mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-21 00:55:17 +00:00
Can delete notifications related to a friendship request
This commit is contained in:
@ -32,20 +32,42 @@ export class NotificationsUtils {
|
||||
* Create & push friendship request notification
|
||||
*
|
||||
* @param fromUser Source user ID
|
||||
* @param toUser Destination user ID
|
||||
* @param destUser Destination user ID
|
||||
* @param action The kind of action
|
||||
*/
|
||||
public static async CreateFriendsNotifications(fromUser: number, toUser: number, action: NotifEventType) {
|
||||
// TODO : Delete all the previous notifications
|
||||
public static async CreateFriendsNotifications(fromUser: number, destUser: number, action: NotifEventType) {
|
||||
await this.DeleteNotificationsFrienshipRequest(fromUser, destUser);
|
||||
|
||||
// PUsh the notification
|
||||
// Push the notification
|
||||
await NotificationsHelper.Push(new Notif({
|
||||
fromUserID: fromUser,
|
||||
destUserID: toUser,
|
||||
destUserID: destUser,
|
||||
onElemID: fromUser, // Same as fromUser
|
||||
onElemType: NotifElemType.FRIENDSHIP_REQUEST,
|
||||
type: action
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all the notifications related to a friendship request between two users
|
||||
*
|
||||
* @param userOne First user
|
||||
* @param userTwo Second user
|
||||
*/
|
||||
public static async DeleteNotificationsFrienshipRequest(userOne: number, userTwo: number) {
|
||||
|
||||
// Delete notifications in two ways
|
||||
await NotificationsHelper.Delete(new Notif({
|
||||
onElemType: NotifElemType.FRIENDSHIP_REQUEST,
|
||||
destUserID: userOne,
|
||||
fromUserID: userTwo,
|
||||
}));
|
||||
|
||||
await NotificationsHelper.Delete(new Notif({
|
||||
onElemType: NotifElemType.FRIENDSHIP_REQUEST,
|
||||
destUserID: userTwo,
|
||||
fromUserID: userOne,
|
||||
}));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user