mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-21 21:09:22 +00:00
Do one TODO
This commit is contained in:
parent
c222c8b054
commit
c945c6acda
@ -532,11 +532,8 @@ export class GroupsController {
|
||||
*/
|
||||
public static async RemoveMembership(h: RequestHandler) {
|
||||
const groupID = await h.postGroupIDWithAccess("id", GroupsAccessLevel.LIMITED_ACCESS);
|
||||
const level = await GroupsHelper.GetMembershipLevel(groupID, h.getUserId());
|
||||
|
||||
// TODO : use new method
|
||||
if(level == GroupMembershipLevels.ADMINISTRATOR
|
||||
&& await GroupsHelper.CountMembersAtLevel(groupID, GroupMembershipLevels.ADMINISTRATOR) == 1)
|
||||
if(await GroupsHelper.IsLastAdmin(groupID, h.getUserId()))
|
||||
h.error(401, "You are the last administrator of the group!");
|
||||
|
||||
// Delete mebmership
|
||||
|
@ -398,7 +398,7 @@ export class GroupsHelper {
|
||||
* @param groupID Target group ID
|
||||
* @param userID Target user ID
|
||||
*/
|
||||
private static async IsLastAdmin(groupID: number, userID: number) : Promise<boolean> {
|
||||
public static async IsLastAdmin(groupID: number, userID: number) : Promise<boolean> {
|
||||
return await this.GetMembershipLevel(groupID, userID) == GroupMembershipLevels.ADMINISTRATOR
|
||||
&& await GroupsHelper.CountMembersAtLevel(groupID, GroupMembershipLevels.ADMINISTRATOR) == 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user