diff --git a/src/controllers/NotificationsController.ts b/src/controllers/NotificationsController.ts index 2153e85..15576c6 100644 --- a/src/controllers/NotificationsController.ts +++ b/src/controllers/NotificationsController.ts @@ -85,6 +85,18 @@ export class NotificationsController { h.success() } + /** + * Delete all the notifications of a specific user + * + * @param h Request handler + */ + public static async DeleteAll(h: RequestHandler) { + + await NotificationsHelper.DeleteAllUser(h.getUserId()); + + h.success(); + } + /** * The the ID of a notification included in a request * diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index 6c0a9d7..9b8d491 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -264,6 +264,8 @@ export const Routes : Route[] = [ {path: "/notifications/mark_seen", cb: (h) => NotificationsController.MarkSeen(h)}, + {path: "/notifications/delete_all", cb: (h) => NotificationsController.DeleteAll(h)}, + // Movies controller diff --git a/src/helpers/NotificationsHelper.ts b/src/helpers/NotificationsHelper.ts index 8c243cd..3d3b311 100644 --- a/src/helpers/NotificationsHelper.ts +++ b/src/helpers/NotificationsHelper.ts @@ -255,6 +255,17 @@ export class NotificationsHelper { } + /** + * Delete all the notifications of a given user + * + * @param userID Target user ID + */ + public static async DeleteAllUser(userID: number) { + await this.Delete(new Notif({ + destUserID: userID + })); + } + /** * Count the number of unread notifications of a user *