v0.12.26 FCM feature changes
This commit is contained in:
@@ -36,6 +36,10 @@ async function sendPushToUser(schema, userId, payload) {
|
||||
'SELECT * FROM push_subscriptions WHERE user_id = $1 AND fcm_token IS NOT NULL',
|
||||
[userId]
|
||||
);
|
||||
if (subs.length === 0) {
|
||||
console.log(`[Push] No FCM token for user ${userId} (schema=${schema})`);
|
||||
return;
|
||||
}
|
||||
for (const sub of subs) {
|
||||
try {
|
||||
await messaging.send({
|
||||
@@ -70,6 +74,7 @@ async function sendPushToUser(schema, userId, payload) {
|
||||
fcm_options: { link: payload.url || '/' },
|
||||
},
|
||||
});
|
||||
console.log(`[Push] Sent to user ${userId} device=${sub.device} schema=${schema}`);
|
||||
} catch (err) {
|
||||
// Remove stale tokens
|
||||
const stale = [
|
||||
|
||||
Reference in New Issue
Block a user