mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 21:39:22 +00:00
Can cancel a group membership invitation
This commit is contained in:
parent
675bf79c6e
commit
b396dcd01c
@ -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
|
||||||
*
|
*
|
||||||
|
@ -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)},
|
||||||
]
|
]
|
Loading…
Reference in New Issue
Block a user