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

Can cancel a group membership invitation

This commit is contained in:
Pierre HUBERT 2019-12-27 18:24:18 +01:00
parent 675bf79c6e
commit b396dcd01c
2 changed files with 22 additions and 0 deletions

View File

@ -496,6 +496,26 @@ export class GroupsController {
h.send(this.GroupMemberToAPI(membership)); h.send(this.GroupMemberToAPI(membership));
} }
/**
* Cancel a group membership invitation
*
* @param h Request handler
*/
public static async CancelInvitation(h: RequestHandler) {
const groupID = await h.postGroupIDWithAccess("groupID", GroupsAccessLevel.MODERATOR_ACCESS);
const userID = await h.postUserId("userID");
if(await GroupsHelper.GetMembershipLevel(groupID, userID) != GroupMembershipLevels.INVITED)
h.error(401, "This user has not been invited to join this group!");
// Cancel group invitation
await GroupsHelper.DeleteMember(groupID, userID);
// TODO : delete related notifications
h.success("Membership invitation has been cancelled!");
}
/** /**
* Turn a GroupInfo object into a valid API object * Turn a GroupInfo object into a valid API object
* *

View File

@ -122,4 +122,6 @@ export const Routes : Route[] = [
{path: "/groups/respond_request", cb: (h) => GroupsController.RespondRequest(h)}, {path: "/groups/respond_request", cb: (h) => GroupsController.RespondRequest(h)},
{path: "/groups/get_membership", cb: (h) => GroupsController.GetMembership(h)}, {path: "/groups/get_membership", cb: (h) => GroupsController.GetMembership(h)},
{path: "/groups/cancel_invitation", cb: (h) => GroupsController.CancelInvitation(h)},
] ]