diff options
Diffstat (limited to 'shared/models')
44 files changed, 499 insertions, 127 deletions
diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts index 492b672c7..20ecf176c 100644 --- a/shared/models/activitypub/activity.ts +++ b/shared/models/activitypub/activity.ts | |||
@@ -8,12 +8,33 @@ import { ViewObject } from './objects/view-object' | |||
8 | import { APObject } from './objects/object.model' | 8 | import { APObject } from './objects/object.model' |
9 | import { PlaylistObject } from './objects/playlist-object' | 9 | import { PlaylistObject } from './objects/playlist-object' |
10 | 10 | ||
11 | export type Activity = ActivityCreate | ActivityUpdate | | 11 | export type Activity = |
12 | ActivityDelete | ActivityFollow | ActivityAccept | ActivityAnnounce | | 12 | ActivityCreate | |
13 | ActivityUndo | ActivityLike | ActivityReject | ActivityView | ActivityDislike | ActivityFlag | 13 | ActivityUpdate | |
14 | 14 | ActivityDelete | | |
15 | export type ActivityType = 'Create' | 'Update' | 'Delete' | 'Follow' | 'Accept' | 'Announce' | 'Undo' | 'Like' | 'Reject' | | 15 | ActivityFollow | |
16 | 'View' | 'Dislike' | 'Flag' | 16 | ActivityAccept | |
17 | ActivityAnnounce | | ||
18 | ActivityUndo | | ||
19 | ActivityLike | | ||
20 | ActivityReject | | ||
21 | ActivityView | | ||
22 | ActivityDislike | | ||
23 | ActivityFlag | ||
24 | |||
25 | export type ActivityType = | ||
26 | 'Create' | | ||
27 | 'Update' | | ||
28 | 'Delete' | | ||
29 | 'Follow' | | ||
30 | 'Accept' | | ||
31 | 'Announce' | | ||
32 | 'Undo' | | ||
33 | 'Like' | | ||
34 | 'Reject' | | ||
35 | 'View' | | ||
36 | 'Dislike' | | ||
37 | 'Flag' | ||
17 | 38 | ||
18 | export interface ActivityAudience { | 39 | export interface ActivityAudience { |
19 | to: string[] | 40 | to: string[] |
@@ -66,17 +87,17 @@ export interface ActivityAnnounce extends BaseActivity { | |||
66 | } | 87 | } |
67 | 88 | ||
68 | export interface ActivityUndo extends BaseActivity { | 89 | export interface ActivityUndo extends BaseActivity { |
69 | type: 'Undo', | 90 | type: 'Undo' |
70 | object: ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate | ActivityAnnounce | 91 | object: ActivityFollow | ActivityLike | ActivityDislike | ActivityCreate | ActivityAnnounce |
71 | } | 92 | } |
72 | 93 | ||
73 | export interface ActivityLike extends BaseActivity { | 94 | export interface ActivityLike extends BaseActivity { |
74 | type: 'Like', | 95 | type: 'Like' |
75 | object: APObject | 96 | object: APObject |
76 | } | 97 | } |
77 | 98 | ||
78 | export interface ActivityView extends BaseActivity { | 99 | export interface ActivityView extends BaseActivity { |
79 | type: 'View', | 100 | type: 'View' |
80 | actor: string | 101 | actor: string |
81 | object: APObject | 102 | object: APObject |
82 | } | 103 | } |
@@ -89,7 +110,7 @@ export interface ActivityDislike extends BaseActivity { | |||
89 | } | 110 | } |
90 | 111 | ||
91 | export interface ActivityFlag extends BaseActivity { | 112 | export interface ActivityFlag extends BaseActivity { |
92 | type: 'Flag', | 113 | type: 'Flag' |
93 | content: string, | 114 | content: string |
94 | object: APObject | APObject[] | 115 | object: APObject | APObject[] |
95 | } | 116 | } |
diff --git a/shared/models/activitypub/activitypub-actor.ts b/shared/models/activitypub/activitypub-actor.ts index b8a2dc925..f022f3d02 100644 --- a/shared/models/activitypub/activitypub-actor.ts +++ b/shared/models/activitypub/activitypub-actor.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { ActivityPubAttributedTo } from './objects/common-objects' | 1 | import { ActivityIconObject, ActivityPubAttributedTo } from './objects/common-objects' |
2 | 2 | ||
3 | export type ActivityPubActorType = 'Person' | 'Application' | 'Group' | 'Service' | 'Organization' | 3 | export type ActivityPubActorType = 'Person' | 'Application' | 'Group' | 'Service' | 'Organization' |
4 | 4 | ||
@@ -27,9 +27,5 @@ export interface ActivityPubActor { | |||
27 | publicKeyPem: string | 27 | publicKeyPem: string |
28 | } | 28 | } |
29 | 29 | ||
30 | icon: { | 30 | icon: ActivityIconObject |
31 | type: 'Image' | ||
32 | mediaType: 'image/png' | ||
33 | url: string | ||
34 | } | ||
35 | } | 31 | } |
diff --git a/shared/models/activitypub/activitypub-signature.ts b/shared/models/activitypub/activitypub-signature.ts index 1d9f4b3b3..fafdc246d 100644 --- a/shared/models/activitypub/activitypub-signature.ts +++ b/shared/models/activitypub/activitypub-signature.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | export interface ActivityPubSignature { | 1 | export interface ActivityPubSignature { |
2 | type: 'GraphSignature2012' | 2 | type: string |
3 | created: Date, | 3 | created: Date |
4 | creator: string | 4 | creator: string |
5 | signatureValue: string | 5 | signatureValue: string |
6 | } | 6 | } |
diff --git a/shared/models/activitypub/context.ts b/shared/models/activitypub/context.ts new file mode 100644 index 000000000..bd795a2fd --- /dev/null +++ b/shared/models/activitypub/context.ts | |||
@@ -0,0 +1 @@ | |||
export type ContextType = 'All' | 'View' | 'Announce' | 'CacheFile' | |||
diff --git a/shared/models/activitypub/objects/cache-file-object.ts b/shared/models/activitypub/objects/cache-file-object.ts index 4b0a3a724..19a817582 100644 --- a/shared/models/activitypub/objects/cache-file-object.ts +++ b/shared/models/activitypub/objects/cache-file-object.ts | |||
@@ -2,7 +2,7 @@ import { ActivityVideoUrlObject, ActivityPlaylistUrlObject } from './common-obje | |||
2 | 2 | ||
3 | export interface CacheFileObject { | 3 | export interface CacheFileObject { |
4 | id: string | 4 | id: string |
5 | type: 'CacheFile', | 5 | type: 'CacheFile' |
6 | object: string | 6 | object: string |
7 | expires: string | 7 | expires: string |
8 | url: ActivityVideoUrlObject | ActivityPlaylistUrlObject | 8 | url: ActivityVideoUrlObject | ActivityPlaylistUrlObject |
diff --git a/shared/models/activitypub/objects/common-objects.ts b/shared/models/activitypub/objects/common-objects.ts index de1116ab3..bb3ffe678 100644 --- a/shared/models/activitypub/objects/common-objects.ts +++ b/shared/models/activitypub/objects/common-objects.ts | |||
@@ -1,14 +1,15 @@ | |||
1 | export interface ActivityIdentifierObject { | 1 | export interface ActivityIdentifierObject { |
2 | identifier: string | 2 | identifier: string |
3 | name: string | 3 | name: string |
4 | url?: string | ||
4 | } | 5 | } |
5 | 6 | ||
6 | export interface ActivityIconObject { | 7 | export interface ActivityIconObject { |
7 | type: 'Image' | 8 | type: 'Image' |
8 | url: string | 9 | url: string |
9 | mediaType: 'image/jpeg' | 10 | mediaType: 'image/jpeg' | 'image/png' |
10 | width: number | 11 | width?: number |
11 | height: number | 12 | height?: number |
12 | } | 13 | } |
13 | 14 | ||
14 | export type ActivityVideoUrlObject = { | 15 | export type ActivityVideoUrlObject = { |
@@ -27,6 +28,15 @@ export type ActivityPlaylistSegmentHashesObject = { | |||
27 | href: string | 28 | href: string |
28 | } | 29 | } |
29 | 30 | ||
31 | export type ActivityVideoFileMetadataObject = { | ||
32 | type: 'Link' | ||
33 | rel: [ 'metadata', any ] | ||
34 | mediaType: 'application/json' | ||
35 | height: number | ||
36 | href: string | ||
37 | fps: number | ||
38 | } | ||
39 | |||
30 | export type ActivityPlaylistInfohashesObject = { | 40 | export type ActivityPlaylistInfohashesObject = { |
31 | type: 'Infohash' | 41 | type: 'Infohash' |
32 | name: string | 42 | name: string |
@@ -71,19 +81,23 @@ export interface ActivityMentionObject { | |||
71 | name: string | 81 | name: string |
72 | } | 82 | } |
73 | 83 | ||
74 | export type ActivityTagObject = ActivityPlaylistSegmentHashesObject | | 84 | export type ActivityTagObject = |
75 | ActivityPlaylistInfohashesObject | | 85 | ActivityPlaylistSegmentHashesObject |
76 | ActivityVideoUrlObject | | 86 | | ActivityPlaylistInfohashesObject |
77 | ActivityHashTagObject | | 87 | | ActivityVideoUrlObject |
78 | ActivityMentionObject | | 88 | | ActivityHashTagObject |
79 | ActivityBitTorrentUrlObject | | 89 | | ActivityMentionObject |
80 | ActivityMagnetUrlObject | 90 | | ActivityBitTorrentUrlObject |
91 | | ActivityMagnetUrlObject | ||
92 | | ActivityVideoFileMetadataObject | ||
81 | 93 | ||
82 | export type ActivityUrlObject = ActivityVideoUrlObject | | 94 | export type ActivityUrlObject = |
83 | ActivityPlaylistUrlObject | | 95 | ActivityVideoUrlObject |
84 | ActivityBitTorrentUrlObject | | 96 | | ActivityPlaylistUrlObject |
85 | ActivityMagnetUrlObject | | 97 | | ActivityBitTorrentUrlObject |
86 | ActivityHtmlUrlObject | 98 | | ActivityMagnetUrlObject |
99 | | ActivityHtmlUrlObject | ||
100 | | ActivityVideoFileMetadataObject | ||
87 | 101 | ||
88 | export interface ActivityPubAttributedTo { | 102 | export interface ActivityPubAttributedTo { |
89 | type: 'Group' | 'Person' | 103 | type: 'Group' | 'Person' |
diff --git a/shared/models/activitypub/objects/video-abuse-object.ts b/shared/models/activitypub/objects/video-abuse-object.ts index 5f1264a76..d9622b414 100644 --- a/shared/models/activitypub/objects/video-abuse-object.ts +++ b/shared/models/activitypub/objects/video-abuse-object.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | export interface VideoAbuseObject { | 1 | export interface VideoAbuseObject { |
2 | type: 'Flag', | 2 | type: 'Flag' |
3 | content: string | 3 | content: string |
4 | object: string | string[] | 4 | object: string | string[] |
5 | } | 5 | } |
diff --git a/shared/models/activitypub/objects/video-torrent-object.ts b/shared/models/activitypub/objects/video-torrent-object.ts index 239822bc4..11de8fc56 100644 --- a/shared/models/activitypub/objects/video-torrent-object.ts +++ b/shared/models/activitypub/objects/video-torrent-object.ts | |||
@@ -20,8 +20,8 @@ export interface VideoTorrentObject { | |||
20 | subtitleLanguage: ActivityIdentifierObject[] | 20 | subtitleLanguage: ActivityIdentifierObject[] |
21 | views: number | 21 | views: number |
22 | sensitive: boolean | 22 | sensitive: boolean |
23 | commentsEnabled: boolean, | 23 | commentsEnabled: boolean |
24 | downloadEnabled: boolean, | 24 | downloadEnabled: boolean |
25 | waitTranscoding: boolean | 25 | waitTranscoding: boolean |
26 | state: VideoState | 26 | state: VideoState |
27 | published: string | 27 | published: string |
@@ -30,7 +30,9 @@ export interface VideoTorrentObject { | |||
30 | mediaType: 'text/markdown' | 30 | mediaType: 'text/markdown' |
31 | content: string | 31 | content: string |
32 | support: string | 32 | support: string |
33 | icon: ActivityIconObject | 33 | |
34 | icon: ActivityIconObject[] | ||
35 | |||
34 | url: ActivityUrlObject[] | 36 | url: ActivityUrlObject[] |
35 | likes: string | 37 | likes: string |
36 | dislikes: string | 38 | dislikes: string |
diff --git a/shared/models/activitypub/objects/view-object.ts b/shared/models/activitypub/objects/view-object.ts index 00348116a..4dd21ce8e 100644 --- a/shared/models/activitypub/objects/view-object.ts +++ b/shared/models/activitypub/objects/view-object.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | export interface ViewObject { | 1 | export interface ViewObject { |
2 | type: 'View', | 2 | type: 'View' |
3 | actor: string | 3 | actor: string |
4 | object: string | 4 | object: string |
5 | } | 5 | } |
diff --git a/shared/models/i18n/i18n.ts b/shared/models/i18n/i18n.ts index 032944281..46940772f 100644 --- a/shared/models/i18n/i18n.ts +++ b/shared/models/i18n/i18n.ts | |||
@@ -1,46 +1,56 @@ | |||
1 | export const LOCALE_FILES = [ 'player', 'server' ] | 1 | export const LOCALE_FILES = [ 'player', 'server' ] |
2 | 2 | ||
3 | export const I18N_LOCALES = { | 3 | export const I18N_LOCALES = { |
4 | // Always first to avoid issues when using express acceptLanguages function when no accept language header is set | ||
4 | 'en-US': 'English', | 5 | 'en-US': 'English', |
5 | 'fr-FR': 'Français', | 6 | |
6 | 'ja-JP': '日本語', | ||
7 | 'eu-ES': 'Euskara', | ||
8 | 'ca-ES': 'Català', | 7 | 'ca-ES': 'Català', |
9 | 'cs-CZ': 'Čeština', | 8 | 'cs-CZ': 'Čeština', |
10 | 'eo': 'Esperanto', | ||
11 | 'el-GR': 'ελληνικά', | ||
12 | 'de-DE': 'Deutsch', | 9 | 'de-DE': 'Deutsch', |
13 | 'it-IT': 'Italiano', | 10 | 'el-GR': 'ελληνικά', |
14 | 'nl-NL': 'Nederlands', | 11 | 'eo': 'Esperanto', |
15 | 'es-ES': 'Español', | 12 | 'es-ES': 'Español', |
16 | 'oc': 'Occitan', | 13 | 'eu-ES': 'Euskara', |
14 | 'fi-FI': 'suomi', | ||
15 | 'fr-FR': 'Français', | ||
17 | 'gd': 'Gàidhlig', | 16 | 'gd': 'Gàidhlig', |
18 | 'zh-Hant-TW': '繁體中文(台灣)', | 17 | 'hu-HU': 'magyar', |
18 | 'it-IT': 'Italiano', | ||
19 | 'ja-JP': '日本語', | ||
20 | 'nl-NL': 'Nederlands', | ||
21 | 'pl-PL': 'Polski', | ||
19 | 'pt-BR': 'Português (Brasil)', | 22 | 'pt-BR': 'Português (Brasil)', |
20 | 'pt-PT': 'Português (Portugal)', | 23 | 'pt-PT': 'Português (Portugal)', |
21 | 'sv-SE': 'svenska', | ||
22 | 'pl-PL': 'Polski', | ||
23 | 'fi-FI': 'suomi', | ||
24 | 'ru-RU': 'русский', | 24 | 'ru-RU': 'русский', |
25 | 'zh-Hans-CN': '简体中文(中国)' | 25 | 'sv-SE': 'svenska', |
26 | 'th-TH': 'ไทย', | ||
27 | 'zh-Hans-CN': '简体中文(中国)', | ||
28 | 'zh-Hant-TW': '繁體中文(台灣)' | ||
26 | } | 29 | } |
27 | 30 | ||
28 | const I18N_LOCALE_ALIAS = { | 31 | const I18N_LOCALE_ALIAS = { |
29 | 'en': 'en-US', | ||
30 | 'fr': 'fr-FR', | ||
31 | 'eu': 'eu-ES', | ||
32 | 'ca': 'ca-ES', | 32 | 'ca': 'ca-ES', |
33 | 'cs': 'cs-CZ', | 33 | 'cs': 'cs-CZ', |
34 | 'de': 'de-DE', | 34 | 'de': 'de-DE', |
35 | 'el': 'el-GR', | ||
36 | 'en': 'en-US', | ||
35 | 'es': 'es-ES', | 37 | 'es': 'es-ES', |
36 | 'pt': 'pt-PT', | 38 | 'eu': 'eu-ES', |
37 | 'fi': 'fi-FI', | 39 | 'fi': 'fi-FI', |
38 | 'sv': 'sv-SE', | 40 | 'fr': 'fr-FR', |
41 | 'ja': 'ja-JP', | ||
42 | 'it': 'it-IT', | ||
43 | 'hu': 'hu-HU', | ||
44 | 'nl': 'nl-NL', | ||
39 | 'pl': 'pl-PL', | 45 | 'pl': 'pl-PL', |
46 | 'pt': 'pt-BR', | ||
40 | 'ru': 'ru-RU', | 47 | 'ru': 'ru-RU', |
41 | 'nl': 'nl-NL', | 48 | 'sv': 'sv-SE', |
49 | 'th': 'th-TH', | ||
42 | 'zh': 'zh-Hans-CN', | 50 | 'zh': 'zh-Hans-CN', |
51 | 'zh-Hans': 'zh-Hans-CN', | ||
43 | 'zh-CN': 'zh-Hans-CN', | 52 | 'zh-CN': 'zh-Hans-CN', |
53 | 'zh-Hant': 'zh-Hant-TW', | ||
44 | 'zh-TW': 'zh-Hant-TW' | 54 | 'zh-TW': 'zh-Hant-TW' |
45 | } | 55 | } |
46 | 56 | ||
@@ -56,16 +66,18 @@ export function isDefaultLocale (locale: string) { | |||
56 | } | 66 | } |
57 | 67 | ||
58 | export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) { | 68 | export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) { |
69 | // FIXME: remove disable rule when the client is upgraded to typescript 3.7 | ||
70 | // eslint-disable-next-line | ||
59 | return translations && translations[str] ? translations[str] : str | 71 | return translations && translations[str] ? translations[str] : str |
60 | } | 72 | } |
61 | 73 | ||
62 | const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l) | 74 | const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l) |
63 | export function is18nPath (path: string) { | 75 | export function is18nPath (path: string) { |
64 | return possiblePaths.indexOf(path) !== -1 | 76 | return possiblePaths.includes(path) |
65 | } | 77 | } |
66 | 78 | ||
67 | export function is18nLocale (locale: string) { | 79 | export function is18nLocale (locale: string) { |
68 | return POSSIBLE_LOCALES.indexOf(locale) !== -1 | 80 | return POSSIBLE_LOCALES.includes(locale) |
69 | } | 81 | } |
70 | 82 | ||
71 | export function getCompleteLocale (locale: string) { | 83 | export function getCompleteLocale (locale: string) { |
@@ -77,7 +89,7 @@ export function getCompleteLocale (locale: string) { | |||
77 | } | 89 | } |
78 | 90 | ||
79 | export function getShortLocale (locale: string) { | 91 | export function getShortLocale (locale: string) { |
80 | if (locale.indexOf('-') === -1) return locale | 92 | if (locale.includes('-') === false) return locale |
81 | 93 | ||
82 | return locale.split('-')[0] | 94 | return locale.split('-')[0] |
83 | } | 95 | } |
diff --git a/shared/models/nodeinfo/index.d.ts b/shared/models/nodeinfo/index.d.ts index 0a2d0492e..336cb66d2 100644 --- a/shared/models/nodeinfo/index.d.ts +++ b/shared/models/nodeinfo/index.d.ts | |||
@@ -98,7 +98,7 @@ export interface HttpNodeinfoDiasporaSoftwareNsSchema20 { | |||
98 | * The amount of users that signed in at least once in the last 30 days. | 98 | * The amount of users that signed in at least once in the last 30 days. |
99 | */ | 99 | */ |
100 | activeMonth?: number | 100 | activeMonth?: number |
101 | }; | 101 | } |
102 | /** | 102 | /** |
103 | * The amount of posts that were made by users that are registered on this server. | 103 | * The amount of posts that were made by users that are registered on this server. |
104 | */ | 104 | */ |
diff --git a/shared/models/overviews/videos-overview.ts b/shared/models/overviews/videos-overview.ts index e725f166b..0f3cb4a52 100644 --- a/shared/models/overviews/videos-overview.ts +++ b/shared/models/overviews/videos-overview.ts | |||
@@ -1,18 +1,24 @@ | |||
1 | import { Video, VideoChannelSummary, VideoConstant } from '../videos' | 1 | import { Video, VideoChannelSummary, VideoConstant } from '../videos' |
2 | 2 | ||
3 | export interface ChannelOverview { | ||
4 | channel: VideoChannelSummary | ||
5 | videos: Video[] | ||
6 | } | ||
7 | |||
8 | export interface CategoryOverview { | ||
9 | category: VideoConstant<number> | ||
10 | videos: Video[] | ||
11 | } | ||
12 | |||
13 | export interface TagOverview { | ||
14 | tag: string | ||
15 | videos: Video[] | ||
16 | } | ||
17 | |||
3 | export interface VideosOverview { | 18 | export interface VideosOverview { |
4 | channels: { | 19 | channels: ChannelOverview[] |
5 | channel: VideoChannelSummary | ||
6 | videos: Video[] | ||
7 | }[] | ||
8 | 20 | ||
9 | categories: { | 21 | categories: CategoryOverview[] |
10 | category: VideoConstant<number> | ||
11 | videos: Video[] | ||
12 | }[] | ||
13 | 22 | ||
14 | tags: { | 23 | tags: TagOverview[] |
15 | tag: string | ||
16 | videos: Video[] | ||
17 | }[] | ||
18 | } | 24 | } |
diff --git a/shared/models/plugins/client-hook.model.ts b/shared/models/plugins/client-hook.model.ts index ecbe8bd3c..b53b8de99 100644 --- a/shared/models/plugins/client-hook.model.ts +++ b/shared/models/plugins/client-hook.model.ts | |||
@@ -65,6 +65,13 @@ export const clientActionHookObject = { | |||
65 | 'action:video-watch.video.loaded': true, | 65 | 'action:video-watch.video.loaded': true, |
66 | // Fired when the player finished loading | 66 | // Fired when the player finished loading |
67 | 'action:video-watch.player.loaded': true, | 67 | 'action:video-watch.player.loaded': true, |
68 | // Fired when the video watch page comments(threads) are loaded and load more comments on scroll | ||
69 | 'action:video-watch.video-threads.loaded': true, | ||
70 | // Fired when a user click on 'View x replies' and they're loaded | ||
71 | 'action:video-watch.video-thread-replies.loaded': true, | ||
72 | |||
73 | // Fired when the login page is being initialized | ||
74 | 'action:login.init': true, | ||
68 | 75 | ||
69 | // Fired when the search page is being initialized | 76 | // Fired when the search page is being initialized |
70 | 'action:search.init': true, | 77 | 'action:search.init': true, |
diff --git a/shared/models/plugins/peertube-plugin-latest-version.model.ts b/shared/models/plugins/peertube-plugin-latest-version.model.ts index dec4618fa..811a64429 100644 --- a/shared/models/plugins/peertube-plugin-latest-version.model.ts +++ b/shared/models/plugins/peertube-plugin-latest-version.model.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | export interface PeertubePluginLatestVersionRequest { | 1 | export interface PeertubePluginLatestVersionRequest { |
2 | currentPeerTubeEngine?: string, | 2 | currentPeerTubeEngine?: string |
3 | 3 | ||
4 | npmNames: string[] | 4 | npmNames: string[] |
5 | } | 5 | } |
diff --git a/shared/models/plugins/plugin-client-scope.type.ts b/shared/models/plugins/plugin-client-scope.type.ts index 1c6d884f0..d112434e8 100644 --- a/shared/models/plugins/plugin-client-scope.type.ts +++ b/shared/models/plugins/plugin-client-scope.type.ts | |||
@@ -1 +1 @@ | |||
export type PluginClientScope = 'common' | 'video-watch' | 'search' | 'signup' | export type PluginClientScope = 'common' | 'video-watch' | 'search' | 'signup' | 'login' | ||
diff --git a/shared/models/plugins/plugin-package-json.model.ts b/shared/models/plugins/plugin-package-json.model.ts index 3f3077671..c26e9ae5b 100644 --- a/shared/models/plugins/plugin-package-json.model.ts +++ b/shared/models/plugins/plugin-package-json.model.ts | |||
@@ -5,7 +5,7 @@ export type PluginTranslationPaths = { | |||
5 | } | 5 | } |
6 | 6 | ||
7 | export type ClientScript = { | 7 | export type ClientScript = { |
8 | script: string, | 8 | script: string |
9 | scopes: PluginClientScope[] | 9 | scopes: PluginClientScope[] |
10 | } | 10 | } |
11 | 11 | ||
@@ -13,12 +13,12 @@ export type PluginPackageJson = { | |||
13 | name: string | 13 | name: string |
14 | version: string | 14 | version: string |
15 | description: string | 15 | description: string |
16 | engine: { peertube: string }, | 16 | engine: { peertube: string } |
17 | 17 | ||
18 | homepage: string, | 18 | homepage: string |
19 | author: string, | 19 | author: string |
20 | bugs: string, | 20 | bugs: string |
21 | library: string, | 21 | library: string |
22 | 22 | ||
23 | staticDirs: { [ name: string ]: string } | 23 | staticDirs: { [ name: string ]: string } |
24 | css: string[] | 24 | css: string[] |
diff --git a/shared/models/plugins/plugin-playlist-privacy-manager.model.ts b/shared/models/plugins/plugin-playlist-privacy-manager.model.ts new file mode 100644 index 000000000..f9630c77f --- /dev/null +++ b/shared/models/plugins/plugin-playlist-privacy-manager.model.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | import { VideoPlaylistPrivacy } from '@shared/models' | ||
2 | |||
3 | export interface PluginPlaylistPrivacyManager { | ||
4 | // PUBLIC = 1, | ||
5 | // UNLISTED = 2, | ||
6 | // PRIVATE = 3 | ||
7 | deletePlaylistPrivacy: (privacyKey: VideoPlaylistPrivacy) => boolean | ||
8 | } | ||
diff --git a/shared/models/plugins/plugin-settings-manager.model.ts b/shared/models/plugins/plugin-settings-manager.model.ts index 63390a190..db88ae6e7 100644 --- a/shared/models/plugins/plugin-settings-manager.model.ts +++ b/shared/models/plugins/plugin-settings-manager.model.ts | |||
@@ -1,7 +1,11 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | 2 | ||
3 | export interface PluginSettingsManager { | 3 | export interface PluginSettingsManager { |
4 | getSetting: (name: string) => Bluebird<string> | 4 | getSetting: (name: string) => Bluebird<string | boolean> |
5 | |||
6 | getSettings: (names: string[]) => Bluebird<{ [settingName: string]: string | boolean }> | ||
5 | 7 | ||
6 | setSetting: (name: string, value: string) => Bluebird<any> | 8 | setSetting: (name: string, value: string) => Bluebird<any> |
9 | |||
10 | onSettingsChange: (cb: (names: string[]) => void) => void | ||
7 | } | 11 | } |
diff --git a/shared/models/plugins/plugin-video-privacy-manager.model.ts b/shared/models/plugins/plugin-video-privacy-manager.model.ts new file mode 100644 index 000000000..d602ba297 --- /dev/null +++ b/shared/models/plugins/plugin-video-privacy-manager.model.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { VideoPrivacy } from '@shared/models' | ||
2 | |||
3 | export interface PluginVideoPrivacyManager { | ||
4 | // PUBLIC = 1 | ||
5 | // UNLISTED = 2 | ||
6 | // PRIVATE = 3 | ||
7 | // INTERNAL = 4 | ||
8 | deletePrivacy: (privacyKey: VideoPrivacy) => boolean | ||
9 | } | ||
diff --git a/shared/models/plugins/register-server-auth.model.ts b/shared/models/plugins/register-server-auth.model.ts new file mode 100644 index 000000000..4ffce9456 --- /dev/null +++ b/shared/models/plugins/register-server-auth.model.ts | |||
@@ -0,0 +1,52 @@ | |||
1 | import { UserRole } from '@shared/models' | ||
2 | import { MOAuthToken, MUser } from '@server/typings/models' | ||
3 | import * as express from 'express' | ||
4 | |||
5 | export type RegisterServerAuthOptions = RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions | ||
6 | |||
7 | export interface RegisterServerAuthenticatedResult { | ||
8 | username: string | ||
9 | email: string | ||
10 | role?: UserRole | ||
11 | displayName?: string | ||
12 | } | ||
13 | |||
14 | export interface RegisterServerExternalAuthenticatedResult extends RegisterServerAuthenticatedResult { | ||
15 | req: express.Request | ||
16 | res: express.Response | ||
17 | } | ||
18 | |||
19 | interface RegisterServerAuthBase { | ||
20 | // Authentication name (a plugin can register multiple auth strategies) | ||
21 | authName: string | ||
22 | |||
23 | // Called by PeerTube when a user from your plugin logged out | ||
24 | onLogout?(user: MUser): void | ||
25 | |||
26 | // Your plugin can hook PeerTube access/refresh token validity | ||
27 | // So you can control for your plugin the user session lifetime | ||
28 | hookTokenValidity?(options: { token: MOAuthToken, type: 'access' | 'refresh' }): Promise<{ valid: boolean }> | ||
29 | } | ||
30 | |||
31 | export interface RegisterServerAuthPassOptions extends RegisterServerAuthBase { | ||
32 | // Weight of this authentication so PeerTube tries the auth methods in DESC weight order | ||
33 | getWeight(): number | ||
34 | |||
35 | // Used by PeerTube to login a user | ||
36 | // Returns null if the login failed, or { username, email } on success | ||
37 | login(body: { | ||
38 | id: string | ||
39 | password: string | ||
40 | }): Promise<RegisterServerAuthenticatedResult | null> | ||
41 | } | ||
42 | |||
43 | export interface RegisterServerAuthExternalOptions extends RegisterServerAuthBase { | ||
44 | // Will be displayed in a block next to the login form | ||
45 | authDisplayName: () => string | ||
46 | |||
47 | onAuthRequest: (req: express.Request, res: express.Response) => void | ||
48 | } | ||
49 | |||
50 | export interface RegisterServerAuthExternalResult { | ||
51 | userAuthenticated (options: RegisterServerExternalAuthenticatedResult): void | ||
52 | } | ||
diff --git a/shared/models/plugins/register-server-setting.model.ts b/shared/models/plugins/register-server-setting.model.ts index 65a181705..920c3480f 100644 --- a/shared/models/plugins/register-server-setting.model.ts +++ b/shared/models/plugins/register-server-setting.model.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | export interface RegisterServerSettingOptions { | 1 | export interface RegisterServerSettingOptions { |
2 | name: string | 2 | name: string |
3 | label: string | 3 | label: string |
4 | type: 'input' | 4 | type: 'input' | 'input-checkbox' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced' |
5 | 5 | ||
6 | // If the setting is not private, anyone can view its value (client code included) | 6 | // If the setting is not private, anyone can view its value (client code included) |
7 | // If the setting is private, only server-side hooks can access it | 7 | // If the setting is private, only server-side hooks can access it |
@@ -9,7 +9,7 @@ export interface RegisterServerSettingOptions { | |||
9 | private: boolean | 9 | private: boolean |
10 | 10 | ||
11 | // Default setting value | 11 | // Default setting value |
12 | default?: string | 12 | default?: string | boolean |
13 | } | 13 | } |
14 | 14 | ||
15 | export interface RegisteredServerSettings { | 15 | export interface RegisteredServerSettings { |
diff --git a/shared/models/plugins/server-hook.model.ts b/shared/models/plugins/server-hook.model.ts index 80ecd9e24..20f89b86d 100644 --- a/shared/models/plugins/server-hook.model.ts +++ b/shared/models/plugins/server-hook.model.ts | |||
@@ -70,7 +70,7 @@ export const serverActionHookObject = { | |||
70 | // Fired when a user is updated by an admin/moderator | 70 | // Fired when a user is updated by an admin/moderator |
71 | 'action:api.user.updated': true, | 71 | 'action:api.user.updated': true, |
72 | 72 | ||
73 | // Fired when a user got a new oauth2 token | 73 | // Fired when a user got a new oauth2 token |
74 | 'action:api.user.oauth2-got-token': true | 74 | 'action:api.user.oauth2-got-token': true |
75 | } | 75 | } |
76 | 76 | ||
diff --git a/shared/models/redundancy/index.ts b/shared/models/redundancy/index.ts index 61bf0fca7..649cc489f 100644 --- a/shared/models/redundancy/index.ts +++ b/shared/models/redundancy/index.ts | |||
@@ -1 +1,3 @@ | |||
1 | export * from './videos-redundancy.model' | 1 | export * from './videos-redundancy-strategy.model' |
2 | export * from './video-redundancies-filters.model' | ||
3 | export * from './video-redundancy.model' | ||
diff --git a/shared/models/redundancy/video-redundancies-filters.model.ts b/shared/models/redundancy/video-redundancies-filters.model.ts new file mode 100644 index 000000000..05ba7dfd3 --- /dev/null +++ b/shared/models/redundancy/video-redundancies-filters.model.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoRedundanciesTarget = 'my-videos' | 'remote-videos' | |||
diff --git a/shared/models/redundancy/video-redundancy-config-filter.type.ts b/shared/models/redundancy/video-redundancy-config-filter.type.ts new file mode 100644 index 000000000..bb1ae701c --- /dev/null +++ b/shared/models/redundancy/video-redundancy-config-filter.type.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoRedundancyConfigFilter = 'nobody' | 'anybody' | 'followings' | |||
diff --git a/shared/models/redundancy/video-redundancy.model.ts b/shared/models/redundancy/video-redundancy.model.ts new file mode 100644 index 000000000..fa6e05832 --- /dev/null +++ b/shared/models/redundancy/video-redundancy.model.ts | |||
@@ -0,0 +1,35 @@ | |||
1 | export interface VideoRedundancy { | ||
2 | id: number | ||
3 | name: string | ||
4 | url: string | ||
5 | uuid: string | ||
6 | |||
7 | redundancies: { | ||
8 | files: FileRedundancyInformation[] | ||
9 | |||
10 | streamingPlaylists: StreamingPlaylistRedundancyInformation[] | ||
11 | } | ||
12 | } | ||
13 | |||
14 | interface RedundancyInformation { | ||
15 | id: number | ||
16 | fileUrl: string | ||
17 | strategy: string | ||
18 | |||
19 | createdAt: Date | string | ||
20 | updatedAt: Date | string | ||
21 | |||
22 | expiresOn: Date | string | ||
23 | |||
24 | size: number | ||
25 | } | ||
26 | |||
27 | // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
28 | export interface FileRedundancyInformation extends RedundancyInformation { | ||
29 | |||
30 | } | ||
31 | |||
32 | // eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
33 | export interface StreamingPlaylistRedundancyInformation extends RedundancyInformation { | ||
34 | |||
35 | } | ||
diff --git a/shared/models/redundancy/videos-redundancy.model.ts b/shared/models/redundancy/videos-redundancy-strategy.model.ts index a8c2743c1..15409abf0 100644 --- a/shared/models/redundancy/videos-redundancy.model.ts +++ b/shared/models/redundancy/videos-redundancy-strategy.model.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | export type VideoRedundancyStrategy = 'most-views' | 'trending' | 'recently-added' | 1 | export type VideoRedundancyStrategy = 'most-views' | 'trending' | 'recently-added' |
2 | export type VideoRedundancyStrategyWithManual = VideoRedundancyStrategy | 'manual' | ||
2 | 3 | ||
3 | export type MostViewsRedundancyStrategy = { | 4 | export type MostViewsRedundancyStrategy = { |
4 | strategy: 'most-views' | 5 | strategy: 'most-views' |
@@ -19,4 +20,4 @@ export type RecentlyAddedStrategy = { | |||
19 | minLifetime: number | 20 | minLifetime: number |
20 | } | 21 | } |
21 | 22 | ||
22 | export type VideosRedundancy = MostViewsRedundancyStrategy | TrendingRedundancyStrategy | RecentlyAddedStrategy | 23 | export type VideosRedundancyStrategy = MostViewsRedundancyStrategy | TrendingRedundancyStrategy | RecentlyAddedStrategy |
diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts index 032b91a29..07e17bda2 100644 --- a/shared/models/server/custom-config.model.ts +++ b/shared/models/server/custom-config.model.ts | |||
@@ -97,7 +97,7 @@ export interface CustomConfig { | |||
97 | videos: { | 97 | videos: { |
98 | http: { | 98 | http: { |
99 | enabled: boolean | 99 | enabled: boolean |
100 | }, | 100 | } |
101 | torrent: { | 101 | torrent: { |
102 | enabled: boolean | 102 | enabled: boolean |
103 | } | 103 | } |
@@ -114,7 +114,7 @@ export interface CustomConfig { | |||
114 | 114 | ||
115 | followers: { | 115 | followers: { |
116 | instance: { | 116 | instance: { |
117 | enabled: boolean, | 117 | enabled: boolean |
118 | manualApproval: boolean | 118 | manualApproval: boolean |
119 | } | 119 | } |
120 | } | 120 | } |
diff --git a/shared/models/server/emailer.model.ts b/shared/models/server/emailer.model.ts new file mode 100644 index 000000000..069ef0bab --- /dev/null +++ b/shared/models/server/emailer.model.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | export type SendEmailOptions = { | ||
2 | to: string[] | ||
3 | |||
4 | template?: string | ||
5 | locals?: { [key: string]: any } | ||
6 | |||
7 | // override defaults | ||
8 | subject?: string | ||
9 | text?: string | ||
10 | from?: string | { name?: string, address: string } | ||
11 | replyTo?: string | ||
12 | } | ||
diff --git a/shared/models/server/index.ts b/shared/models/server/index.ts index bf61ab270..b0afb2c66 100644 --- a/shared/models/server/index.ts +++ b/shared/models/server/index.ts | |||
@@ -2,6 +2,7 @@ export * from './about.model' | |||
2 | export * from './contact-form.model' | 2 | export * from './contact-form.model' |
3 | export * from './custom-config.model' | 3 | export * from './custom-config.model' |
4 | export * from './debug.model' | 4 | export * from './debug.model' |
5 | export * from './emailer.model' | ||
5 | export * from './job.model' | 6 | export * from './job.model' |
6 | export * from './server-config.model' | 7 | export * from './server-config.model' |
7 | export * from './server-stats.model' | 8 | export * from './server-stats.model' |
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts index b82a633b2..57d61c480 100644 --- a/shared/models/server/job.model.ts +++ b/shared/models/server/job.model.ts | |||
@@ -1,23 +1,125 @@ | |||
1 | import { SendEmailOptions } from './emailer.model' | ||
2 | import { VideoResolution } from '@shared/models' | ||
3 | import { ContextType } from '../activitypub/context' | ||
4 | |||
1 | export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 5 | export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' |
2 | 6 | ||
3 | export type JobType = 'activitypub-http-unicast' | | 7 | export type JobType = |
4 | 'activitypub-http-broadcast' | | 8 | | 'activitypub-http-unicast' |
5 | 'activitypub-http-fetcher' | | 9 | | 'activitypub-http-broadcast' |
6 | 'activitypub-follow' | | 10 | | 'activitypub-http-fetcher' |
7 | 'video-file-import' | | 11 | | 'activitypub-follow' |
8 | 'video-transcoding' | | 12 | | 'video-file-import' |
9 | 'email' | | 13 | | 'video-transcoding' |
10 | 'video-import' | | 14 | | 'email' |
11 | 'videos-views' | | 15 | | 'video-import' |
12 | 'activitypub-refresher' | 16 | | 'videos-views' |
17 | | 'activitypub-refresher' | ||
18 | | 'video-redundancy' | ||
13 | 19 | ||
14 | export interface Job { | 20 | export interface Job { |
15 | id: number | 21 | id: number |
16 | state: JobState | 22 | state: JobState |
17 | type: JobType | 23 | type: JobType |
18 | data: any, | 24 | data: any |
19 | error: any, | 25 | error: any |
20 | createdAt: Date | string | 26 | createdAt: Date | string |
21 | finishedOn: Date | string | 27 | finishedOn: Date | string |
22 | processedOn: Date | string | 28 | processedOn: Date | string |
23 | } | 29 | } |
30 | |||
31 | export type ActivitypubHttpBroadcastPayload = { | ||
32 | uris: string[] | ||
33 | signatureActorId?: number | ||
34 | body: any | ||
35 | contextType?: ContextType | ||
36 | } | ||
37 | |||
38 | export type ActivitypubFollowPayload = { | ||
39 | followerActorId: number | ||
40 | name: string | ||
41 | host: string | ||
42 | isAutoFollow?: boolean | ||
43 | assertIsChannel?: boolean | ||
44 | } | ||
45 | |||
46 | export type FetchType = 'activity' | 'video-likes' | 'video-dislikes' | 'video-shares' | 'video-comments' | 'account-playlists' | ||
47 | export type ActivitypubHttpFetcherPayload = { | ||
48 | uri: string | ||
49 | type: FetchType | ||
50 | videoId?: number | ||
51 | accountId?: number | ||
52 | } | ||
53 | |||
54 | export type ActivitypubHttpUnicastPayload = { | ||
55 | uri: string | ||
56 | signatureActorId?: number | ||
57 | body: any | ||
58 | contextType?: ContextType | ||
59 | } | ||
60 | |||
61 | export type RefreshPayload = { | ||
62 | type: 'video' | 'video-playlist' | 'actor' | ||
63 | url: string | ||
64 | } | ||
65 | |||
66 | export type EmailPayload = SendEmailOptions | ||
67 | |||
68 | export type VideoFileImportPayload = { | ||
69 | videoUUID: string | ||
70 | filePath: string | ||
71 | } | ||
72 | |||
73 | export type VideoImportYoutubeDLPayload = { | ||
74 | type: 'youtube-dl' | ||
75 | videoImportId: number | ||
76 | |||
77 | generateThumbnail: boolean | ||
78 | generatePreview: boolean | ||
79 | |||
80 | fileExt?: string | ||
81 | } | ||
82 | export type VideoImportTorrentPayload = { | ||
83 | type: 'magnet-uri' | 'torrent-file' | ||
84 | videoImportId: number | ||
85 | } | ||
86 | export type VideoImportPayload = VideoImportYoutubeDLPayload | VideoImportTorrentPayload | ||
87 | |||
88 | export type VideoRedundancyPayload = { | ||
89 | videoId: number | ||
90 | } | ||
91 | |||
92 | // Video transcoding payloads | ||
93 | |||
94 | interface BaseTranscodingPayload { | ||
95 | videoUUID: string | ||
96 | isNewVideo?: boolean | ||
97 | } | ||
98 | |||
99 | interface HLSTranscodingPayload extends BaseTranscodingPayload { | ||
100 | type: 'hls' | ||
101 | isPortraitMode?: boolean | ||
102 | resolution: VideoResolution | ||
103 | copyCodecs: boolean | ||
104 | } | ||
105 | |||
106 | export interface NewResolutionTranscodingPayload extends BaseTranscodingPayload { | ||
107 | type: 'new-resolution' | ||
108 | isPortraitMode?: boolean | ||
109 | resolution: VideoResolution | ||
110 | } | ||
111 | |||
112 | export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload { | ||
113 | type: 'merge-audio' | ||
114 | resolution: VideoResolution | ||
115 | } | ||
116 | |||
117 | export interface OptimizeTranscodingPayload extends BaseTranscodingPayload { | ||
118 | type: 'optimize' | ||
119 | } | ||
120 | |||
121 | export type VideoTranscodingPayload = | ||
122 | HLSTranscodingPayload | ||
123 | | NewResolutionTranscodingPayload | ||
124 | | OptimizeTranscodingPayload | ||
125 | | MergeAudioTranscodingPayload | ||
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts index f1bb2153c..a1f9b3b5d 100644 --- a/shared/models/server/server-config.model.ts +++ b/shared/models/server/server-config.model.ts | |||
@@ -12,6 +12,22 @@ export interface ServerConfigTheme extends ServerConfigPlugin { | |||
12 | css: string[] | 12 | css: string[] |
13 | } | 13 | } |
14 | 14 | ||
15 | export interface RegisteredExternalAuthConfig { | ||
16 | npmName: string | ||
17 | name: string | ||
18 | version: string | ||
19 | authName: string | ||
20 | authDisplayName: string | ||
21 | } | ||
22 | |||
23 | export interface RegisteredIdAndPassAuthConfig { | ||
24 | npmName: string | ||
25 | name: string | ||
26 | version: string | ||
27 | authName: string | ||
28 | weight: number | ||
29 | } | ||
30 | |||
15 | export interface ServerConfig { | 31 | export interface ServerConfig { |
16 | serverVersion: string | 32 | serverVersion: string |
17 | serverCommit?: string | 33 | serverCommit?: string |
@@ -28,8 +44,19 @@ export interface ServerConfig { | |||
28 | } | 44 | } |
29 | } | 45 | } |
30 | 46 | ||
47 | search: { | ||
48 | remoteUri: { | ||
49 | users: boolean | ||
50 | anonymous: boolean | ||
51 | } | ||
52 | } | ||
53 | |||
31 | plugin: { | 54 | plugin: { |
32 | registered: ServerConfigPlugin[] | 55 | registered: ServerConfigPlugin[] |
56 | |||
57 | registeredExternalAuths: RegisteredExternalAuthConfig[] | ||
58 | |||
59 | registeredIdAndPassAuths: RegisteredIdAndPassAuthConfig[] | ||
33 | } | 60 | } |
34 | 61 | ||
35 | theme: { | 62 | theme: { |
@@ -46,7 +73,7 @@ export interface ServerConfig { | |||
46 | } | 73 | } |
47 | 74 | ||
48 | signup: { | 75 | signup: { |
49 | allowed: boolean, | 76 | allowed: boolean |
50 | allowedForCurrentIP: boolean | 77 | allowedForCurrentIP: boolean |
51 | requiresEmailVerification: boolean | 78 | requiresEmailVerification: boolean |
52 | } | 79 | } |
@@ -97,7 +124,7 @@ export interface ServerConfig { | |||
97 | max: number | 124 | max: number |
98 | } | 125 | } |
99 | extensions: string[] | 126 | extensions: string[] |
100 | }, | 127 | } |
101 | file: { | 128 | file: { |
102 | extensions: string[] | 129 | extensions: string[] |
103 | } | 130 | } |
@@ -107,7 +134,7 @@ export interface ServerConfig { | |||
107 | file: { | 134 | file: { |
108 | size: { | 135 | size: { |
109 | max: number | 136 | max: number |
110 | }, | 137 | } |
111 | extensions: string[] | 138 | extensions: string[] |
112 | } | 139 | } |
113 | } | 140 | } |
diff --git a/shared/models/server/server-stats.model.ts b/shared/models/server/server-stats.model.ts index 74f3de5d3..75d7dc554 100644 --- a/shared/models/server/server-stats.model.ts +++ b/shared/models/server/server-stats.model.ts | |||
@@ -1,7 +1,11 @@ | |||
1 | import { VideoRedundancyStrategy } from '../redundancy' | 1 | import { VideoRedundancyStrategyWithManual } from '../redundancy' |
2 | 2 | ||
3 | export interface ServerStats { | 3 | export interface ServerStats { |
4 | totalUsers: number | 4 | totalUsers: number |
5 | totalDailyActiveUsers: number | ||
6 | totalWeeklyActiveUsers: number | ||
7 | totalMonthlyActiveUsers: number | ||
8 | |||
5 | totalLocalVideos: number | 9 | totalLocalVideos: number |
6 | totalLocalVideoViews: number | 10 | totalLocalVideoViews: number |
7 | totalLocalVideoComments: number | 11 | totalLocalVideoComments: number |
@@ -13,11 +17,13 @@ export interface ServerStats { | |||
13 | totalInstanceFollowers: number | 17 | totalInstanceFollowers: number |
14 | totalInstanceFollowing: number | 18 | totalInstanceFollowing: number |
15 | 19 | ||
16 | videosRedundancy: { | 20 | videosRedundancy: VideosRedundancyStats[] |
17 | strategy: VideoRedundancyStrategy | 21 | } |
18 | totalSize: number | 22 | |
19 | totalUsed: number | 23 | export interface VideosRedundancyStats { |
20 | totalVideoFiles: number | 24 | strategy: VideoRedundancyStrategyWithManual |
21 | totalVideos: number | 25 | totalSize: number |
22 | }[] | 26 | totalUsed: number |
27 | totalVideoFiles: number | ||
28 | totalVideos: number | ||
23 | } | 29 | } |
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts index 4a28a229d..2f88a65de 100644 --- a/shared/models/users/user-right.enum.ts +++ b/shared/models/users/user-right.enum.ts | |||
@@ -33,5 +33,7 @@ export enum UserRight { | |||
33 | SEE_ALL_VIDEOS, | 33 | SEE_ALL_VIDEOS, |
34 | CHANGE_VIDEO_OWNERSHIP, | 34 | CHANGE_VIDEO_OWNERSHIP, |
35 | 35 | ||
36 | MANAGE_PLUGINS | 36 | MANAGE_PLUGINS, |
37 | |||
38 | MANAGE_VIDEOS_REDUNDANCIES | ||
37 | } | 39 | } |
diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts index 0b6554e51..2b08b5850 100644 --- a/shared/models/users/user-role.ts +++ b/shared/models/users/user-role.ts | |||
@@ -7,15 +7,13 @@ export enum UserRole { | |||
7 | USER = 2 | 7 | USER = 2 |
8 | } | 8 | } |
9 | 9 | ||
10 | // TODO: use UserRole for key once https://github.com/Microsoft/TypeScript/issues/13042 is fixed | 10 | export const USER_ROLE_LABELS: { [ id in UserRole ]: string } = { |
11 | export const USER_ROLE_LABELS: { [ id: number ]: string } = { | ||
12 | [UserRole.USER]: 'User', | 11 | [UserRole.USER]: 'User', |
13 | [UserRole.MODERATOR]: 'Moderator', | 12 | [UserRole.MODERATOR]: 'Moderator', |
14 | [UserRole.ADMINISTRATOR]: 'Administrator' | 13 | [UserRole.ADMINISTRATOR]: 'Administrator' |
15 | } | 14 | } |
16 | 15 | ||
17 | // TODO: use UserRole for key once https://github.com/Microsoft/TypeScript/issues/13042 is fixed | 16 | const userRoleRights: { [ id in UserRole ]: UserRight[] } = { |
18 | const userRoleRights: { [ id: number ]: UserRight[] } = { | ||
19 | [UserRole.ADMINISTRATOR]: [ | 17 | [UserRole.ADMINISTRATOR]: [ |
20 | UserRight.ALL | 18 | UserRight.ALL |
21 | ], | 19 | ], |
@@ -40,5 +38,5 @@ const userRoleRights: { [ id: number ]: UserRight[] } = { | |||
40 | export function hasUserRight (userRole: UserRole, userRight: UserRight) { | 38 | export function hasUserRight (userRole: UserRole, userRight: UserRight) { |
41 | const userRights = userRoleRights[userRole] | 39 | const userRights = userRoleRights[userRole] |
42 | 40 | ||
43 | return userRights.indexOf(UserRight.ALL) !== -1 || userRights.indexOf(userRight) !== -1 | 41 | return userRights.includes(UserRight.ALL) || userRights.includes(userRight) |
44 | } | 42 | } |
diff --git a/shared/models/users/user.model.ts b/shared/models/users/user.model.ts index 168851196..6c959ceea 100644 --- a/shared/models/users/user.model.ts +++ b/shared/models/users/user.model.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { Account } from '../actors' | 1 | import { Account } from '../actors' |
2 | import { VideoChannel } from '../videos/channel/video-channel.model' | 2 | import { VideoChannel } from '../videos/channel/video-channel.model' |
3 | import { VideoPlaylist } from '../videos/playlist/video-playlist.model' | ||
4 | import { UserRole } from './user-role' | 3 | import { UserRole } from './user-role' |
5 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' | 4 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' |
6 | import { UserNotificationSetting } from './user-notification-setting.model' | 5 | import { UserNotificationSetting } from './user-notification-setting.model' |
@@ -32,6 +31,11 @@ export interface User { | |||
32 | videoQuotaDaily: number | 31 | videoQuotaDaily: number |
33 | videoQuotaUsed?: number | 32 | videoQuotaUsed?: number |
34 | videoQuotaUsedDaily?: number | 33 | videoQuotaUsedDaily?: number |
34 | videosCount?: number | ||
35 | videoAbusesCount?: number | ||
36 | videoAbusesAcceptedCount?: number | ||
37 | videoAbusesCreatedCount?: number | ||
38 | videoCommentsCount? : number | ||
35 | 39 | ||
36 | theme: string | 40 | theme: string |
37 | 41 | ||
@@ -46,6 +50,10 @@ export interface User { | |||
46 | noWelcomeModal: boolean | 50 | noWelcomeModal: boolean |
47 | 51 | ||
48 | createdAt: Date | 52 | createdAt: Date |
53 | |||
54 | pluginAuth: string | null | ||
55 | |||
56 | lastLoginDate: Date | null | ||
49 | } | 57 | } |
50 | 58 | ||
51 | export interface MyUserSpecialPlaylist { | 59 | export interface MyUserSpecialPlaylist { |
diff --git a/shared/models/videos/abuse/video-abuse-video-is.type.ts b/shared/models/videos/abuse/video-abuse-video-is.type.ts new file mode 100644 index 000000000..e86018993 --- /dev/null +++ b/shared/models/videos/abuse/video-abuse-video-is.type.ts | |||
@@ -0,0 +1 @@ | |||
export type VideoAbuseVideoIs = 'deleted' | 'blacklisted' | |||
diff --git a/shared/models/videos/abuse/video-abuse.model.ts b/shared/models/videos/abuse/video-abuse.model.ts index 4f668795a..f2c2cdc41 100644 --- a/shared/models/videos/abuse/video-abuse.model.ts +++ b/shared/models/videos/abuse/video-abuse.model.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { Account } from '../../actors/index' | 1 | import { Account } from '../../actors/index' |
2 | import { VideoConstant } from '../video-constant.model' | 2 | import { VideoConstant } from '../video-constant.model' |
3 | import { VideoAbuseState } from './video-abuse-state.model' | 3 | import { VideoAbuseState } from './video-abuse-state.model' |
4 | import { VideoChannel } from '../channel/video-channel.model' | ||
4 | 5 | ||
5 | export interface VideoAbuse { | 6 | export interface VideoAbuse { |
6 | id: number | 7 | id: number |
@@ -14,7 +15,19 @@ export interface VideoAbuse { | |||
14 | id: number | 15 | id: number |
15 | name: string | 16 | name: string |
16 | uuid: string | 17 | uuid: string |
18 | nsfw: boolean | ||
19 | deleted: boolean | ||
20 | blacklisted: boolean | ||
21 | thumbnailPath?: string | ||
22 | channel?: VideoChannel | ||
17 | } | 23 | } |
18 | 24 | ||
19 | createdAt: Date | 25 | createdAt: Date |
26 | updatedAt: Date | ||
27 | |||
28 | count?: number | ||
29 | nth?: number | ||
30 | |||
31 | countReportsForReporter?: number | ||
32 | countReportsForReportee?: number | ||
20 | } | 33 | } |
diff --git a/shared/models/videos/blacklist/video-blacklist.model.ts b/shared/models/videos/blacklist/video-blacklist.model.ts index 68d59e489..a6e0ef175 100644 --- a/shared/models/videos/blacklist/video-blacklist.model.ts +++ b/shared/models/videos/blacklist/video-blacklist.model.ts | |||
@@ -7,11 +7,12 @@ export enum VideoBlacklistType { | |||
7 | 7 | ||
8 | export interface VideoBlacklist { | 8 | export interface VideoBlacklist { |
9 | id: number | 9 | id: number |
10 | createdAt: Date | ||
11 | updatedAt: Date | ||
12 | unfederated: boolean | 10 | unfederated: boolean |
13 | reason?: string | 11 | reason?: string |
14 | type: VideoBlacklistType | 12 | type: VideoBlacklistType |
15 | 13 | ||
16 | video: Video | 14 | video: Video |
15 | |||
16 | createdAt: Date | ||
17 | updatedAt: Date | ||
17 | } | 18 | } |
diff --git a/shared/models/videos/channel/video-channel.model.ts b/shared/models/videos/channel/video-channel.model.ts index de4c26b3d..421004e68 100644 --- a/shared/models/videos/channel/video-channel.model.ts +++ b/shared/models/videos/channel/video-channel.model.ts | |||
@@ -2,12 +2,18 @@ import { Actor } from '../../actors/actor.model' | |||
2 | import { Account } from '../../actors/index' | 2 | import { Account } from '../../actors/index' |
3 | import { Avatar } from '../../avatars' | 3 | import { Avatar } from '../../avatars' |
4 | 4 | ||
5 | export type ViewsPerDate = { | ||
6 | date: Date | ||
7 | views: number | ||
8 | } | ||
9 | |||
5 | export interface VideoChannel extends Actor { | 10 | export interface VideoChannel extends Actor { |
6 | displayName: string | 11 | displayName: string |
7 | description: string | 12 | description: string |
8 | support: string | 13 | support: string |
9 | isLocal: boolean | 14 | isLocal: boolean |
10 | ownerAccount?: Account | 15 | ownerAccount?: Account |
16 | viewsPerDay?: ViewsPerDate[] // chronologically ordered | ||
11 | } | 17 | } |
12 | 18 | ||
13 | export interface VideoChannelSummary { | 19 | export interface VideoChannelSummary { |
diff --git a/shared/models/videos/video-file-metadata.ts b/shared/models/videos/video-file-metadata.ts new file mode 100644 index 000000000..15683cacf --- /dev/null +++ b/shared/models/videos/video-file-metadata.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | import { FfprobeData } from "fluent-ffmpeg" | ||
2 | import { DeepOmit } from "@server/models/utils" | ||
3 | |||
4 | export type VideoFileMetadataModel = DeepOmit<FfprobeData, 'filename'> | ||
5 | |||
6 | export class VideoFileMetadata implements VideoFileMetadataModel { | ||
7 | streams: { [x: string]: any, [x: number]: any }[] | ||
8 | format: { [x: string]: any, [x: number]: any } | ||
9 | chapters: any[] | ||
10 | |||
11 | constructor (hash: Partial<VideoFileMetadataModel>) { | ||
12 | this.chapters = hash.chapters | ||
13 | this.format = hash.format | ||
14 | this.streams = hash.streams | ||
15 | |||
16 | delete this.format.filename | ||
17 | } | ||
18 | } | ||
diff --git a/shared/models/videos/video-file.model.ts b/shared/models/videos/video-file.model.ts index 04da0627e..6cc2d5aee 100644 --- a/shared/models/videos/video-file.model.ts +++ b/shared/models/videos/video-file.model.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { VideoConstant, VideoResolution } from '@shared/models' | 1 | import { VideoConstant, VideoResolution } from '@shared/models' |
2 | import { FfprobeData } from 'fluent-ffmpeg' | ||
2 | 3 | ||
3 | export interface VideoFile { | 4 | export interface VideoFile { |
4 | magnetUri: string | 5 | magnetUri: string |
@@ -9,4 +10,6 @@ export interface VideoFile { | |||
9 | fileUrl: string | 10 | fileUrl: string |
10 | fileDownloadUrl: string | 11 | fileDownloadUrl: string |
11 | fps: number | 12 | fps: number |
13 | metadata?: FfprobeData | ||
14 | metadataUrl?: string | ||
12 | } | 15 | } |
diff --git a/shared/models/videos/video-transcoding-fps.model.ts b/shared/models/videos/video-transcoding-fps.model.ts index 82022d2f1..25fc1c2da 100644 --- a/shared/models/videos/video-transcoding-fps.model.ts +++ b/shared/models/videos/video-transcoding-fps.model.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | export type VideoTranscodingFPS = { | 1 | export type VideoTranscodingFPS = { |
2 | MIN: number, | 2 | MIN: number |
3 | AVERAGE: number, | 3 | STANDARD: number[] |
4 | MAX: number, | 4 | HD_STANDARD: number[] |
5 | AVERAGE: number | ||
6 | MAX: number | ||
5 | KEEP_ORIGIN_FPS_RESOLUTION_MIN: number | 7 | KEEP_ORIGIN_FPS_RESOLUTION_MIN: number |
6 | } | 8 | } |
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 7576439fe..a69152759 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { AccountSummary, VideoChannelSummary, VideoResolution, VideoState } from '../../index' | 1 | import { AccountSummary, VideoChannelSummary, VideoState } from '../../index' |
2 | import { Account } from '../actors' | 2 | import { Account } from '../actors' |
3 | import { VideoChannel } from './channel/video-channel.model' | 3 | import { VideoChannel } from './channel/video-channel.model' |
4 | import { VideoPrivacy } from './video-privacy.enum' | 4 | import { VideoPrivacy } from './video-privacy.enum' |