mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-21 00:55:17 +00:00
Can create groups membership notifications (moderator > user)
This commit is contained in:
@ -70,4 +70,38 @@ export class NotificationsUtils {
|
||||
fromUserID: userOne,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create & push a group membership notification
|
||||
*
|
||||
* @param userID The ID of the target user for the membership
|
||||
* @param moderatorID The ID of the moderator creating the notification (0 if it is the user)
|
||||
* @param groupID The ID of the target group
|
||||
* @param kind The kind of notification to create
|
||||
*/
|
||||
public static async CreateGroupMembershipNotification(userID: number, moderatorID: number, groupID: number, kind: NotifEventType) {
|
||||
// TODO : Delete all previous notifications
|
||||
|
||||
const n = new Notif({
|
||||
onElemID: groupID,
|
||||
onElemType: NotifElemType.GROUP_MEMBERSHIP,
|
||||
type: kind
|
||||
});
|
||||
|
||||
|
||||
// The notification must be sent to all the moderators of the group
|
||||
if(moderatorID < 1) {
|
||||
n.fromUserID = userID;
|
||||
n.destUserID = -1;
|
||||
}
|
||||
|
||||
// We specify both the source and the destination of the notification
|
||||
// not to broadcast the notification to all the group members
|
||||
else {
|
||||
n.fromUserID = moderatorID;
|
||||
n.destUserID = userID;
|
||||
}
|
||||
|
||||
await NotificationsHelper.Push(n);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user