1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-21 00:55:17 +00:00

Get information about a group

This commit is contained in:
2019-12-15 17:37:39 +01:00
parent af9e95a914
commit 76b0d9605c
4 changed files with 197 additions and 4 deletions

View File

@ -1,9 +1,14 @@
import { pathUserData } from "../utils/UserDataUtils";
import { join } from "path";
/**
* Single group information
*
* @author Pierre HUBERT
*/
export const PATH_GROUP_LOGO = "groups_logo";
/**
* Group visibility level
*/
@ -23,4 +28,65 @@ export enum GroupsAccessLevel {
MEMBER_ACCESS = 3, //Member access (same as view access but as member)
MODERATOR_ACCESS = 4, //Can create posts, even if posts creation is restricted
ADMIN_ACCESS = 5, //Can do everything
}
/**
* Registration level of groups
*/
export enum GroupRegistrationLevel {
OPEN_REGISTRATION = 0,
MODERATED_REGISTRATION = 1,
CLOSED_REGISTRATION = 2,
}
export enum GroupPostsCreationLevel {
POSTS_LEVEL_MODERATORS = 0, //Only the moderators and the administrator can create posts
POSTS_LEVEL_ALL_MEMBERS = 1, //All the members of the group can create posts
}
export interface GroupInfoConstructor {
id: number,
name: string,
membersCount: number,
visiblity: GroupVisibilityLevel,
registrationLevel: GroupRegistrationLevel,
postsCreationLevel: GroupPostsCreationLevel,
logo ?: string,
virtualDirectory ?: string
}
export class GroupInfo implements GroupInfoConstructor {
id: number;
name: string;
membersCount: number;
visiblity: GroupVisibilityLevel;
registrationLevel: GroupRegistrationLevel;
postsCreationLevel: GroupPostsCreationLevel;
logo?: string;
virtualDirectory?: string;
constructor(info: GroupInfoConstructor) {
for (const key in info) {
if (info.hasOwnProperty(key)) {
this[key] = info[key];
}
}
}
get hasLogo() : boolean {
return this.logo
&& this.logo != "null"
&& this.logo != undefined;
}
get logoPath() : string {
if(this.hasLogo)
return this.logo
else
return join(PATH_GROUP_LOGO, "default.png");
}
get logoURL() : string {
return pathUserData(this.logoPath, false);
}
}