Repository navigation
refactor: remove rest-api client, access PlaceOS directly - #391
Merged
Merged
Conversation
staff-api and rest-api share a database, so the intra-service requests made through `get_placeos_client` are replaced with local implementations: - systems fetch / with_emails / search: ControlSystem queries (zone searches are a single query instead of one request per zone) - signals: published directly to redis (REDIS_URL), on both the global and authority scoped channels; failures are logged, not raised - X-API-Key auth: ApiKey lookup and JWT built locally - SSO resource tokens: `User#resource_token` from placeos-models Systems are now rendered as `PlaceOS::Model::ControlSystem`, matching rest-api's representation. The `placeos` client shard and the PLACE_URI, PLACE_HOST_HEADER and SSL_VERIFY_NONE settings are removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merged
1 task done
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
stakach
added a commit
to PlaceOS/local
that referenced
this pull request
Oct 8, 2026
staff-api now publishes signals directly to redis (PlaceOS/staff-api#391). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
staff-api and rest-api share a database, so the HTTP calls made through
get_placeos_clientnow run locally. Theplaceoscrystal-client shard is gone.systems.fetchfind_system!:ControlSystem.find!. Guests are still limited to the systems in their JWT roles.systems.with_emailssystems_with_emails: oneControlSystem.where(email: ...)querysystems.search(one request per zone, run in parallel)systems_in_zones: a single SQL query (any zone, all features, capacity>=, bookable)root.signalsignal: RedisPUBLISHtoplaceos/<channel>andplaceos/<authority_id>/<channel>, same as rest-apiapikeys.inspect_jwtApiKey.find_key!→expired?→build_jwtusers.resource_tokenUser#resource_tokenfrom placeos-models (PlaceOS/models#333)Behaviour changes
PlaceOS::Model::ControlSysteminevent.systemandavailability.system. That is a superset of the old client struct, the same object rest-api returns./guest/channel no longer fails. rest-api blocked these for guest JWTs; staff-api chooses the channel itself, so that check doesn't apply here.Config / deploy
REDIS_URL, defaulting toredis://localhost:6379. staff-api deployments already have Redis access.PLACE_URI,PLACE_HOST_HEADER,SSL_VERIFY_NONE.PLACE_URIis no longer required at boot.Tidy-ups
PlaceOS::Client::API::Errorhandler.action_not_implementedhandler toneeds_authentication.system.zones || []no-ops and the repeatedplaceos_clientlocals..to_sbefore it's compared or sent, becauseEmail == Stringis always false.Dependencies
Uses
User#resource_tokenfrom placeos-models 9.119.0 (PlaceOS/models#333).Test plan
./test: 322 examples, 0 failures, 0 errors, 12 pendingSignalSpy).spec/controllers/placeos_direct_spec.crcovers:systems_in_zonesfiltersfind_system!forced auth on the unauthenticated public-event attendee routes.crystal tool format --check,./bin/ameba: clean🤖 Generated with Claude Code