aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models
diff options
context:
space:
mode:
Diffstat (limited to 'shared/models')
-rw-r--r--shared/models/feeds/feed-format.enum.ts2
-rw-r--r--shared/models/i18n/i18n.ts105
-rw-r--r--shared/models/i18n/index.ts1
-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
22 files changed, 18 insertions, 174 deletions
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/i18n/i18n.ts b/shared/models/i18n/i18n.ts
deleted file mode 100644
index 9ad0f456d..000000000
--- a/shared/models/i18n/i18n.ts
+++ /dev/null
@@ -1,105 +0,0 @@
1export const LOCALE_FILES = [ 'player', 'server' ]
2
3export const I18N_LOCALES = {
4 // Always first to avoid issues when using express acceptLanguages function when no accept language header is set
5 'en-US': 'English',
6
7 'ar': 'العربية',
8 'ca-ES': 'Català',
9 'cs-CZ': 'Čeština',
10 'de-DE': 'Deutsch',
11 'el-GR': 'ελληνικά',
12 'eo': 'Esperanto',
13 'es-ES': 'Español',
14 'eu-ES': 'Euskara',
15 'fi-FI': 'suomi',
16 'fr-FR': 'Français',
17 'gd': 'Gàidhlig',
18 'hu-HU': 'magyar',
19 'it-IT': 'Italiano',
20 'ja-JP': '日本語',
21 'kab': 'Taqbaylit',
22 'nl-NL': 'Nederlands',
23 'oc': 'Occitan',
24 'pl-PL': 'Polski',
25 'pt-BR': 'Português (Brasil)',
26 'pt-PT': 'Português (Portugal)',
27 'ru-RU': 'русский',
28 'sv-SE': 'svenska',
29 'th-TH': 'ไทย',
30 'vi-VN': 'Tiếng Việt',
31 'zh-Hans-CN': '简体中文(中国)',
32 'zh-Hant-TW': '繁體中文(台灣)'
33}
34
35const I18N_LOCALE_ALIAS = {
36 'ar-001': 'ar',
37 'ca': 'ca-ES',
38 'cs': 'cs-CZ',
39 'de': 'de-DE',
40 'el': 'el-GR',
41 'en': 'en-US',
42 'es': 'es-ES',
43 'eu': 'eu-ES',
44 'fi': 'fi-FI',
45 'fr': 'fr-FR',
46 'hu': 'hu-HU',
47 'it': 'it-IT',
48 'ja': 'ja-JP',
49 'nl': 'nl-NL',
50 'pl': 'pl-PL',
51 'pt': 'pt-BR',
52 'ru': 'ru-RU',
53 'sv': 'sv-SE',
54 'th': 'th-TH',
55 'vi': 'vi-VN',
56 'zh-CN': 'zh-Hans-CN',
57 'zh-Hans': 'zh-Hans-CN',
58 'zh-Hant': 'zh-Hant-TW',
59 'zh-TW': 'zh-Hant-TW',
60 'zh': 'zh-Hans-CN'
61}
62
63export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
64 .concat(Object.keys(I18N_LOCALE_ALIAS))
65
66export function getDefaultLocale () {
67 return 'en-US'
68}
69
70export function isDefaultLocale (locale: string) {
71 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
72}
73
74export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
75 // FIXME: remove disable rule when the client is upgraded to typescript 3.7
76 // eslint-disable-next-line
77 return translations && translations[str] ? translations[str] : str
78}
79
80const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
81export function is18nPath (path: string) {
82 return possiblePaths.includes(path)
83}
84
85export function is18nLocale (locale: string) {
86 return POSSIBLE_LOCALES.includes(locale)
87}
88
89export function getCompleteLocale (locale: string) {
90 if (!locale) return locale
91
92 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
93
94 return locale
95}
96
97export function getShortLocale (locale: string) {
98 if (locale.includes('-') === false) return locale
99
100 return locale.split('-')[0]
101}
102
103export function buildFileLocale (locale: string) {
104 return getCompleteLocale(locale)
105}
diff --git a/shared/models/i18n/index.ts b/shared/models/i18n/index.ts
deleted file mode 100644
index 8f7cbe2c7..000000000
--- a/shared/models/i18n/index.ts
+++ /dev/null
@@ -1 +0,0 @@
1export * from './i18n'
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}