Skip to content

feat: add last_active_at ping endpoint#955

Open
dylanjeffers wants to merge 2 commits into
mainfrom
feat/last-active-at-ping
Open

feat: add last_active_at ping endpoint#955
dylanjeffers wants to merge 2 commits into
mainfrom
feat/last-active-at-ping

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

Summary

  • Adds last_active_at column to users table (migration 0221)
  • Adds POST /v1/users/me/ping?user_id=<hashId> endpoint that sets last_active_at = now() for the given user
  • Handler uses myId from the user_id query param (decoded by global resolveMyIdMiddleware) and updates by user_id — avoids wallet-matching issues with delegate/manager wallets
  • Auth is enforced by the global authMiddleware which validates the Encoded-Data-Message/Encoded-Data-Signature headers against the user_id param
  • Adds requireUserIdMiddleware bypass for /users/me/* literal routes

Mobile client compatibility

The mobile pingActivity() function already sends:

  • user_id as a query param (encoded hash ID)
  • Encoded-Data-Message + Encoded-Data-Signature headers via signAPIRequest()
  • No body required

No mobile changes needed.

Test plan

  • go build ./... passes
  • go vet ./api/... passes
  • Integration tests in v1_users_ping_test.go cover: authenticated 200, missing user_id 400, unauthenticated 403
  • Verify on staging: POST /v1/users/me/ping?user_id=<id> with signature headers returns 200
  • Verify last_active_at column is updated in the DB after a successful ping

🤖 Generated with Claude Code

dylanjeffers and others added 2 commits June 15, 2026 18:36
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant