1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-22 13:29:22 +00:00

Can send notification to all groups moderators

This commit is contained in:
Pierre HUBERT 2020-03-24 18:59:06 +01:00
parent 45e9ca43fe
commit 900ed3cf98
2 changed files with 23 additions and 2 deletions

View File

@ -328,7 +328,11 @@ export class GroupsController {
// Respond to the invitation // Respond to the invitation
await GroupsHelper.RespondInvitation(groupID, h.getUserId(), accept); await GroupsHelper.RespondInvitation(groupID, h.getUserId(), accept);
// TODO : Create a notification // Create a notification
await NotificationsUtils.CreateGroupMembershipNotification(
h.getUserId(), 0, groupID,
accept ? NotifEventType.ACCEPTED_GROUP_MEMBERSHIP_INVITATION : NotifEventType.REJECTED_GROUP_MEMBERSHIP_INVITATION
)
h.success("Response to the invitation was successfully saved!"); h.success("Response to the invitation was successfully saved!");
} }

View File

@ -5,6 +5,7 @@ import { PostsHelper } from "./PostsHelper";
import { PostPageKind, PostVisibilityLevel } from "../entities/Post"; import { PostPageKind, PostVisibilityLevel } from "../entities/Post";
import { FriendsHelper } from "./FriendsHelper"; import { FriendsHelper } from "./FriendsHelper";
import { GroupsHelper } from "./GroupsHelper"; import { GroupsHelper } from "./GroupsHelper";
import { GroupMembershipLevels } from "../entities/GroupMember";
/** /**
* Notifications helper * Notifications helper
@ -133,7 +134,7 @@ export class NotificationsHelper {
else { else {
// Push the notification to all the moderators of the group // Push the notification to all the moderators of the group
throw new Error("//TODO Push notification to all members of the group"); await this.PushGroupModerators(n, n.onElemID);
} }
} }
@ -160,6 +161,22 @@ export class NotificationsHelper {
await this.PushPublic(n, list); await this.PushPublic(n, list);
} }
/**
* Push a notification to all the moderators & administrators of a group
*
* @param n The notification to push
* @param groupID Target group ID
*/
private static async PushGroupModerators(n: Notif, groupID: number) {
let list = await GroupsHelper.GetListMembers(groupID);
// Remove all the users who are not moderators or administrators
list = list.filter((v) => v.level <= GroupMembershipLevels.MODERATOR);
const ids = list.map((v) => v.userID);
await this.PushPublic(n, ids);
}
/** /**
* Push a notification to multiple users * Push a notification to multiple users
* *