diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/initializers/constants.ts | 2 | ||||
-rw-r--r-- | server/models/video/video.ts | 19 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 4 |
3 files changed, 14 insertions, 11 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index d1915586a..fb436366c 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -168,7 +168,7 @@ const CONFIG = { | |||
168 | get DESCRIPTION () { return config.get<string>('instance.description') }, | 168 | get DESCRIPTION () { return config.get<string>('instance.description') }, |
169 | get TERMS () { return config.get<string>('instance.terms') }, | 169 | get TERMS () { return config.get<string>('instance.terms') }, |
170 | get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') }, | 170 | get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') }, |
171 | get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') }, | 171 | get NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') }, |
172 | CUSTOMIZATIONS: { | 172 | CUSTOMIZATIONS: { |
173 | get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') }, | 173 | get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') }, |
174 | get CSS () { return config.get<string>('instance.customizations.css') } | 174 | get CSS () { return config.get<string>('instance.customizations.css') } |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 2e66f9aa7..c08d18b71 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -884,6 +884,13 @@ export class VideoModel extends Model<VideoModel> { | |||
884 | return languageLabel | 884 | return languageLabel |
885 | } | 885 | } |
886 | 886 | ||
887 | private static getPrivacyLabel (id: number) { | ||
888 | let privacyLabel = VIDEO_PRIVACIES[id] | ||
889 | if (!privacyLabel) privacyLabel = 'Unknown' | ||
890 | |||
891 | return privacyLabel | ||
892 | } | ||
893 | |||
887 | getOriginalFile () { | 894 | getOriginalFile () { |
888 | if (Array.isArray(this.VideoFiles) === false) return undefined | 895 | if (Array.isArray(this.VideoFiles) === false) return undefined |
889 | 896 | ||
@@ -990,6 +997,10 @@ export class VideoModel extends Model<VideoModel> { | |||
990 | id: this.language, | 997 | id: this.language, |
991 | label: VideoModel.getLanguageLabel(this.language) | 998 | label: VideoModel.getLanguageLabel(this.language) |
992 | }, | 999 | }, |
1000 | privacy: { | ||
1001 | id: this.privacy, | ||
1002 | label: VideoModel.getPrivacyLabel(this.privacy) | ||
1003 | }, | ||
993 | nsfw: this.nsfw, | 1004 | nsfw: this.nsfw, |
994 | description: this.getTruncatedDescription(), | 1005 | description: this.getTruncatedDescription(), |
995 | isLocal: this.isOwned(), | 1006 | isLocal: this.isOwned(), |
@@ -1016,15 +1027,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1016 | toFormattedDetailsJSON (): VideoDetails { | 1027 | toFormattedDetailsJSON (): VideoDetails { |
1017 | const formattedJson = this.toFormattedJSON() | 1028 | const formattedJson = this.toFormattedJSON() |
1018 | 1029 | ||
1019 | // Maybe our server is not up to date and there are new privacy settings since our version | ||
1020 | let privacyLabel = VIDEO_PRIVACIES[this.privacy] | ||
1021 | if (!privacyLabel) privacyLabel = 'Unknown' | ||
1022 | |||
1023 | const detailsJson = { | 1030 | const detailsJson = { |
1024 | privacy: { | ||
1025 | id: this.privacy, | ||
1026 | label: privacyLabel | ||
1027 | }, | ||
1028 | support: this.support, | 1031 | support: this.support, |
1029 | descriptionPath: this.getDescriptionPath(), | 1032 | descriptionPath: this.getDescriptionPath(), |
1030 | channel: this.VideoChannel.toFormattedJSON(), | 1033 | channel: this.VideoChannel.toFormattedJSON(), |
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index df9071c29..5e186147e 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -442,6 +442,8 @@ async function completeVideoCheck ( | |||
442 | expect(video.licence.label).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown') | 442 | expect(video.licence.label).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown') |
443 | expect(video.language.id).to.equal(attributes.language) | 443 | expect(video.language.id).to.equal(attributes.language) |
444 | expect(video.language.label).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown') | 444 | expect(video.language.label).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown') |
445 | expect(video.privacy.id).to.deep.equal(attributes.privacy) | ||
446 | expect(video.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy]) | ||
445 | expect(video.nsfw).to.equal(attributes.nsfw) | 447 | expect(video.nsfw).to.equal(attributes.nsfw) |
446 | expect(video.description).to.equal(attributes.description) | 448 | expect(video.description).to.equal(attributes.description) |
447 | expect(video.account.host).to.equal(attributes.account.host) | 449 | expect(video.account.host).to.equal(attributes.account.host) |
@@ -459,8 +461,6 @@ async function completeVideoCheck ( | |||
459 | 461 | ||
460 | expect(videoDetails.files).to.have.lengthOf(attributes.files.length) | 462 | expect(videoDetails.files).to.have.lengthOf(attributes.files.length) |
461 | expect(videoDetails.tags).to.deep.equal(attributes.tags) | 463 | expect(videoDetails.tags).to.deep.equal(attributes.tags) |
462 | expect(videoDetails.privacy.id).to.deep.equal(attributes.privacy) | ||
463 | expect(videoDetails.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy]) | ||
464 | expect(videoDetails.account.name).to.equal(attributes.account.name) | 464 | expect(videoDetails.account.name).to.equal(attributes.account.name) |
465 | expect(videoDetails.account.host).to.equal(attributes.account.host) | 465 | expect(videoDetails.account.host).to.equal(attributes.account.host) |
466 | expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled) | 466 | expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled) |