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

Can cancel a group membership request

This commit is contained in:
Pierre HUBERT 2019-12-27 10:02:05 +01:00
parent 8c31a4d8c4
commit 3be2b8d90f
2 changed files with 21 additions and 0 deletions

View File

@ -368,6 +368,25 @@ export class GroupsController {
h.success("The membership has been successfully saved!");
}
/**
* Cancel a membership request
*
* @param h Request handler
*/
public static async CancelRequest(h: RequestHandler) {
const groupID = await h.postGroupIDWithAccess("id", GroupsAccessLevel.LIMITED_ACCESS);
if(await GroupsHelper.GetMembershipLevel(groupID, h.getUserId()) != GroupMembershipLevels.PENDING)
h.error(401, "You did not send a membership request to this group!");
// Delete membership of the user
await GroupsHelper.DeleteMember(groupID, h.getUserId());
// TODO : delete any potential notificaton
h.success("The request has been successfully cancelled!");
}
/**
* Turn a GroupInfo object into a valid API object
*

View File

@ -112,4 +112,6 @@ export const Routes : Route[] = [
{path: "/groups/respond_invitation", cb: (h) => GroupsController.RespondInvitation(h)},
{path: "/groups/send_request", cb: (h) => GroupsController.SendRequest(h)},
{path: "/groups/cancel_request", cb: (h) => GroupsController.CancelRequest(h)},
]