mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-25 23: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) {
|
public static async RemoveMembership(h: RequestHandler) {
|
||||||
const groupID = await h.postGroupIDWithAccess("id", GroupsAccessLevel.LIMITED_ACCESS);
|
const groupID = await h.postGroupIDWithAccess("id", GroupsAccessLevel.LIMITED_ACCESS);
|
||||||
const level = await GroupsHelper.GetMembershipLevel(groupID, h.getUserId());
|
|
||||||
|
|
||||||
// TODO : use new method
|
if(await GroupsHelper.IsLastAdmin(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!");
|
h.error(401, "You are the last administrator of the group!");
|
||||||
|
|
||||||
// Delete mebmership
|
// Delete mebmership
|
||||||
|
@ -398,7 +398,7 @@ export class GroupsHelper {
|
|||||||
* @param groupID Target group ID
|
* @param groupID Target group ID
|
||||||
* @param userID Target user 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
|
return await this.GetMembershipLevel(groupID, userID) == GroupMembershipLevels.ADMINISTRATOR
|
||||||
&& await GroupsHelper.CountMembersAtLevel(groupID, GroupMembershipLevels.ADMINISTRATOR) == 1;
|
&& await GroupsHelper.CountMembersAtLevel(groupID, GroupMembershipLevels.ADMINISTRATOR) == 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user