-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetnoti.js
More file actions
29 lines (24 loc) · 928 Bytes
/
setnoti.js
File metadata and controls
29 lines (24 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const express = require('express');
const db = require('./db.js');
const app = express();
app.use(express.json());
app.post('/', (req, res) => {
const { user_id, all_noti = true, chatroom_noti = true, qna_noti = true, accept_noti = true, review_noti = true } = req.body;
const notificationSettings = {
all_noti,
chatroom_noti,
qna_noti,
accept_noti,
review_noti
};
db.query('UPDATE users SET ? WHERE user_id = ?', [notificationSettings, user_id], (err, results) => {
if (err) {
console.error('Error updating notification settings: ' + err.stack);
res.status(500).json({ error: 'Internal server error' });
return;
}
console.log('Notification settings updated for user ID: ' + user_id);
res.status(200).json({ message: 'Notification settings updated successfully' });
});
});
module.exports = app;