diff options
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' | |||
5 | import { ComponentPagination, RestExtractor, RestService } from '@app/core' | 5 | import { ComponentPagination, RestExtractor, RestService } from '@app/core' |
6 | import { PluginService } from '@app/core/plugins/plugin.service' | 6 | import { PluginService } from '@app/core/plugins/plugin.service' |
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | 7 | import { I18n } from '@ngx-translate/i18n-polyfill' |
8 | import { peertubeTranslate } from '@shared/core-utils/i18n' | ||
8 | import { | 9 | import { |
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 @@ | |||
1 | import { OnInit, Directive } from '@angular/core' | 1 | import { Directive, OnInit } from '@angular/core' |
2 | import { ConfigService } from '@app/+admin/config/shared/config.service' | 2 | import { ConfigService } from '@app/+admin/config/shared/config.service' |
3 | import { AuthService, ScreenService, ServerService, User } from '@app/core' | 3 | import { AuthService, ScreenService, ServerService, User } from '@app/core' |
4 | import { FormReactive } from '@app/shared/shared-forms' | 4 | import { FormReactive } from '@app/shared/shared-forms' |
5 | import { ServerConfig, USER_ROLE_LABELS, UserAdminFlag, UserRole, VideoResolution } from '@shared/models' | 5 | import { USER_ROLE_LABELS } from '@shared/core-utils/users' |
6 | import { ServerConfig, UserAdminFlag, UserRole, VideoResolution } from '@shared/models' | ||
6 | 7 | ||
7 | @Directive() | 8 | @Directive() |
8 | export abstract class UserEdit extends FormReactive implements OnInit { | 9 | export 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' | |||
5 | import { RestExtractor, ServerService } from '@app/core' | 5 | import { RestExtractor, ServerService } from '@app/core' |
6 | import { immutableAssign } from '@app/helpers' | 6 | import { immutableAssign } from '@app/helpers' |
7 | import { VideoService } from '@app/shared/shared-main' | 7 | import { VideoService } from '@app/shared/shared-main' |
8 | import { peertubeTranslate, VideosOverview as VideosOverviewServer } from '@shared/models' | 8 | import { peertubeTranslate } from '@shared/core-utils/i18n' |
9 | import { VideosOverview as VideosOverviewServer } from '@shared/models' | ||
9 | import { environment } from '../../../../environments/environment' | 10 | import { environment } from '../../../../environments/environment' |
10 | import { VideosOverview } from './videos-overview.model' | 11 | import { 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- | |||
13 | import { WelcomeModalComponent } from '@app/modal/welcome-modal.component' | 13 | import { WelcomeModalComponent } from '@app/modal/welcome-modal.component' |
14 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 14 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
15 | import { I18n } from '@ngx-translate/i18n-polyfill' | 15 | import { I18n } from '@ngx-translate/i18n-polyfill' |
16 | import { BroadcastMessageLevel, getShortLocale, is18nPath, ServerConfig, UserRole } from '@shared/models' | 16 | import { getShortLocale, is18nPath } from '@shared/core-utils/i18n' |
17 | import { BroadcastMessageLevel, ServerConfig, UserRole } from '@shared/models' | ||
17 | import { MenuService } from './core/menu/menu.service' | 18 | import { MenuService } from './core/menu/menu.service' |
18 | import { POP_STATE_MODAL_DISMISS } from './helpers' | 19 | import { POP_STATE_MODAL_DISMISS } from './helpers' |
19 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 20 | import { 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' | |||
5 | import { ServerService } from '@app/core' | 5 | import { ServerService } from '@app/core' |
6 | import localeOc from '@app/helpers/locales/oc' | 6 | import localeOc from '@app/helpers/locales/oc' |
7 | import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' | 7 | import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' |
8 | import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/models' | 8 | import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/core-utils/i18n' |
9 | import { AppRoutingModule } from './app-routing.module' | 9 | import { AppRoutingModule } from './app-routing.module' |
10 | import { AppComponent } from './app.component' | 10 | import { AppComponent } from './app.component' |
11 | import { CoreModule } from './core' | 11 | import { 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 @@ | |||
1 | import { Observable, of } from 'rxjs' | 1 | import { Observable, of } from 'rxjs' |
2 | import { map } from 'rxjs/operators' | 2 | import { map } from 'rxjs/operators' |
3 | import { User } from '@app/core/users/user.model' | 3 | import { User } from '@app/core/users/user.model' |
4 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 4 | import { peertubeLocalStorage } from '@app/helpers/peertube-web-storage' |
5 | import { hasUserRight } from '@shared/core-utils/users' | ||
5 | import { | 6 | import { |
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' | |||
9 | import { ServerService } from '@app/core/server/server.service' | 9 | import { ServerService } from '@app/core/server/server.service' |
10 | import { getDevLocale, importModule, isOnDevLocale } from '@app/helpers' | 10 | import { getDevLocale, importModule, isOnDevLocale } from '@app/helpers' |
11 | import { CustomModalComponent } from '@app/modal/custom-modal.component' | 11 | import { CustomModalComponent } from '@app/modal/custom-modal.component' |
12 | import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' | ||
12 | import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks' | 13 | import { getHookType, internalRunHook } from '@shared/core-utils/plugins/hooks' |
13 | import { | 14 | import { |
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' | |||
4 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' | 4 | import { Inject, Injectable, LOCALE_ID } from '@angular/core' |
5 | import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' | 5 | import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' |
6 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' | 6 | import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' |
7 | import { | 7 | import { getCompleteLocale, isDefaultLocale, peertubeTranslate } from '@shared/core-utils/i18n' |
8 | getCompleteLocale, | 8 | import { SearchTargetType, ServerConfig, ServerStats, VideoConstant } from '@shared/models' |
9 | isDefaultLocale, | ||
10 | peertubeTranslate, | ||
11 | SearchTargetType, | ||
12 | ServerConfig, | ||
13 | ServerStats, | ||
14 | VideoConstant | ||
15 | } from '@shared/models' | ||
16 | import { environment } from '../../../environments/environment' | 9 | import { 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 @@ | |||
1 | import { Account } from '@app/shared/shared-main/account/account.model' | 1 | import { Account } from '@app/shared/shared-main/account/account.model' |
2 | import { hasUserRight } from '@shared/core-utils/users' | ||
2 | import { | 3 | import { |
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 @@ | |||
1 | import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' |
2 | import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' | 2 | import { getDevLocale, isOnDevLocale, sortBy } from '@app/helpers' |
3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
4 | import { getCompleteLocale, getShortLocale, I18N_LOCALES } from '@shared/models' | 4 | import { 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' | |||
3 | import { HttpClient } from '@angular/common/http' | 3 | import { HttpClient } from '@angular/common/http' |
4 | import { Injectable } from '@angular/core' | 4 | import { Injectable } from '@angular/core' |
5 | import { MarkdownService, RestExtractor, ServerService } from '@app/core' | 5 | import { MarkdownService, RestExtractor, ServerService } from '@app/core' |
6 | import { About, peertubeTranslate } from '@shared/models' | 6 | import { peertubeTranslate } from '@shared/core-utils/i18n' |
7 | import { About } from '@shared/models' | ||
7 | import { environment } from '../../../environments/environment' | 8 | import { 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' | |||
5 | import { RestExtractor, ServerService } from '@app/core' | 5 | import { RestExtractor, ServerService } from '@app/core' |
6 | import { objectToFormData, sortBy } from '@app/helpers' | 6 | import { objectToFormData, sortBy } from '@app/helpers' |
7 | import { VideoService } from '@app/shared/shared-main/video' | 7 | import { VideoService } from '@app/shared/shared-main/video' |
8 | import { peertubeTranslate, ResultList, VideoCaption } from '@shared/models' | 8 | import { peertubeTranslate } from '@shared/core-utils/i18n' |
9 | import { ResultList, VideoCaption } from '@shared/models' | ||
9 | import { VideoCaptionEdit } from './video-caption-edit.model' | 10 | import { 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' | |||
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core' | 6 | import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core' |
7 | import { objectToFormData } from '@app/helpers' | 7 | import { objectToFormData } from '@app/helpers' |
8 | import { peertubeTranslate, ResultList, VideoImport, VideoImportCreate, VideoUpdate } from '@shared/models' | 8 | import { peertubeTranslate } from '@shared/core-utils/i18n' |
9 | import { ResultList, VideoImport, VideoImportCreate, VideoUpdate } from '@shared/models' | ||
9 | import { environment } from '../../../../environments/environment' | 10 | import { 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 @@ | |||
1 | import { AuthUser } from '@app/core' | 1 | import { AuthUser } from '@app/core' |
2 | import { User } from '@app/core/users/user.model' | 2 | import { User } from '@app/core/users/user.model' |
3 | import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' | 3 | import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' |
4 | import { peertubeTranslate } from '@shared/core-utils/i18n' | ||
4 | import { | 5 | import { |
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' | |||
6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
7 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | 7 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' |
8 | import { I18n } from '@ngx-translate/i18n-polyfill' | 8 | import { I18n } from '@ngx-translate/i18n-polyfill' |
9 | import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' | 9 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' |
10 | import { AbusePredefinedReasonsString } from '@shared/models' | ||
10 | import { AbuseService } from '../abuse.service' | 11 | import { 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' | |||
6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
7 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | 7 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' |
8 | import { I18n } from '@ngx-translate/i18n-polyfill' | 8 | import { I18n } from '@ngx-translate/i18n-polyfill' |
9 | import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' | 9 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' |
10 | import { AbusePredefinedReasonsString } from '@shared/models' | ||
10 | import { AbuseService } from '../abuse.service' | 11 | import { 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 | |||
7 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 7 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
8 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | 8 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' |
9 | import { I18n } from '@ngx-translate/i18n-polyfill' | 9 | import { I18n } from '@ngx-translate/i18n-polyfill' |
10 | import { abusePredefinedReasonsMap, AbusePredefinedReasonsString } from '@shared/models' | 10 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' |
11 | import { AbusePredefinedReasonsString } from '@shared/models' | ||
11 | import { Video } from '../../shared-main' | 12 | import { Video } from '../../shared-main' |
12 | import { AbuseService } from '../abuse.service' | 13 | import { 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 @@ | |||
1 | import { getAbsoluteAPIUrl } from '@app/helpers' | 1 | import { getAbsoluteAPIUrl } from '@app/helpers' |
2 | import { Actor } from '@app/shared/shared-main' | 2 | import { Actor } from '@app/shared/shared-main' |
3 | import { peertubeTranslate } from '@shared/core-utils/i18n' | ||
3 | import { | 4 | import { |
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' | |||
19 | import './videojs-components/settings-panel-child' | 19 | import './videojs-components/settings-panel-child' |
20 | import './videojs-components/theater-button' | 20 | import './videojs-components/theater-button' |
21 | import videojs from 'video.js' | 21 | import videojs from 'video.js' |
22 | import { isDefaultLocale, VideoFile } from '@shared/models' | 22 | import { VideoFile } from '@shared/models' |
23 | import { isDefaultLocale } from '@shared/core-utils/i18n' | ||
23 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' | 24 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' |
24 | import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder' | 25 | import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder' |
25 | import { segmentValidatorFactory } from './p2p-media-loader/segment-validator' | 26 | import { 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 @@ | |||
1 | import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '@shared/models' | 1 | import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '@shared/core-utils/i18n' |
2 | 2 | ||
3 | export class TranslationsManager { | 3 | export 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 @@ | |||
1 | import './embed.scss' | 1 | import './embed.scss' |
2 | import videojs from 'video.js' | 2 | import videojs from 'video.js' |
3 | import { objectToUrlEncoded, peertubeLocalStorage, PureAuthUser } from '@root-helpers/index' | 3 | import { objectToUrlEncoded, peertubeLocalStorage, PureAuthUser } from '@root-helpers/index' |
4 | import { peertubeTranslate } from '../../../../shared/core-utils/i18n' | ||
4 | import { | 5 | import { |
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { logger } from '@server/helpers/logger' | ||
2 | import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation' | 3 | import { createAccountAbuse, createVideoAbuse, createVideoCommentAbuse } from '@server/lib/moderation' |
4 | import { Notifier } from '@server/lib/notifier' | ||
3 | import { AbuseModel } from '@server/models/abuse/abuse' | 5 | import { AbuseModel } from '@server/models/abuse/abuse' |
4 | import { AbuseMessageModel } from '@server/models/abuse/abuse-message' | 6 | import { AbuseMessageModel } from '@server/models/abuse/abuse-message' |
5 | import { getServerActor } from '@server/models/application/application' | 7 | import { getServerActor } from '@server/models/application/application' |
6 | import { AbuseCreate, abusePredefinedReasonsMap, AbuseState, UserRight } from '../../../shared' | 8 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' |
9 | import { AbuseCreate, AbuseState, UserRight } from '../../../shared' | ||
7 | import { getFormattedObjects } from '../../helpers/utils' | 10 | import { getFormattedObjects } from '../../helpers/utils' |
8 | import { sequelizeTypescript } from '../../initializers/database' | 11 | import { sequelizeTypescript } from '../../initializers/database' |
9 | import { | 12 | import { |
@@ -25,8 +28,6 @@ import { | |||
25 | setDefaultSort | 28 | setDefaultSort |
26 | } from '../../middlewares' | 29 | } from '../../middlewares' |
27 | import { AccountModel } from '../../models/account/account' | 30 | import { AccountModel } from '../../models/account/account' |
28 | import { Notifier } from '@server/lib/notifier' | ||
29 | import { logger } from '@server/helpers/logger' | ||
30 | 31 | ||
31 | const abuseRouter = express.Router() | 32 | const 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 @@ | |||
1 | import { constants, promises as fs } from 'fs' | ||
2 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { constants, promises as fs } from 'fs' | ||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { CONFIG } from '@server/initializers/config' | ||
5 | import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n' | ||
4 | import { root } from '../helpers/core-utils' | 6 | import { root } from '../helpers/core-utils' |
7 | import { logger } from '../helpers/logger' | ||
5 | import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' | 8 | import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' |
6 | import { asyncMiddleware, embedCSP } from '../middlewares' | ||
7 | import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n' | ||
8 | import { ClientHtml } from '../lib/client-html' | 9 | import { ClientHtml } from '../lib/client-html' |
9 | import { logger } from '../helpers/logger' | 10 | import { asyncMiddleware, embedCSP } from '../middlewares' |
10 | import { CONFIG } from '@server/initializers/config' | ||
11 | 11 | ||
12 | const clientsRouter = express.Router() | 12 | const 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 | |||
6 | import { serveThemeCSSValidator } from '../middlewares/validators/themes' | 6 | import { serveThemeCSSValidator } from '../middlewares/validators/themes' |
7 | import { PluginType } from '../../shared/models/plugins/plugin.type' | 7 | import { PluginType } from '../../shared/models/plugins/plugin.type' |
8 | import { isTestInstance } from '../helpers/core-utils' | 8 | import { isTestInstance } from '../helpers/core-utils' |
9 | import { getCompleteLocale, is18nLocale } from '../../shared/models/i18n' | 9 | import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n' |
10 | import { logger } from '@server/helpers/logger' | 10 | import { logger } from '@server/helpers/logger' |
11 | 11 | ||
12 | const sendFileOptions = { | 12 | const 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 @@ | |||
1 | import validator from 'validator' | 1 | import validator from 'validator' |
2 | import { AbuseFilter, abusePredefinedReasonsMap, AbusePredefinedReasonsString, AbuseVideoIs, AbuseCreate } from '@shared/models' | 2 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' |
3 | import { AbuseCreate, AbuseFilter, AbusePredefinedReasonsString, AbuseVideoIs } from '@shared/models' | ||
3 | import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' | 4 | import { ABUSE_STATES, CONSTRAINTS_FIELDS } from '../../initializers/constants' |
4 | import { exists, isArray } from './misc' | 5 | import { 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' | |||
8 | const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS | 8 | const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS |
9 | 9 | ||
10 | function isPluginTypeValid (value: any) { | 10 | function 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 | ||
14 | function isPluginNameValid (value: string) { | 15 | function 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 | ||
12 | function isVideoBlacklistTypeValid (value: any) { | 12 | function 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 '@ | |||
2 | import { AccountModel } from '@server/models/account/account' | 2 | import { AccountModel } from '@server/models/account/account' |
3 | import { VideoModel } from '@server/models/video/video' | 3 | import { VideoModel } from '@server/models/video/video' |
4 | import { VideoCommentModel } from '@server/models/video/video-comment' | 4 | import { VideoCommentModel } from '@server/models/video/video-comment' |
5 | import { AbuseObject, abusePredefinedReasonsMap, AbuseState, ActivityCreate, ActivityFlag } from '../../../../shared' | 5 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' |
6 | import { AbuseObject, AbuseState, ActivityCreate, ActivityFlag } from '../../../../shared' | ||
6 | import { getAPId } from '../../../helpers/activitypub' | 7 | import { getAPId } from '../../../helpers/activitypub' |
7 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 8 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
8 | import { logger } from '../../../helpers/logger' | 9 | import { 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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' | 2 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n' |
3 | import { | 3 | import { |
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' |
19 | import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses' | 19 | import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses' |
20 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' | ||
20 | import { | 21 | import { |
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 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
2 | import { values } from 'lodash' | ||
1 | import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize' | 3 | import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize' |
2 | import { | 4 | import { |
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' |
22 | import { hasUserRight, MyUser, USER_ROLE_LABELS, UserRight, AbuseState, VideoPlaylistType, VideoPrivacy } from '../../../shared' | 24 | import { |
25 | MMyUserFormattable, | ||
26 | MUserDefault, | ||
27 | MUserFormattable, | ||
28 | MUserId, | ||
29 | MUserNotifSettingChannelDefault, | ||
30 | MUserWithNotificationSetting, | ||
31 | MVideoFullLight | ||
32 | } from '@server/types/models' | ||
33 | import { hasUserRight, USER_ROLE_LABELS } from '../../../shared/core-utils/users' | ||
34 | import { AbuseState, MyUser, UserRight, VideoPlaylistType, VideoPrivacy } from '../../../shared/models' | ||
23 | import { User, UserRole } from '../../../shared/models/users' | 35 | import { User, UserRole } from '../../../shared/models/users' |
36 | import { UserAdminFlag } from '../../../shared/models/users/user-flag.model' | ||
37 | import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' | ||
38 | import { isThemeNameValid } from '../../helpers/custom-validators/plugins' | ||
24 | import { | 39 | import { |
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' |
44 | import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' | 59 | import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' |
60 | import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants' | ||
61 | import { clearCacheByUserId } from '../../lib/oauth-model' | ||
62 | import { getThemeOrDefault } from '../../lib/plugins/theme-utils' | ||
63 | import { ActorModel } from '../activitypub/actor' | ||
64 | import { ActorFollowModel } from '../activitypub/actor-follow' | ||
45 | import { OAuthTokenModel } from '../oauth/oauth-token' | 65 | import { OAuthTokenModel } from '../oauth/oauth-token' |
46 | import { getSort, throwIfNotValid } from '../utils' | 66 | import { getSort, throwIfNotValid } from '../utils' |
67 | import { VideoModel } from '../video/video' | ||
47 | import { VideoChannelModel } from '../video/video-channel' | 68 | import { VideoChannelModel } from '../video/video-channel' |
69 | import { VideoImportModel } from '../video/video-import' | ||
48 | import { VideoPlaylistModel } from '../video/video-playlist' | 70 | import { VideoPlaylistModel } from '../video/video-playlist' |
49 | import { AccountModel } from './account' | 71 | import { AccountModel } from './account' |
50 | import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' | ||
51 | import { values } from 'lodash' | ||
52 | import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants' | ||
53 | import { clearCacheByUserId } from '../../lib/oauth-model' | ||
54 | import { UserNotificationSettingModel } from './user-notification-setting' | 72 | import { UserNotificationSettingModel } from './user-notification-setting' |
55 | import { VideoModel } from '../video/video' | ||
56 | import { ActorModel } from '../activitypub/actor' | ||
57 | import { ActorFollowModel } from '../activitypub/actor-follow' | ||
58 | import { VideoImportModel } from '../video/video-import' | ||
59 | import { UserAdminFlag } from '../../../shared/models/users/user-flag.model' | ||
60 | import { isThemeNameValid } from '../../helpers/custom-validators/plugins' | ||
61 | import { getThemeOrDefault } from '../../lib/plugins/theme-utils' | ||
62 | import * as Bluebird from 'bluebird' | ||
63 | import { | ||
64 | MMyUserFormattable, | ||
65 | MUserDefault, | ||
66 | MUserFormattable, | ||
67 | MUserId, | ||
68 | MUserNotifSettingChannelDefault, | ||
69 | MUserWithNotificationSetting, | ||
70 | MVideoFullLight | ||
71 | } from '@server/types/models' | ||
72 | 73 | ||
73 | enum ScopeNames { | 74 | enum 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 @@ | |||
1 | import { AbusePredefinedReasons, AbusePredefinedReasonsString } from '../../models/moderation/abuse/abuse-reason.model' | ||
2 | |||
3 | export 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 @@ | |||
1 | import { UserRight, UserRole } from '../../models/users' | ||
2 | |||
3 | export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = { | ||
4 | [UserRole.USER]: 'User', | ||
5 | [UserRole.MODERATOR]: 'Moderator', | ||
6 | [UserRole.ADMINISTRATOR]: 'Administrator' | ||
7 | } | ||
8 | |||
9 | const 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 | |||
31 | export 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 @@ | |||
1 | export enum FeedFormat { | 1 | export 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' | |||
7 | export * from './users' | 7 | export * from './users' |
8 | export * from './videos' | 8 | export * from './videos' |
9 | export * from './feeds' | 9 | export * from './feeds' |
10 | export * from './i18n' | ||
11 | export * from './overviews' | 10 | export * from './overviews' |
12 | export * from './plugins' | 11 | export * from './plugins' |
13 | export * from './search' | 12 | export * 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 @@ | |||
1 | export enum AbusePredefinedReasons { | 1 | export 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 | |||
22 | export 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 @@ | |||
1 | export enum AbuseState { | 1 | export 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 @@ | |||
1 | export enum HookType { | 1 | export 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 @@ | |||
1 | export enum UserAdminFlag { | 1 | export 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 @@ | |||
1 | export enum UserNotificationSettingValue { | 1 | export 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 @@ | |||
1 | export enum UserRight { | 1 | export 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 @@ | |||
1 | import { UserRight } from './user-right.enum' | ||
2 | |||
3 | // Keep the order | 1 | // Keep the order |
4 | export enum UserRole { | 2 | export enum UserRole { |
5 | ADMINISTRATOR = 0, | 3 | ADMINISTRATOR = 0, |
6 | MODERATOR = 1, | 4 | MODERATOR = 1, |
7 | USER = 2 | 5 | USER = 2 |
8 | } | 6 | } |
9 | |||
10 | export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = { | ||
11 | [UserRole.USER]: 'User', | ||
12 | [UserRole.MODERATOR]: 'Moderator', | ||
13 | [UserRole.ADMINISTRATOR]: 'Administrator' | ||
14 | } | ||
15 | |||
16 | const 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 | |||
38 | export 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 @@ | |||
1 | import { Video } from '../video.model' | 1 | import { Video } from '../video.model' |
2 | 2 | ||
3 | export enum VideoBlacklistType { | 3 | export 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 @@ | |||
1 | export enum VideoImportState { | 1 | export 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 @@ | |||
1 | import { Video } from '../video.model' | 1 | import { Video } from '../video.model' |
2 | 2 | ||
3 | export enum VideoPlaylistElementType { | 3 | export 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 @@ | |||
1 | export enum VideoPlaylistPrivacy { | 1 | export 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 @@ | |||
1 | export enum VideoPlaylistType { | 1 | export 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 @@ | |||
1 | export enum ThumbnailType { | 1 | export 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 | ||
13 | export enum VideoChangeOwnershipStatus { | 13 | export 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 @@ | |||
1 | export enum VideoPrivacy { | 1 | export 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 @@ | |||
1 | import { VideoTranscodingFPS } from './video-transcoding-fps.model' | 1 | import { VideoTranscodingFPS } from './video-transcoding-fps.model' |
2 | 2 | ||
3 | export enum VideoResolution { | 3 | export 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 @@ | |||
1 | export enum VideoState { | 1 | export 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 @@ | |||
1 | export enum VideoStreamingPlaylistType { | 1 | export const enum VideoStreamingPlaylistType { |
2 | HLS = 1 | 2 | HLS = 1 |
3 | } | 3 | } |