mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-22 13:29:22 +00:00
Can delete a group membership
This commit is contained in:
parent
b396dcd01c
commit
a3e05bd49e
@ -516,6 +516,27 @@ export class GroupsController {
|
|||||||
h.success("Membership invitation has been cancelled!");
|
h.success("Membership invitation has been cancelled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the membership of a user to a group
|
||||||
|
*
|
||||||
|
* @param h Request handler
|
||||||
|
*/
|
||||||
|
public static async RemoveMembership(h: RequestHandler) {
|
||||||
|
const groupID = await h.postGroupIDWithAccess("id", GroupsAccessLevel.LIMITED_ACCESS);
|
||||||
|
const level = await GroupsHelper.GetMembershipLevel(groupID, h.getUserId());
|
||||||
|
|
||||||
|
if(level == GroupMembershipLevels.ADMINISTRATOR
|
||||||
|
&& await GroupsHelper.CountMembersAtLevel(groupID, GroupMembershipLevels.ADMINISTRATOR) == 1)
|
||||||
|
h.error(401, "You are the last administrator of the group!");
|
||||||
|
|
||||||
|
// Delete mebmership
|
||||||
|
await GroupsHelper.DeleteMember(groupID, h.getUserId());
|
||||||
|
|
||||||
|
// TODO : delete group membership notifications
|
||||||
|
|
||||||
|
h.success("Your membership has been successfully deleted!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn a GroupInfo object into a valid API object
|
* Turn a GroupInfo object into a valid API object
|
||||||
*
|
*
|
||||||
|
@ -124,4 +124,6 @@ export const Routes : Route[] = [
|
|||||||
{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)},
|
{path: "/groups/cancel_invitation", cb: (h) => GroupsController.CancelInvitation(h)},
|
||||||
|
|
||||||
|
{path: "/groups/remove_membership", cb: (h) => GroupsController.RemoveMembership(h)},
|
||||||
]
|
]
|
Loading…
Reference in New Issue
Block a user