Added notification bell, WIP.
This commit is contained in:
@@ -140,6 +140,28 @@ export async function removeAlert(alertId, reqUser) {
|
||||
.delete();
|
||||
}
|
||||
|
||||
export async function fetchNotifications(reqUser, options = {}) {
|
||||
const notifications = await knex('notifications')
|
||||
.select('notifications.*', 'alerts.id as alert_id', 'scenes.title as scene_title')
|
||||
.leftJoin('releases as scenes', 'scenes.id', 'notifications.scene_id')
|
||||
.leftJoin('alerts', 'alerts.id', 'notifications.alert_id')
|
||||
.where('notifications.user_id', reqUser.id)
|
||||
.limit(options.limit || 10)
|
||||
.orderBy('created_at', 'desc');
|
||||
|
||||
return notifications.map((notification) => ({
|
||||
id: notification.id,
|
||||
sceneId: notification.scene_id,
|
||||
scene: {
|
||||
id: notification.scene_id,
|
||||
title: notification.scene_title,
|
||||
},
|
||||
alertId: notification.alert_id,
|
||||
isSeen: notification.seen,
|
||||
createdAt: notification.created_at,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function updateNotification(notificationId, updatedNotification, reqUser) {
|
||||
await knex('notifications')
|
||||
.where('id', notificationId)
|
||||
|
||||
Reference in New Issue
Block a user