mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-22 04:03:21 +03:00
Completed notification functionality
Minor code cleanup
This commit is contained in:
@@ -1,13 +1,32 @@
|
||||
const utils = require('./utils');
|
||||
const logger = require('./logger');
|
||||
const { uuid } = require('uuidv4');
|
||||
const db_api = require('./db');
|
||||
|
||||
exports.sendNotification = async () => {
|
||||
exports.sendNotification = async (notification) => {
|
||||
// TODO: hook into third party service
|
||||
|
||||
const notification = {}
|
||||
|
||||
await db_api.insertRecordIntoTable('notifications', notification);
|
||||
|
||||
return notification;
|
||||
}
|
||||
}
|
||||
|
||||
exports.sendDownloadNotification = async (file, user_uid) => {
|
||||
const data = {file_uid: file.uid, file_title: file.title};
|
||||
const notification = exports.createNotification('download_complete', ['play'], data, user_uid);
|
||||
return await exports.sendNotification(notification);
|
||||
}
|
||||
|
||||
exports.sendDownloadErrorNotification = async (download, user_uid) => {
|
||||
const data = {download_uid: download.uid, download_url: download.url};
|
||||
const notification = exports.createNotification('download_error', ['view_download_error', 'retry_download'], data, user_uid);
|
||||
return await exports.sendNotification(notification);
|
||||
}
|
||||
|
||||
exports.createNotification = (type, actions, data, user_uid) => {
|
||||
const notification = {
|
||||
type: type,
|
||||
actions: actions,
|
||||
data: data,
|
||||
user_uid: user_uid,
|
||||
uid: uuid(),
|
||||
read: false
|
||||
}
|
||||
return notification;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user