mirror of
				https://gitlab.com/comunic/comunicapiv2
				synced 2025-10-31 09:34:44 +00:00 
			
		
		
		
	Can send notification to all groups moderators
This commit is contained in:
		| @@ -328,7 +328,11 @@ export class GroupsController { | ||||
| 		// Respond to the invitation | ||||
| 		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!"); | ||||
| 	} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import { PostsHelper } from "./PostsHelper"; | ||||
| import { PostPageKind, PostVisibilityLevel } from "../entities/Post"; | ||||
| import { FriendsHelper } from "./FriendsHelper"; | ||||
| import { GroupsHelper } from "./GroupsHelper"; | ||||
| import { GroupMembershipLevels } from "../entities/GroupMember"; | ||||
|  | ||||
| /** | ||||
|  * Notifications helper | ||||
| @@ -133,7 +134,7 @@ export class NotificationsHelper { | ||||
| 			else { | ||||
|  | ||||
| 				// 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); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 *  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user