v0.8.7 pin bug fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jama-backend",
|
||||
"version": "0.8.6",
|
||||
"version": "0.8.7",
|
||||
"description": "TeamChat backend server",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -70,11 +70,12 @@ router.post('/subscribe', authMiddleware, (req, res) => {
|
||||
return res.status(400).json({ error: 'Invalid subscription' });
|
||||
}
|
||||
const db = getDb();
|
||||
db.prepare(`
|
||||
INSERT INTO push_subscriptions (user_id, endpoint, p256dh, auth)
|
||||
VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT(endpoint) DO UPDATE SET user_id = ?, p256dh = ?, auth = ?
|
||||
`).run(req.user.id, endpoint, keys.p256dh, keys.auth, req.user.id, keys.p256dh, keys.auth);
|
||||
// Use DELETE+INSERT to avoid relying on any specific UNIQUE constraint
|
||||
// (existing DBs may have different schemas for this table)
|
||||
const delStmt = db.prepare('DELETE FROM push_subscriptions WHERE endpoint = ?');
|
||||
const insStmt = db.prepare('INSERT INTO push_subscriptions (user_id, endpoint, p256dh, auth) VALUES (?, ?, ?, ?)');
|
||||
delStmt.run(endpoint);
|
||||
insStmt.run(req.user.id, endpoint, keys.p256dh, keys.auth);
|
||||
res.json({ success: true });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user