feat: add last_active_at ping endpoint#955
Open
dylanjeffers wants to merge 2 commits into
Open
Conversation
…et auth The handler was using getAuthedWallet(c) which required signature-based auth, then updating by wallet address. This was overcomplicated for a fire-and-forget activity signal. Now uses myId from the user_id query param (already decoded by resolveMyIdMiddleware) and updates by user_id. Removes requireAuthMiddleware from the route since the handler no longer needs the wallet — the global authMiddleware still validates signatures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers the three key paths: - Authenticated request with valid user_id returns 200 - Missing user_id returns 400 - Unauthenticated request with user_id returns 403 Co-Authored-By: Claude Opus 4.6 <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
last_active_atcolumn touserstable (migration 0221)POST /v1/users/me/ping?user_id=<hashId>endpoint that setslast_active_at = now()for the given usermyIdfrom theuser_idquery param (decoded by globalresolveMyIdMiddleware) and updates byuser_id— avoids wallet-matching issues with delegate/manager walletsauthMiddlewarewhich validates theEncoded-Data-Message/Encoded-Data-Signatureheaders against theuser_idparamrequireUserIdMiddlewarebypass for/users/me/*literal routesMobile client compatibility
The mobile
pingActivity()function already sends:user_idas a query param (encoded hash ID)Encoded-Data-Message+Encoded-Data-Signatureheaders viasignAPIRequest()No mobile changes needed.
Test plan
go build ./...passesgo vet ./api/...passesv1_users_ping_test.gocover: authenticated 200, missing user_id 400, unauthenticated 403POST /v1/users/me/ping?user_id=<id>with signature headers returns 200last_active_atcolumn is updated in the DB after a successful ping🤖 Generated with Claude Code