feat(push): native device-token registration + FCM/APNs senders
- /api/v1/devices (register) + /api/v1/devices/remove — auth-required, validates platform (ios|android), upserts by token; e2e covers register/validation/auth/remove. - db device_tokens table + deviceTokens repo. - push.js: FCM HTTP v1 (Android) and APNs token-based over HTTP/2 (iOS) folded into the single push.sendToUser path alongside Web Push; each transport independently config-gated and a silent no-op without creds. Dead tokens pruned on 404/410. - docs: CLIENTS.md Phase B updated; DEPLOY.md env table adds FCM/APNs vars. e2e 117/117. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -306,6 +306,21 @@ CREATE TABLE IF NOT EXISTS push_subscriptions (
|
||||
CREATE INDEX IF NOT EXISTS idx_push_user ON push_subscriptions(user_id);
|
||||
`);
|
||||
|
||||
// Native device push tokens (FCM for Android, APNs for iOS) registered by the mobile app.
|
||||
// Distinct from push_subscriptions (Web Push): a native token is just an opaque string + platform.
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS device_tokens (
|
||||
id TEXT PRIMARY KEY,
|
||||
user_id TEXT NOT NULL,
|
||||
tenant_id TEXT,
|
||||
platform TEXT NOT NULL,
|
||||
token TEXT NOT NULL UNIQUE,
|
||||
created_at INTEGER NOT NULL,
|
||||
last_seen INTEGER
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_devtok_user ON device_tokens(user_id);
|
||||
`);
|
||||
|
||||
// Favourite conversations (per user). target = 'dm:<userId>' or 'group:<groupId>'.
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS favorites (
|
||||
|
||||
Reference in New Issue
Block a user