mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-04 04:21:30 +03:00
Added notifications - (WIP, boilerplate)
This commit is contained in:
@@ -1992,6 +1992,44 @@ app.post('/api/changeRolePermissions', optionalJwt, async (req, res) => {
|
||||
res.send({success: success});
|
||||
});
|
||||
|
||||
// notifications
|
||||
|
||||
app.post('/api/getNotifications', optionalJwt, async (req, res) => {
|
||||
const uuid = req.user.uid;
|
||||
|
||||
const notifications = await db_api.getRecords('notifications', {user_uid: uuid});
|
||||
|
||||
res.send({notifications: notifications});
|
||||
});
|
||||
|
||||
// set notifications to read
|
||||
app.post('/api/setNotificationsToRead', optionalJwt, async (req, res) => {
|
||||
const uids = req.body.uids;
|
||||
|
||||
// TODO: do a bulk update
|
||||
const success = true; // await db_api.updateRecords('notifications', {user_uid: uuid});
|
||||
|
||||
res.send({success: success});
|
||||
});
|
||||
|
||||
app.post('/api/deleteNotification', optionalJwt, async (req, res) => {
|
||||
const uid = req.body.uid;
|
||||
|
||||
const success = await db_api.removeRecord('notifications', {uid: uid});
|
||||
|
||||
res.send({success: success});
|
||||
});
|
||||
|
||||
app.post('/api/deleteAllNotifications', optionalJwt, async (req, res) => {
|
||||
const uuid = req.user.uid;
|
||||
|
||||
const success = await db_api.removeAllRecords('notifications', {user_uid: uuid});
|
||||
|
||||
res.send({success: success});
|
||||
});
|
||||
|
||||
// web server
|
||||
|
||||
app.use(function(req, res, next) {
|
||||
//if the request is not html then move along
|
||||
var accept = req.accepts('html', 'json', 'xml');
|
||||
|
||||
@@ -58,6 +58,10 @@ const tables = {
|
||||
name: 'tasks',
|
||||
primary_key: 'key'
|
||||
},
|
||||
notifications: {
|
||||
name: 'notifications',
|
||||
primary_key: 'uid'
|
||||
},
|
||||
test: {
|
||||
name: 'test'
|
||||
}
|
||||
|
||||
13
backend/notifications.js
Normal file
13
backend/notifications.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const utils = require('./utils');
|
||||
const logger = require('./logger');
|
||||
const db_api = require('./db');
|
||||
|
||||
exports.sendNotification = async () => {
|
||||
// TODO: hook into third party service
|
||||
|
||||
const notification = {}
|
||||
|
||||
await db_api.insertRecordIntoTable('notifications', notification);
|
||||
|
||||
return notification;
|
||||
}
|
||||
Reference in New Issue
Block a user