]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/models/users/user-role.ts
Add ability to mute a user/instance by server in server api
[github/Chocobozzz/PeerTube.git] / shared / models / users / user-role.ts
CommitLineData
954605a8
C
1import { UserRight } from './user-right.enum'
2
3// Keep the order
4export enum UserRole {
5 ADMINISTRATOR = 0,
6 MODERATOR = 1,
7 USER = 2
8}
9
ba75d268
C
10// TODO: use UserRole for key once https://github.com/Microsoft/TypeScript/issues/13042 is fixed
11export const USER_ROLE_LABELS: { [ id: number ]: string } = {
954605a8
C
12 [UserRole.USER]: 'User',
13 [UserRole.MODERATOR]: 'Moderator',
14 [UserRole.ADMINISTRATOR]: 'Administrator'
15}
16
17// TODO: use UserRole for key once https://github.com/Microsoft/TypeScript/issues/13042 is fixed
18const userRoleRights: { [ id: number ]: UserRight[] } = {
19 [UserRole.ADMINISTRATOR]: [
20 UserRight.ALL
21 ],
22
23 [UserRole.MODERATOR]: [
24 UserRight.MANAGE_VIDEO_BLACKLIST,
25 UserRight.MANAGE_VIDEO_ABUSES,
26 UserRight.REMOVE_ANY_VIDEO,
4cb6d457 27 UserRight.REMOVE_ANY_VIDEO_CHANNEL,
6221f311 28 UserRight.REMOVE_ANY_VIDEO_COMMENT,
1cd3facc 29 UserRight.UPDATE_ANY_VIDEO,
b44164bb
C
30 UserRight.SEE_ALL_VIDEOS,
31 UserRight.MANAGE_ACCOUNTS_BLOCKLIST,
32 UserRight.MANAGE_SERVERS_BLOCKLIST
954605a8
C
33 ],
34
35 [UserRole.USER]: []
36}
37
38export function hasUserRight (userRole: UserRole, userRight: UserRight) {
39 const userRights = userRoleRights[userRole]
40
41 return userRights.indexOf(UserRight.ALL) !== -1 || userRights.indexOf(userRight) !== -1
42}