From 2243730c8edf210c0a3ffc161bac89785f6a52f0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Apr 2018 14:52:10 +0200 Subject: Add information concerning video privacy in my videos list --- server/initializers/constants.ts | 2 +- server/models/video/video.ts | 19 +++++++++++-------- server/tests/utils/videos/videos.ts | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'server') 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 = { get DESCRIPTION () { return config.get('instance.description') }, get TERMS () { return config.get('instance.terms') }, get DEFAULT_CLIENT_ROUTE () { return config.get('instance.default_client_route') }, - get DEFAULT_NSFW_POLICY () { return config.get('instance.default_nsfw_policy') }, + get NSFW_POLICY () { return config.get('instance.default_nsfw_policy') }, CUSTOMIZATIONS: { get JAVASCRIPT () { return config.get('instance.customizations.javascript') }, get CSS () { return config.get('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 { return languageLabel } + private static getPrivacyLabel (id: number) { + let privacyLabel = VIDEO_PRIVACIES[id] + if (!privacyLabel) privacyLabel = 'Unknown' + + return privacyLabel + } + getOriginalFile () { if (Array.isArray(this.VideoFiles) === false) return undefined @@ -990,6 +997,10 @@ export class VideoModel extends Model { id: this.language, label: VideoModel.getLanguageLabel(this.language) }, + privacy: { + id: this.privacy, + label: VideoModel.getPrivacyLabel(this.privacy) + }, nsfw: this.nsfw, description: this.getTruncatedDescription(), isLocal: this.isOwned(), @@ -1016,15 +1027,7 @@ export class VideoModel extends Model { toFormattedDetailsJSON (): VideoDetails { const formattedJson = this.toFormattedJSON() - // Maybe our server is not up to date and there are new privacy settings since our version - let privacyLabel = VIDEO_PRIVACIES[this.privacy] - if (!privacyLabel) privacyLabel = 'Unknown' - const detailsJson = { - privacy: { - id: this.privacy, - label: privacyLabel - }, support: this.support, descriptionPath: this.getDescriptionPath(), 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 ( expect(video.licence.label).to.equal(VIDEO_LICENCES[attributes.licence] || 'Unknown') expect(video.language.id).to.equal(attributes.language) expect(video.language.label).to.equal(VIDEO_LANGUAGES[attributes.language] || 'Unknown') + expect(video.privacy.id).to.deep.equal(attributes.privacy) + expect(video.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy]) expect(video.nsfw).to.equal(attributes.nsfw) expect(video.description).to.equal(attributes.description) expect(video.account.host).to.equal(attributes.account.host) @@ -459,8 +461,6 @@ async function completeVideoCheck ( expect(videoDetails.files).to.have.lengthOf(attributes.files.length) expect(videoDetails.tags).to.deep.equal(attributes.tags) - expect(videoDetails.privacy.id).to.deep.equal(attributes.privacy) - expect(videoDetails.privacy.label).to.deep.equal(VIDEO_PRIVACIES[attributes.privacy]) expect(videoDetails.account.name).to.equal(attributes.account.name) expect(videoDetails.account.host).to.equal(attributes.account.host) expect(videoDetails.commentsEnabled).to.equal(attributes.commentsEnabled) -- cgit v1.2.3