aboutsummaryrefslogtreecommitdiffhomepage
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
parent583eb04b541175035d6d452ca626a96ebf2b7437 (diff)
downloadPeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.tar.gz
PeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.tar.zst
PeerTube-bd45d503e5d007e730f4e81dccd7e7864c9a85cc.zip
Reorganize shared models
-rw-r--r--client/src/app/+admin/plugins/shared/plugin-api.service.ts2
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts5
-rw-r--r--client/src/app/+videos/video-list/overview/overview.service.ts3
-rw-r--r--client/src/app/app.component.ts3
-rw-r--r--client/src/app/app.module.ts2
-rw-r--r--client/src/app/core/auth/auth-user.model.ts4
-rw-r--r--client/src/app/core/plugins/plugin.service.ts4
-rw-r--r--client/src/app/core/server/server.service.ts11
-rw-r--r--client/src/app/core/users/user.model.ts2
-rw-r--r--client/src/app/menu/language-chooser.component.ts2
-rw-r--r--client/src/app/shared/shared-instance/instance.service.ts3
-rw-r--r--client/src/app/shared/shared-main/video-caption/video-caption.service.ts3
-rw-r--r--client/src/app/shared/shared-main/video/video-import.service.ts3
-rw-r--r--client/src/app/shared/shared-main/video/video.model.ts2
-rw-r--r--client/src/app/shared/shared-moderation/report-modals/account-report.component.ts3
-rw-r--r--client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts3
-rw-r--r--client/src/app/shared/shared-moderation/report-modals/video-report.component.ts3
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist.model.ts2
-rw-r--r--client/src/assets/player/peertube-player-manager.ts3
-rw-r--r--client/src/assets/player/translations-manager.ts2
-rw-r--r--client/src/standalone/videos/embed.ts2
-rw-r--r--client/webpack/webpack.video-embed.js1
-rw-r--r--server/controllers/api/abuse.ts7
-rw-r--r--server/controllers/client.ts10
-rw-r--r--server/controllers/plugins.ts2
-rw-r--r--server/helpers/custom-validators/abuses.ts3
-rw-r--r--server/helpers/custom-validators/plugins.ts3
-rw-r--r--server/helpers/custom-validators/video-blacklist.ts3
-rw-r--r--server/lib/activitypub/process/process-flag.ts3
-rw-r--r--server/lib/client-html.ts2
-rw-r--r--server/middlewares/user-right.ts2
-rw-r--r--server/models/abuse/abuse.ts8
-rw-r--r--server/models/account/user.ts45
-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
59 files changed, 152 insertions, 141 deletions
diff --git a/client/src/app/+admin/plugins/shared/plugin-api.service.ts b/client/src/app/+admin/plugins/shared/plugin-api.service.ts
index bf9129e01..1fb827832 100644
--- a/client/src/app/+admin/plugins/shared/plugin-api.service.ts
+++ b/client/src/app/+admin/plugins/shared/plugin-api.service.ts
@@ -5,12 +5,12 @@ import { Injectable } from '@angular/core'
5import { ComponentPagination, RestExtractor, RestService } from '@app/core' 5import { ComponentPagination, RestExtractor, RestService } from '@app/core'
6import { PluginService } from '@app/core/plugins/plugin.service' 6import { PluginService } from '@app/core/plugins/plugin.service'
7import { I18n } from '@ngx-translate/i18n-polyfill' 7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { peertubeTranslate } from '@shared/core-utils/i18n'
8import { 9import {
9 InstallOrUpdatePlugin, 10 InstallOrUpdatePlugin,
10 ManagePlugin, 11 ManagePlugin,
11 PeerTubePlugin, 12 PeerTubePlugin,
12 PeerTubePluginIndex, 13 PeerTubePluginIndex,
13 peertubeTranslate,
14 PluginType, 14 PluginType,
15 RegisteredServerSettings, 15 RegisteredServerSettings,
16 ResultList 16 ResultList
diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts
index 22ec42520..bdbb10814 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/users/user-edit/user-edit.ts
@@ -1,8 +1,9 @@
1import { OnInit, Directive } from '@angular/core' 1import { Directive, OnInit } from '@angular/core'
2import { ConfigService } from '@app/+admin/config/shared/config.service' 2import { ConfigService } from '@app/+admin/config/shared/config.service'
3import { AuthService, ScreenService, ServerService, User } from '@app/core' 3import { AuthService, ScreenService, ServerService, User } from '@app/core'
4import { FormReactive } from '@app/shared/shared-forms' 4import { FormReactive } from '@app/shared/shared-forms'
5import { ServerConfig, USER_ROLE_LABELS, UserAdminFlag, UserRole, VideoResolution } from '@shared/models' 5import { USER_ROLE_LABELS } from '@shared/core-utils/users'
6import { ServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models'
6 7
7@Directive() 8@Directive()
8export abstract class UserEdit extends FormReactive implements OnInit { 9export abstract class UserEdit extends FormReactive implements OnInit {
diff --git a/client/src/app/+videos/video-list/overview/overview.service.ts b/client/src/app/+videos/video-list/overview/overview.service.ts
index 4458454d5..3aa64ebc8 100644
--- a/client/src/app/+videos/video-list/overview/overview.service.ts
+++ b/client/src/app/+videos/video-list/overview/overview.service.ts
@@ -5,7 +5,8 @@ import { Injectable } from '@angular/core'
5import { RestExtractor, ServerService } from '@app/core' 5import { RestExtractor, ServerService } from '@app/core'
6import { immutableAssign } from '@app/helpers' 6import { immutableAssign } from '@app/helpers'
7import { VideoService } from '@app/shared/shared-main' 7import { VideoService } from '@app/shared/shared-main'
8import { peertubeTranslate, VideosOverview as VideosOverviewServer } from '@shared/models' 8import { peertubeTranslate } from '@shared/core-utils/i18n'
9import { VideosOverview as VideosOverviewServer } from '@shared/models'
9import { environment } from '../../../../environments/environment' 10import { environment } from '../../../../environments/environment'
10import { VideosOverview } from './videos-overview.model' 11import { VideosOverview } from './videos-overview.model'
11 12
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index dee7fd056..ff0e28aa5 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -13,7 +13,8 @@ import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config-
13import { WelcomeModalComponent } from '@app/modal/welcome-modal.component' 13import { WelcomeModalComponent } from '@app/modal/welcome-modal.component'
14import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 14import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
15import { I18n } from '@ngx-translate/i18n-polyfill' 15import { I18n } from '@ngx-translate/i18n-polyfill'
16import { BroadcastMessageLevel, getShortLocale, is18nPath, ServerConfig, UserRole } from '@shared/models' 16import { getShortLocale, is18nPath } from '@shared/core-utils/i18n'
17import { BroadcastMessageLevel, ServerConfig, UserRole } from '@shared/models'
17import { MenuService } from './core/menu/menu.service' 18import { MenuService } from './core/menu/menu.service'
18import { POP_STATE_MODAL_DISMISS } from './helpers' 19import { POP_STATE_MODAL_DISMISS } from './helpers'
19import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 20import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index 9698de275..b35cc1716 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -5,7 +5,7 @@ import { BrowserModule } from '@angular/platform-browser'
5import { ServerService } from '@app/core' 5import { ServerService } from '@app/core'
6import localeOc from '@app/helpers/locales/oc' 6import localeOc from '@app/helpers/locales/oc'
7import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' 7import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
8import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/models' 8import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/core-utils/i18n'
9import { AppRoutingModule } from './app-routing.module' 9import { AppRoutingModule } from './app-routing.module'
10import { AppComponent } from './app.component' 10import { AppComponent } from './app.component'
11import { CoreModule } from './core' 11import { CoreModule } from './core'
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts
index ee61ff881..5efc6e1ab 100644
--- a/client/src/app/core/auth/auth-user.model.ts
+++ b/client/src/app/core/auth/auth-user.model.ts
@@ -1,9 +1,9 @@
1import { Observable, of } from 'rxjs' 1import { Observable, of } from 'rxjs'
2import { map } from 'rxjs/operators' 2import { map } from 'rxjs/operators'
3import { User } from '@app/core/users/user.model' 3import { User } from '@app/core/users/user.model'
4import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 4import { peertubeLocalStorage } from '@app/helpers/peertube-web-storage'
5import { hasUserRight } from '@shared/core-utils/users'
5import { 6import {
6 hasUserRight,
7 MyUser as ServerMyUserModel, 7 MyUser as ServerMyUserModel,
8 MyUserSpecialPlaylist, 8 MyUserSpecialPlaylist,
9 NSFWPolicyType, 9 NSFWPolicyType,
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts
index 3cab64142..dc115c0e1 100644
--- a/client/src/app/core/plugins/plugin.service.ts
+++ b/client/src/app/core/plugins/plugin.service.ts
@@ -9,15 +9,13 @@ import { RestExtractor } from '@app/core/rest'
9import { ServerService } from '@app/core/server/server.service' 9import { ServerService } from '@app/core/server/server.service'
10import { getDevLocale, importModule, isOnDevLocale } from '@app/helpers' 10import { getDevLocale, importModule, isOnDevLocale } from '@app/helpers'
11import { CustomModalComponent } from '@app/modal/custom-modal.component' 11import { CustomModalComponent } from '@app/modal/custom-modal.component'
12import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n'
12import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks' 13import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks'
13import { 14import {
14 ClientHook, 15 ClientHook,
15 ClientHookName, 16 ClientHookName,
16 clientHookObject, 17 clientHookObject,
17 ClientScript, 18 ClientScript,
18 getCompleteLocale,
19 isDefaultLocale,
20 peertubeTranslate,
21 PluginClientScope, 19 PluginClientScope,
22 PluginTranslation, 20 PluginTranslation,
23 PluginType, 21 PluginType,
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index c69e0919a..5bcf33c1b 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -4,15 +4,8 @@ import { HttpClient } from '@angular/common/http'
4import { Inject, Injectable, LOCALE_ID } from '@angular/core' 4import { Inject, Injectable, LOCALE_ID } from '@angular/core'
5import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' 5import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers'
6import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 6import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
7import { 7import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n'
8 getCompleteLocale, 8import { SearchTargetType, ServerConfig, ServerStats, VideoConstant } from '@shared/models'
9 isDefaultLocale,
10 peertubeTranslate,
11 SearchTargetType,
12 ServerConfig,
13 ServerStats,
14 VideoConstant
15} from '@shared/models'
16import { environment } from '../../../environments/environment' 9import { environment } from '../../../environments/environment'
17 10
18@Injectable() 11@Injectable()
diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts
index a94b35c46..f0d3a08b8 100644
--- a/client/src/app/core/users/user.model.ts
+++ b/client/src/app/core/users/user.model.ts
@@ -1,7 +1,7 @@
1import { Account } from '@app/shared/shared-main/account/account.model' 1import { Account } from '@app/shared/shared-main/account/account.model'
2import { hasUserRight } from '@shared/core-utils/users'
2import { 3import {
3 Avatar, 4 Avatar,
4 hasUserRight,
5 NSFWPolicyType, 5 NSFWPolicyType,
6 User as UserServerModel, 6 User as UserServerModel,
7 UserAdminFlag, 7 UserAdminFlag,
diff --git a/client/src/app/menu/language-chooser.component.ts b/client/src/app/menu/language-chooser.component.ts
index 3e89f72b8..e15aeff20 100644
--- a/client/src/app/menu/language-chooser.component.ts
+++ b/client/src/app/menu/language-chooser.component.ts
@@ -1,7 +1,7 @@
1import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' 1import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core'
2import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' 2import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers'
3import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 3import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
4import { getCompleteLocale, getShortLocale, I18N_LOCALES } from '@shared/models' 4import { getCompleteLocale, getShortLocale, I18N_LOCALES } from '@shared/core-utils/i18n'
5 5
6@Component({ 6@Component({
7 selector: 'my-language-chooser', 7 selector: 'my-language-chooser',
diff --git a/client/src/app/shared/shared-instance/instance.service.ts b/client/src/app/shared/shared-instance/instance.service.ts
index ba9797bb5..fcfa59f28 100644
--- a/client/src/app/shared/shared-instance/instance.service.ts
+++ b/client/src/app/shared/shared-instance/instance.service.ts
@@ -3,7 +3,8 @@ import { catchError, map } from 'rxjs/operators'
3import { HttpClient } from '@angular/common/http' 3import { HttpClient } from '@angular/common/http'
4import { Injectable } from '@angular/core' 4import { Injectable } from '@angular/core'
5import { MarkdownService, RestExtractor, ServerService } from '@app/core' 5import { MarkdownService, RestExtractor, ServerService } from '@app/core'
6import { About, peertubeTranslate } from '@shared/models' 6import { peertubeTranslate } from '@shared/core-utils/i18n'
7import { About } from '@shared/models'
7import { environment } from '../../../environments/environment' 8import { environment } from '../../../environments/environment'
8 9
9@Injectable() 10@Injectable()
diff --git a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
index d45fb837a..283c63f98 100644
--- a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
+++ b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
@@ -5,7 +5,8 @@ import { Injectable } from '@angular/core'
5import { RestExtractor, ServerService } from '@app/core' 5import { RestExtractor, ServerService } from '@app/core'
6import { objectToFormData, sortBy } from '@app/helpers' 6import { objectToFormData, sortBy } from '@app/helpers'
7import { VideoService } from '@app/shared/shared-main/video' 7import { VideoService } from '@app/shared/shared-main/video'
8import { peertubeTranslate, ResultList, VideoCaption } from '@shared/models' 8import { peertubeTranslate } from '@shared/core-utils/i18n'
9import { ResultList, VideoCaption } from '@shared/models'
9import { VideoCaptionEdit } from './video-caption-edit.model' 10import { VideoCaptionEdit } from './video-caption-edit.model'
10 11
11@Injectable() 12@Injectable()
diff --git a/client/src/app/shared/shared-main/video/video-import.service.ts b/client/src/app/shared/shared-main/video/video-import.service.ts
index a700abacb..99df78e3a 100644
--- a/client/src/app/shared/shared-main/video/video-import.service.ts
+++ b/client/src/app/shared/shared-main/video/video-import.service.ts
@@ -5,7 +5,8 @@ import { HttpClient, HttpParams } from '@angular/common/http'
5import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
6import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core' 6import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core'
7import { objectToFormData } from '@app/helpers' 7import { objectToFormData } from '@app/helpers'
8import { peertubeTranslate, ResultList, VideoImport, VideoImportCreate, VideoUpdate } from '@shared/models' 8import { peertubeTranslate } from '@shared/core-utils/i18n'
9import { ResultList, VideoImport, VideoImportCreate, VideoUpdate } from '@shared/models'
9import { environment } from '../../../../environments/environment' 10import { environment } from '../../../../environments/environment'
10 11
11@Injectable() 12@Injectable()
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 147d0817e..73f0198e2 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -1,9 +1,9 @@
1import { AuthUser } from '@app/core' 1import { AuthUser } from '@app/core'
2import { User } from '@app/core/users/user.model' 2import { User } from '@app/core/users/user.model'
3import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' 3import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
4import { peertubeTranslate } from '@shared/core-utils/i18n'
4import { 5import {
5 Avatar, 6 Avatar,
6 peertubeTranslate,
7 ServerConfig, 7 ServerConfig,
8 UserRight, 8 UserRight,
9 Video as VideoServerModel, 9 Video as VideoServerModel,
diff --git a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
index 78ca934c7..08dbe9538 100644
--- a/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
+++ b/client/src/app/shared/shared-moderation/report-modals/account-report.component.ts
@@ -6,7 +6,8 @@ import { Account } from '@app/shared/shared-main'
6import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 6import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
7import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 7import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
8import { I18n } from '@ngx-translate/i18n-polyfill' 8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' 9import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
10import { AbusePredefinedReasonsString } from '@shared/models'
10import { AbuseService } from '../abuse.service' 11import { AbuseService } from '../abuse.service'
11 12
12@Component({ 13@Component({
diff --git a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
index 00d7b8d34..2769874d9 100644
--- a/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
+++ b/client/src/app/shared/shared-moderation/report-modals/comment-report.component.ts
@@ -6,7 +6,8 @@ import { VideoComment } from '@app/shared/shared-video-comment'
6import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 6import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
7import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 7import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
8import { I18n } from '@ngx-translate/i18n-polyfill' 8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' 9import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
10import { AbusePredefinedReasonsString } from '@shared/models'
10import { AbuseService } from '../abuse.service' 11import { AbuseService } from '../abuse.service'
11 12
12@Component({ 13@Component({
diff --git a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
index 7d53ea3c9..09ab98dfe 100644
--- a/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
+++ b/client/src/app/shared/shared-moderation/report-modals/video-report.component.ts
@@ -7,7 +7,8 @@ import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app
7import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 7import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
8import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' 8import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
9import { I18n } from '@ngx-translate/i18n-polyfill' 9import { I18n } from '@ngx-translate/i18n-polyfill'
10import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' 10import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
11import { AbusePredefinedReasonsString } from '@shared/models'
11import { Video } from '../../shared-main' 12import { Video } from '../../shared-main'
12import { AbuseService } from '../abuse.service' 13import { AbuseService } from '../abuse.service'
13 14
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
index 8f63d2abd..7de379cdf 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
@@ -1,8 +1,8 @@
1import { getAbsoluteAPIUrl } from '@app/helpers' 1import { getAbsoluteAPIUrl } from '@app/helpers'
2import { Actor } from '@app/shared/shared-main' 2import { Actor } from '@app/shared/shared-main'
3import { peertubeTranslate } from '@shared/core-utils/i18n'
3import { 4import {
4 AccountSummary, 5 AccountSummary,
5 peertubeTranslate,
6 VideoChannelSummary, 6 VideoChannelSummary,
7 VideoConstant, 7 VideoConstant,
8 VideoPlaylist as ServerVideoPlaylist, 8 VideoPlaylist as ServerVideoPlaylist,
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index e9597dde1..6a6d63462 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -19,7 +19,8 @@ import './videojs-components/settings-panel'
19import './videojs-components/settings-panel-child' 19import './videojs-components/settings-panel-child'
20import './videojs-components/theater-button' 20import './videojs-components/theater-button'
21import videojs from 'video.js' 21import videojs from 'video.js'
22import { isDefaultLocale, VideoFile } from '@shared/models' 22import { VideoFile } from '@shared/models'
23import { isDefaultLocale } from '@shared/core-utils/i18n'
23import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' 24import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
24import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder' 25import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder'
25import { segmentValidatorFactory } from './p2p-media-loader/segment-validator' 26import { segmentValidatorFactory } from './p2p-media-loader/segment-validator'
diff --git a/client/src/assets/player/translations-manager.ts b/client/src/assets/player/translations-manager.ts
index 2bde7d6ca..631e3feba 100644
--- a/client/src/assets/player/translations-manager.ts
+++ b/client/src/assets/player/translations-manager.ts
@@ -1,4 +1,4 @@
1import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '@shared/models' 1import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '@shared/core-utils/i18n'
2 2
3export class TranslationsManager { 3export class TranslationsManager {
4 private static videojsLocaleCache: { [ path: string ]: any } = {} 4 private static videojsLocaleCache: { [ path: string ]: any } = {}
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index def607916..89903aa35 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -1,8 +1,8 @@
1import './embed.scss' 1import './embed.scss'
2import videojs from 'video.js' 2import videojs from 'video.js'
3import { objectToUrlEncoded, peertubeLocalStorage, PureAuthUser } from '@root-helpers/index' 3import { objectToUrlEncoded, peertubeLocalStorage, PureAuthUser } from '@root-helpers/index'
4import { peertubeTranslate } from '../../../../shared/core-utils/i18n'
4import { 5import {
5 peertubeTranslate,
6 ResultList, 6 ResultList,
7 ServerConfig, 7 ServerConfig,
8 UserRefreshToken, 8 UserRefreshToken,
diff --git a/client/webpack/webpack.video-embed.js b/client/webpack/webpack.video-embed.js
index 83622a974..aa7c5e550 100644
--- a/client/webpack/webpack.video-embed.js
+++ b/client/webpack/webpack.video-embed.js
@@ -29,6 +29,7 @@ module.exports = function () {
29 'video.js$': path.resolve('node_modules/video.js/core.js'), 29 'video.js$': path.resolve('node_modules/video.js/core.js'),
30 '@root-helpers': path.resolve('src/root-helpers'), 30 '@root-helpers': path.resolve('src/root-helpers'),
31 '@shared/models': path.resolve('../shared/models'), 31 '@shared/models': path.resolve('../shared/models'),
32 '@shared/core-utils': path.resolve('../shared/core-utils')
32 } 33 }
33 }, 34 },
34 35
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts
index 03e6be8c8..b97b99f16 100644
--- a/server/controllers/api/abuse.ts
+++ b/server/controllers/api/abuse.ts
@@ -1,9 +1,12 @@
1import * as express from 'express' 1import * as express from 'express'
2import { logger } from '@server/helpers/logger'
2import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation' 3import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation'
4import { Notifier } from '@server/lib/notifier'
3import { AbuseModel } from '@server/models/abuse/abuse' 5import { AbuseModel } from '@server/models/abuse/abuse'
4import { AbuseMessageModel } from '@server/models/abuse/abuse-message' 6import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
5import { getServerActor } from '@server/models/application/application' 7import { getServerActor } from '@server/models/application/application'
6import { AbuseCreate, abusePredefinedReasonsMap, AbuseState, UserRight } from '../../../shared' 8import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
9import { AbuseCreate, AbuseState, UserRight } from '../../../shared'
7import { getFormattedObjects } from '../../helpers/utils' 10import { getFormattedObjects } from '../../helpers/utils'
8import { sequelizeTypescript } from '../../initializers/database' 11import { sequelizeTypescript } from '../../initializers/database'
9import { 12import {
@@ -25,8 +28,6 @@ import {
25 setDefaultSort 28 setDefaultSort
26} from '../../middlewares' 29} from '../../middlewares'
27import { AccountModel } from '../../models/account/account' 30import { AccountModel } from '../../models/account/account'
28import { Notifier } from '@server/lib/notifier'
29import { logger } from '@server/helpers/logger'
30 31
31const abuseRouter = express.Router() 32const abuseRouter = express.Router()
32 33
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index 8c7f881a9..7c80820f4 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -1,13 +1,13 @@
1import { constants, promises as fs } from 'fs'
2import * as express from 'express' 1import * as express from 'express'
2import { constants, promises as fs } from 'fs'
3import { join } from 'path' 3import { join } from 'path'
4import { CONFIG } from '@server/initializers/config'
5import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n'
4import { root } from '../helpers/core-utils' 6import { root } from '../helpers/core-utils'
7import { logger } from '../helpers/logger'
5import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' 8import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants'
6import { asyncMiddleware, embedCSP } from '../middlewares'
7import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n'
8import { ClientHtml } from '../lib/client-html' 9import { ClientHtml } from '../lib/client-html'
9import { logger } from '../helpers/logger' 10import { asyncMiddleware, embedCSP } from '../middlewares'
10import { CONFIG } from '@server/initializers/config'
11 11
12const clientsRouter = express.Router() 12const clientsRouter = express.Router()
13 13
diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts
index f88a1632d..7b947bb6e 100644
--- a/server/controllers/plugins.ts
+++ b/server/controllers/plugins.ts
@@ -6,7 +6,7 @@ import { getPluginValidator, pluginStaticDirectoryValidator, getExternalAuthVali
6import { serveThemeCSSValidator } from '../middlewares/validators/themes' 6import { serveThemeCSSValidator } from '../middlewares/validators/themes'
7import { PluginType } from '../../shared/models/plugins/plugin.type' 7import { PluginType } from '../../shared/models/plugins/plugin.type'
8import { isTestInstance } from '../helpers/core-utils' 8import { isTestInstance } from '../helpers/core-utils'
9import { getCompleteLocale, is18nLocale } from '../../shared/models/i18n' 9import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n'
10import { logger } from '@server/helpers/logger' 10import { logger } from '@server/helpers/logger'
11 11
12const sendFileOptions = { 12const sendFileOptions = {
diff --git a/server/helpers/custom-validators/abuses.ts b/server/helpers/custom-validators/abuses.ts
index 0ddde4b06..94719641a 100644
--- a/server/helpers/custom-validators/abuses.ts
+++ b/server/helpers/custom-validators/abuses.ts
@@ -1,5 +1,6 @@
1import validator from 'validator' 1import validator from 'validator'
2import { AbuseFilter, abusePredefinedReasonsMap, AbusePredefinedReasonsString, AbuseVideoIs, AbuseCreate } from '@shared/models' 2import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
3import { AbuseCreate, AbuseFilter, AbusePredefinedReasonsString, AbuseVideoIs } from '@shared/models'
3import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' 4import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants'
4import { exists, isArray } from './misc' 5import { exists, isArray } from './misc'
5 6
diff --git a/server/helpers/custom-validators/plugins.ts b/server/helpers/custom-validators/plugins.ts
index d2fc03936..f2d4efb32 100644
--- a/server/helpers/custom-validators/plugins.ts
+++ b/server/helpers/custom-validators/plugins.ts
@@ -8,7 +8,8 @@ import { isUrlValid } from './activitypub/misc'
8const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS 8const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS
9 9
10function isPluginTypeValid (value: any) { 10function isPluginTypeValid (value: any) {
11 return exists(value) && validator.isInt('' + value) && PluginType[value] !== undefined 11 return exists(value) &&
12 (value === PluginType.PLUGIN || value === PluginType.THEME)
12} 13}
13 14
14function isPluginNameValid (value: string) { 15function isPluginNameValid (value: string) {
diff --git a/server/helpers/custom-validators/video-blacklist.ts b/server/helpers/custom-validators/video-blacklist.ts
index 17cb3b00b..34fcec38e 100644
--- a/server/helpers/custom-validators/video-blacklist.ts
+++ b/server/helpers/custom-validators/video-blacklist.ts
@@ -10,7 +10,8 @@ function isVideoBlacklistReasonValid (value: string) {
10} 10}
11 11
12function isVideoBlacklistTypeValid (value: any) { 12function isVideoBlacklistTypeValid (value: any) {
13 return exists(value) && validator.isInt('' + value) && VideoBlacklistType[value] !== undefined 13 return exists(value) &&
14 (value === VideoBlacklistType.AUTO_BEFORE_PUBLISHED || value === VideoBlacklistType.MANUAL)
14} 15}
15 16
16// --------------------------------------------------------------------------- 17// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/process/process-flag.ts b/server/lib/activitypub/process/process-flag.ts
index 6350cee12..40d07558c 100644
--- a/server/lib/activitypub/process/process-flag.ts
+++ b/server/lib/activitypub/process/process-flag.ts
@@ -2,7 +2,8 @@ import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@
2import { AccountModel } from '@server/models/account/account' 2import { AccountModel } from '@server/models/account/account'
3import { VideoModel } from '@server/models/video/video' 3import { VideoModel } from '@server/models/video/video'
4import { VideoCommentModel } from '@server/models/video/video-comment' 4import { VideoCommentModel } from '@server/models/video/video-comment'
5import { AbuseObject, abusePredefinedReasonsMap, AbuseState, ActivityCreate, ActivityFlag } from '../../../../shared' 5import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
6import { AbuseObject, AbuseState, ActivityCreate, ActivityFlag } from '../../../../shared'
6import { getAPId } from '../../../helpers/activitypub' 7import { getAPId } from '../../../helpers/activitypub'
7import { retryTransactionWrapper } from '../../../helpers/database-utils' 8import { retryTransactionWrapper } from '../../../helpers/database-utils'
8import { logger } from '../../../helpers/logger' 9import { logger } from '../../../helpers/logger'
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index ffe53d0d5..d8ae73b5d 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' 2import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n'
3import { 3import {
4 AVATARS_SIZE, 4 AVATARS_SIZE,
5 CUSTOM_HTML_TAG_COMMENTS, 5 CUSTOM_HTML_TAG_COMMENTS,
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts
index 4d836485c..aaf0b323a 100644
--- a/server/middlewares/user-right.ts
+++ b/server/middlewares/user-right.ts
@@ -6,7 +6,7 @@ function ensureUserHasRight (userRight: UserRight) {
6 return function (req: express.Request, res: express.Response, next: express.NextFunction) { 6 return function (req: express.Request, res: express.Response, next: express.NextFunction) {
7 const user = res.locals.oauth.token.user 7 const user = res.locals.oauth.token.user
8 if (user.hasRight(userRight) === false) { 8 if (user.hasRight(userRight) === false) {
9 const message = `User ${user.username} does not have right ${UserRight[userRight]} to access to ${req.path}.` 9 const message = `User ${user.username} does not have right ${userRight} to access to ${req.path}.`
10 logger.info(message) 10 logger.info(message)
11 11
12 return res.status(403).json({ error: message }) 12 return res.status(403).json({ error: message })
diff --git a/server/models/abuse/abuse.ts b/server/models/abuse/abuse.ts
index 1b599db62..2a407c3d2 100644
--- a/server/models/abuse/abuse.ts
+++ b/server/models/abuse/abuse.ts
@@ -17,11 +17,11 @@ import {
17 UpdatedAt 17 UpdatedAt
18} from 'sequelize-typescript' 18} from 'sequelize-typescript'
19import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses' 19import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses'
20import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
20import { 21import {
21 AbuseFilter, 22 AbuseFilter,
22 AbuseObject, 23 AbuseObject,
23 AbusePredefinedReasons, 24 AbusePredefinedReasons,
24 abusePredefinedReasonsMap,
25 AbusePredefinedReasonsString, 25 AbusePredefinedReasonsString,
26 AbuseState, 26 AbuseState,
27 AbuseVideoIs, 27 AbuseVideoIs,
@@ -646,8 +646,10 @@ export class AbuseModel extends Model<AbuseModel> {
646 } 646 }
647 647
648 private static getPredefinedReasonsStrings (predefinedReasons: AbusePredefinedReasons[]): AbusePredefinedReasonsString[] { 648 private static getPredefinedReasonsStrings (predefinedReasons: AbusePredefinedReasons[]): AbusePredefinedReasonsString[] {
649 const invertedPredefinedReasons = invert(abusePredefinedReasonsMap)
650
649 return (predefinedReasons || []) 651 return (predefinedReasons || [])
650 .filter(r => r in AbusePredefinedReasons) 652 .map(r => invertedPredefinedReasons[r] as AbusePredefinedReasonsString)
651 .map(r => invert(abusePredefinedReasonsMap)[r] as AbusePredefinedReasonsString) 653 .filter(v => !!v)
652 } 654 }
653} 655}
diff --git a/server/models/account/user.ts b/server/models/account/user.ts
index 5f45f8e7c..22e6715b4 100644
--- a/server/models/account/user.ts
+++ b/server/models/account/user.ts
@@ -1,3 +1,5 @@
1import * as Bluebird from 'bluebird'
2import { values } from 'lodash'
1import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize' 3import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize'
2import { 4import {
3 AfterDestroy, 5 AfterDestroy,
@@ -19,8 +21,21 @@ import {
19 Table, 21 Table,
20 UpdatedAt 22 UpdatedAt
21} from 'sequelize-typescript' 23} from 'sequelize-typescript'
22import { hasUserRight, MyUser, USER_ROLE_LABELS, UserRight, AbuseState, VideoPlaylistType, VideoPrivacy } from '../../../shared' 24import {
25 MMyUserFormattable,
26 MUserDefault,
27 MUserFormattable,
28 MUserId,
29 MUserNotifSettingChannelDefault,
30 MUserWithNotificationSetting,
31 MVideoFullLight
32} from '@server/types/models'
33import { hasUserRight, USER_ROLE_LABELS } from '../../../shared/core-utils/users'
34import { AbuseState, MyUser, UserRight, VideoPlaylistType, VideoPrivacy } from '../../../shared/models'
23import { User, UserRole } from '../../../shared/models/users' 35import { User, UserRole } from '../../../shared/models/users'
36import { UserAdminFlag } from '../../../shared/models/users/user-flag.model'
37import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
38import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
24import { 39import {
25 isNoInstanceConfigWarningModal, 40 isNoInstanceConfigWarningModal,
26 isNoWelcomeModal, 41 isNoWelcomeModal,
@@ -42,33 +57,19 @@ import {
42 isUserWebTorrentEnabledValid 57 isUserWebTorrentEnabledValid
43} from '../../helpers/custom-validators/users' 58} from '../../helpers/custom-validators/users'
44import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' 59import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto'
60import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants'
61import { clearCacheByUserId } from '../../lib/oauth-model'
62import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
63import { ActorModel } from '../activitypub/actor'
64import { ActorFollowModel } from '../activitypub/actor-follow'
45import { OAuthTokenModel } from '../oauth/oauth-token' 65import { OAuthTokenModel } from '../oauth/oauth-token'
46import { getSort, throwIfNotValid } from '../utils' 66import { getSort, throwIfNotValid } from '../utils'
67import { VideoModel } from '../video/video'
47import { VideoChannelModel } from '../video/video-channel' 68import { VideoChannelModel } from '../video/video-channel'
69import { VideoImportModel } from '../video/video-import'
48import { VideoPlaylistModel } from '../video/video-playlist' 70import { VideoPlaylistModel } from '../video/video-playlist'
49import { AccountModel } from './account' 71import { AccountModel } from './account'
50import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type'
51import { values } from 'lodash'
52import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants'
53import { clearCacheByUserId } from '../../lib/oauth-model'
54import { UserNotificationSettingModel } from './user-notification-setting' 72import { UserNotificationSettingModel } from './user-notification-setting'
55import { VideoModel } from '../video/video'
56import { ActorModel } from '../activitypub/actor'
57import { ActorFollowModel } from '../activitypub/actor-follow'
58import { VideoImportModel } from '../video/video-import'
59import { UserAdminFlag } from '../../../shared/models/users/user-flag.model'
60import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
61import { getThemeOrDefault } from '../../lib/plugins/theme-utils'
62import * as Bluebird from 'bluebird'
63import {
64 MMyUserFormattable,
65 MUserDefault,
66 MUserFormattable,
67 MUserId,
68 MUserNotifSettingChannelDefault,
69 MUserWithNotificationSetting,
70 MVideoFullLight
71} from '@server/types/models'
72 73
73enum ScopeNames { 74enum ScopeNames {
74 FOR_ME_API = 'FOR_ME_API', 75 FOR_ME_API = 'FOR_ME_API',
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}