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:
30
src/utils/NotificationsUtils.ts
Normal file
30
src/utils/NotificationsUtils.ts
Normal 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
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user