aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-06 14:58:01 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-07 08:28:14 +0200
commitbd45d503e5d007e730f4e81dccd7e7864c9a85cc (patch)
treeb78df768b8253ba401232c17da940cea016c9960 /shared
parent583eb04b541175035d6d452ca626a96ebf2b7437 (diff)
downloadPeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.tar.gz
PeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.tar.zst
PeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.zip
Reorganize shared models
Diffstat (limited to 'shared')
-rw-r--r--shared/core-utils/abuse/abuse-predefined-reasons.ts14
-rw-r--r--shared/core-utils/abuse/index.ts1
-rw-r--r--shared/core-utils/i18n/i18n.ts (renamed from shared/models/i18n/i18n.ts)0
-rw-r--r--shared/core-utils/i18n/index.ts (renamed from shared/models/i18n/index.ts)0
-rw-r--r--shared/core-utils/users/index.ts1
-rw-r--r--shared/core-utils/users/user-role.ts35
-rw-r--r--shared/models/feeds/feed-format.enum.ts2
-rw-r--r--shared/models/index.ts1
-rw-r--r--shared/models/moderation/abuse/abuse-reason.model.ts15
-rw-r--r--shared/models/moderation/abuse/abuse-state.model.ts2
-rw-r--r--shared/models/plugins/hook-type.enum.ts2
-rw-r--r--shared/models/users/user-flag.model.ts2
-rw-r--r--shared/models/users/user-notification-setting.model.ts2
-rw-r--r--shared/models/users/user-right.enum.ts2
-rw-r--r--shared/models/users/user-role.ts36
-rw-r--r--shared/models/videos/blacklist/video-blacklist.model.ts2
-rw-r--r--shared/models/videos/import/video-import-state.enum.ts2
-rw-r--r--shared/models/videos/playlist/video-playlist-element.model.ts2
-rw-r--r--shared/models/videos/playlist/video-playlist-privacy.model.ts2
-rw-r--r--shared/models/videos/playlist/video-playlist-type.model.ts2
-rw-r--r--shared/models/videos/thumbnail.type.ts2
-rw-r--r--shared/models/videos/video-change-ownership.model.ts2
-rw-r--r--shared/models/videos/video-privacy.enum.ts2
-rw-r--r--shared/models/videos/video-resolution.enum.ts2
-rw-r--r--shared/models/videos/video-state.enum.ts2
-rw-r--r--shared/models/videos/video-streaming-playlist.type.ts2
26 files changed, 69 insertions, 68 deletions
diff --git a/shared/core-utils/abuse/abuse-predefined-reasons.ts b/shared/core-utils/abuse/abuse-predefined-reasons.ts
new file mode 100644
index 000000000..9967e54dd
--- /dev/null
+++ b/shared/core-utils/abuse/abuse-predefined-reasons.ts
@@ -0,0 +1,14 @@
1import { AbusePredefinedReasons, AbusePredefinedReasonsString } from '../../models/moderation/abuse/abuse-reason.model'
2
3export const abusePredefinedReasonsMap: {
4 [key in AbusePredefinedReasonsString]: AbusePredefinedReasons
5} = {
6 violentOrRepulsive: AbusePredefinedReasons.VIOLENT_OR_REPULSIVE,
7 hatefulOrAbusive: AbusePredefinedReasons.HATEFUL_OR_ABUSIVE,
8 spamOrMisleading: AbusePredefinedReasons.SPAM_OR_MISLEADING,
9 privacy: AbusePredefinedReasons.PRIVACY,
10 rights: AbusePredefinedReasons.RIGHTS,
11 serverRules: AbusePredefinedReasons.SERVER_RULES,
12 thumbnails: AbusePredefinedReasons.THUMBNAILS,
13 captions: AbusePredefinedReasons.CAPTIONS
14}
diff --git a/shared/core-utils/abuse/index.ts b/shared/core-utils/abuse/index.ts
new file mode 100644
index 000000000..244b83cff
--- /dev/null
+++ b/shared/core-utils/abuse/index.ts
@@ -0,0 +1 @@
export * from './abuse-predefined-reasons'
diff --git a/shared/models/i18n/i18n.ts b/shared/core-utils/i18n/i18n.ts
index 9ad0f456d..9ad0f456d 100644
--- a/shared/models/i18n/i18n.ts
+++ b/shared/core-utils/i18n/i18n.ts
diff --git a/shared/models/i18n/index.ts b/shared/core-utils/i18n/index.ts
index 8f7cbe2c7..8f7cbe2c7 100644
--- a/shared/models/i18n/index.ts
+++ b/shared/core-utils/i18n/index.ts
diff --git a/shared/core-utils/users/index.ts b/shared/core-utils/users/index.ts
new file mode 100644
index 000000000..1cbf0af1b
--- /dev/null
+++ b/shared/core-utils/users/index.ts
@@ -0,0 +1 @@
export * from './user-role'
diff --git a/shared/core-utils/users/user-role.ts b/shared/core-utils/users/user-role.ts
new file mode 100644
index 000000000..2b322faf3
--- /dev/null
+++ b/shared/core-utils/users/user-role.ts
@@ -0,0 +1,35 @@
1import { UserRight, UserRole } from '../../models/users'
2
3export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = {
4 [UserRole.USER]: 'User',
5 [UserRole.MODERATOR]: 'Moderator',
6 [UserRole.ADMINISTRATOR]: 'Administrator'
7}
8
9const userRoleRights: { [ id in UserRole ]: UserRight[] } = {
10 [UserRole.ADMINISTRATOR]: [
11 UserRight.ALL
12 ],
13
14 [UserRole.MODERATOR]: [
15 UserRight.MANAGE_VIDEO_BLACKLIST,
16 UserRight.MANAGE_ABUSES,
17 UserRight.REMOVE_ANY_VIDEO,
18 UserRight.REMOVE_ANY_VIDEO_CHANNEL,
19 UserRight.REMOVE_ANY_VIDEO_PLAYLIST,
20 UserRight.REMOVE_ANY_VIDEO_COMMENT,
21 UserRight.UPDATE_ANY_VIDEO,
22 UserRight.SEE_ALL_VIDEOS,
23 UserRight.MANAGE_ACCOUNTS_BLOCKLIST,
24 UserRight.MANAGE_SERVERS_BLOCKLIST,
25 UserRight.MANAGE_USERS
26 ],
27
28 [UserRole.USER]: []
29}
30
31export function hasUserRight (userRole: UserRole, userRight: UserRight) {
32 const userRights = userRoleRights[userRole]
33
34 return userRights.includes(UserRight.ALL) || userRights.includes(userRight)
35}
diff --git a/shared/models/feeds/feed-format.enum.ts b/shared/models/feeds/feed-format.enum.ts
index f3173a781..d3d574331 100644
--- a/shared/models/feeds/feed-format.enum.ts
+++ b/shared/models/feeds/feed-format.enum.ts
@@ -1,4 +1,4 @@
1export enum FeedFormat { 1export const enum FeedFormat {
2 RSS = 'xml', 2 RSS = 'xml',
3 ATOM = 'atom', 3 ATOM = 'atom',
4 JSON = 'json' 4 JSON = 'json'
diff --git a/shared/models/index.ts b/shared/models/index.ts
index a68f57148..2214f7ca3 100644
--- a/shared/models/index.ts
+++ b/shared/models/index.ts
@@ -7,7 +7,6 @@ export * from './redundancy'
7export * from './users' 7export * from './users'
8export * from './videos' 8export * from './videos'
9export * from './feeds' 9export * from './feeds'
10export * from './i18n'
11export * from './overviews' 10export * from './overviews'
12export * from './plugins' 11export * from './plugins'
13export * from './search' 12export * from './search'
diff --git a/shared/models/moderation/abuse/abuse-reason.model.ts b/shared/models/moderation/abuse/abuse-reason.model.ts
index 36875969d..57359aef6 100644
--- a/shared/models/moderation/abuse/abuse-reason.model.ts
+++ b/shared/models/moderation/abuse/abuse-reason.model.ts
@@ -1,4 +1,4 @@
1export enum AbusePredefinedReasons { 1export const enum AbusePredefinedReasons {
2 VIOLENT_OR_REPULSIVE = 1, 2 VIOLENT_OR_REPULSIVE = 1,
3 HATEFUL_OR_ABUSIVE, 3 HATEFUL_OR_ABUSIVE,
4 SPAM_OR_MISLEADING, 4 SPAM_OR_MISLEADING,
@@ -18,16 +18,3 @@ export type AbusePredefinedReasonsString =
18 'serverRules' | 18 'serverRules' |
19 'thumbnails' | 19 'thumbnails' |
20 'captions' 20 'captions'
21
22export const abusePredefinedReasonsMap: {
23 [key in AbusePredefinedReasonsString]: AbusePredefinedReasons
24} = {
25 violentOrRepulsive: AbusePredefinedReasons.VIOLENT_OR_REPULSIVE,
26 hatefulOrAbusive: AbusePredefinedReasons.HATEFUL_OR_ABUSIVE,
27 spamOrMisleading: AbusePredefinedReasons.SPAM_OR_MISLEADING,
28 privacy: AbusePredefinedReasons.PRIVACY,
29 rights: AbusePredefinedReasons.RIGHTS,
30 serverRules: AbusePredefinedReasons.SERVER_RULES,
31 thumbnails: AbusePredefinedReasons.THUMBNAILS,
32 captions: AbusePredefinedReasons.CAPTIONS
33}
diff --git a/shared/models/moderation/abuse/abuse-state.model.ts b/shared/models/moderation/abuse/abuse-state.model.ts
index b00cccad8..8ef6fdada 100644
--- a/shared/models/moderation/abuse/abuse-state.model.ts
+++ b/shared/models/moderation/abuse/abuse-state.model.ts
@@ -1,4 +1,4 @@
1export enum AbuseState { 1export const enum AbuseState {
2 PENDING = 1, 2 PENDING = 1,
3 REJECTED = 2, 3 REJECTED = 2,
4 ACCEPTED = 3 4 ACCEPTED = 3
diff --git a/shared/models/plugins/hook-type.enum.ts b/shared/models/plugins/hook-type.enum.ts
index 66d24071c..a96c943f1 100644
--- a/shared/models/plugins/hook-type.enum.ts
+++ b/shared/models/plugins/hook-type.enum.ts
@@ -1,4 +1,4 @@
1export enum HookType { 1export const enum HookType {
2 STATIC = 1, 2 STATIC = 1,
3 ACTION = 2, 3 ACTION = 2,
4 FILTER = 3 4 FILTER = 3
diff --git a/shared/models/users/user-flag.model.ts b/shared/models/users/user-flag.model.ts
index b94262d5e..b791a1263 100644
--- a/shared/models/users/user-flag.model.ts
+++ b/shared/models/users/user-flag.model.ts
@@ -1,4 +1,4 @@
1export enum UserAdminFlag { 1export const enum UserAdminFlag {
2 NONE = 0, 2 NONE = 0,
3 BYPASS_VIDEO_AUTO_BLACKLIST = 1 << 0 3 BYPASS_VIDEO_AUTO_BLACKLIST = 1 << 0
4} 4}
diff --git a/shared/models/users/user-notification-setting.model.ts b/shared/models/users/user-notification-setting.model.ts
index c7590fa8a..473148062 100644
--- a/shared/models/users/user-notification-setting.model.ts
+++ b/shared/models/users/user-notification-setting.model.ts
@@ -1,4 +1,4 @@
1export enum UserNotificationSettingValue { 1export const enum UserNotificationSettingValue {
2 NONE = 0, 2 NONE = 0,
3 WEB = 1 << 0, 3 WEB = 1 << 0,
4 EMAIL = 1 << 1 4 EMAIL = 1 << 1
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts
index 4a7ae4373..4c3d9e7c8 100644
--- a/shared/models/users/user-right.enum.ts
+++ b/shared/models/users/user-right.enum.ts
@@ -1,4 +1,4 @@
1export enum UserRight { 1export const enum UserRight {
2 ALL, 2 ALL,
3 3
4 MANAGE_USERS, 4 MANAGE_USERS,
diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts
index 772988c0c..94413abca 100644
--- a/shared/models/users/user-role.ts
+++ b/shared/models/users/user-role.ts
@@ -1,42 +1,6 @@
1import { UserRight } from './user-right.enum'
2
3// Keep the order 1// Keep the order
4export enum UserRole { 2export enum UserRole {
5 ADMINISTRATOR = 0, 3 ADMINISTRATOR = 0,
6 MODERATOR = 1, 4 MODERATOR = 1,
7 USER = 2 5 USER = 2
8} 6}
9
10export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = {
11 [UserRole.USER]: 'User',
12 [UserRole.MODERATOR]: 'Moderator',
13 [UserRole.ADMINISTRATOR]: 'Administrator'
14}
15
16const userRoleRights: { [ id in UserRole ]: UserRight[] } = {
17 [UserRole.ADMINISTRATOR]: [
18 UserRight.ALL
19 ],
20
21 [UserRole.MODERATOR]: [
22 UserRight.MANAGE_VIDEO_BLACKLIST,
23 UserRight.MANAGE_ABUSES,
24 UserRight.REMOVE_ANY_VIDEO,
25 UserRight.REMOVE_ANY_VIDEO_CHANNEL,
26 UserRight.REMOVE_ANY_VIDEO_PLAYLIST,
27 UserRight.REMOVE_ANY_VIDEO_COMMENT,
28 UserRight.UPDATE_ANY_VIDEO,
29 UserRight.SEE_ALL_VIDEOS,
30 UserRight.MANAGE_ACCOUNTS_BLOCKLIST,
31 UserRight.MANAGE_SERVERS_BLOCKLIST,
32 UserRight.MANAGE_USERS
33 ],
34
35 [UserRole.USER]: []
36}
37
38export function hasUserRight (userRole: UserRole, userRight: UserRight) {
39 const userRights = userRoleRights[userRole]
40
41 return userRights.includes(UserRight.ALL) || userRights.includes(userRight)
42}
diff --git a/shared/models/videos/blacklist/video-blacklist.model.ts b/shared/models/videos/blacklist/video-blacklist.model.ts
index a6e0ef175..982a34592 100644
--- a/shared/models/videos/blacklist/video-blacklist.model.ts
+++ b/shared/models/videos/blacklist/video-blacklist.model.ts
@@ -1,6 +1,6 @@
1import { Video } from '../video.model' 1import { Video } from '../video.model'
2 2
3export enum VideoBlacklistType { 3export const enum VideoBlacklistType {
4 MANUAL = 1, 4 MANUAL = 1,
5 AUTO_BEFORE_PUBLISHED = 2 5 AUTO_BEFORE_PUBLISHED = 2
6} 6}
diff --git a/shared/models/videos/import/video-import-state.enum.ts b/shared/models/videos/import/video-import-state.enum.ts
index 8421b8ca7..33dd83f88 100644
--- a/shared/models/videos/import/video-import-state.enum.ts
+++ b/shared/models/videos/import/video-import-state.enum.ts
@@ -1,4 +1,4 @@
1export enum VideoImportState { 1export const enum VideoImportState {
2 PENDING = 1, 2 PENDING = 1,
3 SUCCESS = 2, 3 SUCCESS = 2,
4 FAILED = 3, 4 FAILED = 3,
diff --git a/shared/models/videos/playlist/video-playlist-element.model.ts b/shared/models/videos/playlist/video-playlist-element.model.ts
index 9a1203892..df9e3b5cf 100644
--- a/shared/models/videos/playlist/video-playlist-element.model.ts
+++ b/shared/models/videos/playlist/video-playlist-element.model.ts
@@ -1,6 +1,6 @@
1import { Video } from '../video.model' 1import { Video } from '../video.model'
2 2
3export enum VideoPlaylistElementType { 3export const enum VideoPlaylistElementType {
4 REGULAR = 0, 4 REGULAR = 0,
5 DELETED = 1, 5 DELETED = 1,
6 PRIVATE = 2, 6 PRIVATE = 2,
diff --git a/shared/models/videos/playlist/video-playlist-privacy.model.ts b/shared/models/videos/playlist/video-playlist-privacy.model.ts
index 96e5e2211..480e1f104 100644
--- a/shared/models/videos/playlist/video-playlist-privacy.model.ts
+++ b/shared/models/videos/playlist/video-playlist-privacy.model.ts
@@ -1,4 +1,4 @@
1export enum VideoPlaylistPrivacy { 1export const enum VideoPlaylistPrivacy {
2 PUBLIC = 1, 2 PUBLIC = 1,
3 UNLISTED = 2, 3 UNLISTED = 2,
4 PRIVATE = 3 4 PRIVATE = 3
diff --git a/shared/models/videos/playlist/video-playlist-type.model.ts b/shared/models/videos/playlist/video-playlist-type.model.ts
index 49233b743..7f51a6354 100644
--- a/shared/models/videos/playlist/video-playlist-type.model.ts
+++ b/shared/models/videos/playlist/video-playlist-type.model.ts
@@ -1,4 +1,4 @@
1export enum VideoPlaylistType { 1export const enum VideoPlaylistType {
2 REGULAR = 1, 2 REGULAR = 1,
3 WATCH_LATER = 2 3 WATCH_LATER = 2
4} 4}
diff --git a/shared/models/videos/thumbnail.type.ts b/shared/models/videos/thumbnail.type.ts
index d6c2bef7b..6907b2802 100644
--- a/shared/models/videos/thumbnail.type.ts
+++ b/shared/models/videos/thumbnail.type.ts
@@ -1,4 +1,4 @@
1export enum ThumbnailType { 1export const enum ThumbnailType {
2 MINIATURE = 1, 2 MINIATURE = 1,
3 PREVIEW = 2 3 PREVIEW = 2
4} 4}
diff --git a/shared/models/videos/video-change-ownership.model.ts b/shared/models/videos/video-change-ownership.model.ts
index a9b1a17f3..669c7f3e7 100644
--- a/shared/models/videos/video-change-ownership.model.ts
+++ b/shared/models/videos/video-change-ownership.model.ts
@@ -10,7 +10,7 @@ export interface VideoChangeOwnership {
10 createdAt: Date 10 createdAt: Date
11} 11}
12 12
13export enum VideoChangeOwnershipStatus { 13export const enum VideoChangeOwnershipStatus {
14 WAITING = 'WAITING', 14 WAITING = 'WAITING',
15 ACCEPTED = 'ACCEPTED', 15 ACCEPTED = 'ACCEPTED',
16 REFUSED = 'REFUSED' 16 REFUSED = 'REFUSED'
diff --git a/shared/models/videos/video-privacy.enum.ts b/shared/models/videos/video-privacy.enum.ts
index 17ed0c9bb..39fd0529f 100644
--- a/shared/models/videos/video-privacy.enum.ts
+++ b/shared/models/videos/video-privacy.enum.ts
@@ -1,4 +1,4 @@
1export enum VideoPrivacy { 1export const enum VideoPrivacy {
2 PUBLIC = 1, 2 PUBLIC = 1,
3 UNLISTED = 2, 3 UNLISTED = 2,
4 PRIVATE = 3, 4 PRIVATE = 3,
diff --git a/shared/models/videos/video-resolution.enum.ts b/shared/models/videos/video-resolution.enum.ts
index 8b5a96cb6..571ab5d8f 100644
--- a/shared/models/videos/video-resolution.enum.ts
+++ b/shared/models/videos/video-resolution.enum.ts
@@ -1,6 +1,6 @@
1import { VideoTranscodingFPS } from './video-transcoding-fps.model' 1import { VideoTranscodingFPS } from './video-transcoding-fps.model'
2 2
3export enum VideoResolution { 3export const enum VideoResolution {
4 H_NOVIDEO = 0, 4 H_NOVIDEO = 0,
5 H_240P = 240, 5 H_240P = 240,
6 H_360P = 360, 6 H_360P = 360,
diff --git a/shared/models/videos/video-state.enum.ts b/shared/models/videos/video-state.enum.ts
index a50e14e4b..31c501932 100644
--- a/shared/models/videos/video-state.enum.ts
+++ b/shared/models/videos/video-state.enum.ts
@@ -1,4 +1,4 @@
1export enum VideoState { 1export const enum VideoState {
2 PUBLISHED = 1, 2 PUBLISHED = 1,
3 TO_TRANSCODE = 2, 3 TO_TRANSCODE = 2,
4 TO_IMPORT = 3 4 TO_IMPORT = 3
diff --git a/shared/models/videos/video-streaming-playlist.type.ts b/shared/models/videos/video-streaming-playlist.type.ts
index 3b403f295..e2e2b93ea 100644
--- a/shared/models/videos/video-streaming-playlist.type.ts
+++ b/shared/models/videos/video-streaming-playlist.type.ts
@@ -1,3 +1,3 @@
1export enum VideoStreamingPlaylistType { 1export const enum VideoStreamingPlaylistType {
2 HLS = 1 2 HLS = 1
3} 3}