1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-21 09:05:17 +00:00

Create notification when posting a new comment

This commit is contained in:
2020-03-23 19:08:04 +01:00
parent bd83a77fb2
commit edc68a0275
4 changed files with 51 additions and 9 deletions

View File

@ -0,0 +1,30 @@
/**
* Notifications utilities
*
* @author Pierre Hubert
*/
import { NotifEventType, Notif, NotifElemType } from "../entities/Notification";
import { NotificationsHelper } from "../helpers/NotificationsHelper";
import { time } from "./DateUtils";
export class NotificationsUtils {
/**
* Create a notification about a post
*
* @param fromUser Source user ID
* @param postID Target post ID
* @param action Action to notify
*/
public static async CreatePostNotification(fromUser: number, postID: number, action: NotifEventType) {
await NotificationsHelper.Push(new Notif({
timeCreate: time(),
fromUserID: fromUser,
onElemID: postID,
onElemType: NotifElemType.POST,
type: action
}));
}
}