diff options
-rw-r--r-- | client/src/app/account/account-videos/account-videos.component.html | 1 | ||||
-rw-r--r-- | client/src/app/account/account-videos/account-videos.component.scss | 6 | ||||
-rw-r--r-- | client/src/app/core/auth/auth-user.model.ts | 8 | ||||
-rw-r--r-- | client/src/app/shared/video/video-details.model.ts | 11 | ||||
-rw-r--r-- | client/src/app/shared/video/video.model.ts | 4 | ||||
-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 | ||||
-rw-r--r-- | shared/models/videos/video.model.ts | 2 |
9 files changed, 29 insertions, 28 deletions
diff --git a/client/src/app/account/account-videos/account-videos.component.html b/client/src/app/account/account-videos/account-videos.component.html index d7e2230b0..66ce3a77b 100644 --- a/client/src/app/account/account-videos/account-videos.component.html +++ b/client/src/app/account/account-videos/account-videos.component.html | |||
@@ -18,6 +18,7 @@ | |||
18 | <div class="video-info"> | 18 | <div class="video-info"> |
19 | <a class="video-info-name" [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name">{{ video.name }}</a> | 19 | <a class="video-info-name" [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name">{{ video.name }}</a> |
20 | <span class="video-info-date-views">{{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> | 20 | <span class="video-info-date-views">{{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span> |
21 | <div class="video-info-private">{{ video.privacy.label }}</div> | ||
21 | </div> | 22 | </div> |
22 | 23 | ||
23 | <!-- Display only once --> | 24 | <!-- Display only once --> |
diff --git a/client/src/app/account/account-videos/account-videos.component.scss b/client/src/app/account/account-videos/account-videos.component.scss index 449cc6af4..f276ea389 100644 --- a/client/src/app/account/account-videos/account-videos.component.scss +++ b/client/src/app/account/account-videos/account-videos.component.scss | |||
@@ -79,8 +79,12 @@ | |||
79 | font-weight: $font-semibold; | 79 | font-weight: $font-semibold; |
80 | } | 80 | } |
81 | 81 | ||
82 | .video-info-date-views { | 82 | .video-info-date-views, .video-info-private { |
83 | font-size: 13px; | 83 | font-size: 13px; |
84 | |||
85 | &.video-info-private { | ||
86 | font-weight: $font-semibold; | ||
87 | } | ||
84 | } | 88 | } |
85 | } | 89 | } |
86 | 90 | ||
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts index 60fe57899..74ed1c580 100644 --- a/client/src/app/core/auth/auth-user.model.ts +++ b/client/src/app/core/auth/auth-user.model.ts | |||
@@ -71,7 +71,7 @@ export class AuthUser extends User { | |||
71 | ROLE: 'role', | 71 | ROLE: 'role', |
72 | EMAIL: 'email', | 72 | EMAIL: 'email', |
73 | USERNAME: 'username', | 73 | USERNAME: 'username', |
74 | DEFAULT_NSFW_POLICY: 'nsfw_policy', | 74 | NSFW_POLICY: 'nsfw_policy', |
75 | AUTO_PLAY_VIDEO: 'auto_play_video' | 75 | AUTO_PLAY_VIDEO: 'auto_play_video' |
76 | } | 76 | } |
77 | 77 | ||
@@ -86,7 +86,7 @@ export class AuthUser extends User { | |||
86 | username: peertubeLocalStorage.getItem(this.KEYS.USERNAME), | 86 | username: peertubeLocalStorage.getItem(this.KEYS.USERNAME), |
87 | email: peertubeLocalStorage.getItem(this.KEYS.EMAIL), | 87 | email: peertubeLocalStorage.getItem(this.KEYS.EMAIL), |
88 | role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole, | 88 | role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole, |
89 | nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.DEFAULT_NSFW_POLICY) as NSFWPolicyType, | 89 | nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.NSFW_POLICY) as NSFWPolicyType, |
90 | autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true' | 90 | autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true' |
91 | }, | 91 | }, |
92 | Tokens.load() | 92 | Tokens.load() |
@@ -100,7 +100,7 @@ export class AuthUser extends User { | |||
100 | peertubeLocalStorage.removeItem(this.KEYS.USERNAME) | 100 | peertubeLocalStorage.removeItem(this.KEYS.USERNAME) |
101 | peertubeLocalStorage.removeItem(this.KEYS.ID) | 101 | peertubeLocalStorage.removeItem(this.KEYS.ID) |
102 | peertubeLocalStorage.removeItem(this.KEYS.ROLE) | 102 | peertubeLocalStorage.removeItem(this.KEYS.ROLE) |
103 | peertubeLocalStorage.removeItem(this.KEYS.DEFAULT_NSFW_POLICY) | 103 | peertubeLocalStorage.removeItem(this.KEYS.NSFW_POLICY) |
104 | peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO) | 104 | peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO) |
105 | peertubeLocalStorage.removeItem(this.KEYS.EMAIL) | 105 | peertubeLocalStorage.removeItem(this.KEYS.EMAIL) |
106 | Tokens.flush() | 106 | Tokens.flush() |
@@ -137,7 +137,7 @@ export class AuthUser extends User { | |||
137 | peertubeLocalStorage.setItem(AuthUser.KEYS.USERNAME, this.username) | 137 | peertubeLocalStorage.setItem(AuthUser.KEYS.USERNAME, this.username) |
138 | peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email) | 138 | peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email) |
139 | peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString()) | 139 | peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString()) |
140 | peertubeLocalStorage.setItem(AuthUser.KEYS.DEFAULT_NSFW_POLICY, this.nsfwPolicy.toString()) | 140 | peertubeLocalStorage.setItem(AuthUser.KEYS.NSFW_POLICY, this.nsfwPolicy.toString()) |
141 | peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) | 141 | peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) |
142 | this.tokens.save() | 142 | this.tokens.save() |
143 | } | 143 | } |
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts index a1f7207a2..5397aa37f 100644 --- a/client/src/app/shared/video/video-details.model.ts +++ b/client/src/app/shared/video/video-details.model.ts | |||
@@ -1,17 +1,9 @@ | |||
1 | import { | 1 | import { UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile } from '../../../../../shared' |
2 | UserRight, | ||
3 | VideoChannel, | ||
4 | VideoDetails as VideoDetailsServerModel, | ||
5 | VideoFile, | ||
6 | VideoPrivacy | ||
7 | } from '../../../../../shared' | ||
8 | import { Account } from '../../../../../shared/models/actors' | 2 | import { Account } from '../../../../../shared/models/actors' |
9 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' | ||
10 | import { AuthUser } from '../../core' | 3 | import { AuthUser } from '../../core' |
11 | import { Video } from '../../shared/video/video.model' | 4 | import { Video } from '../../shared/video/video.model' |
12 | 5 | ||
13 | export class VideoDetails extends Video implements VideoDetailsServerModel { | 6 | export class VideoDetails extends Video implements VideoDetailsServerModel { |
14 | privacy: VideoConstant<VideoPrivacy> | ||
15 | descriptionPath: string | 7 | descriptionPath: string |
16 | support: string | 8 | support: string |
17 | channel: VideoChannel | 9 | channel: VideoChannel |
@@ -26,7 +18,6 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { | |||
26 | constructor (hash: VideoDetailsServerModel) { | 18 | constructor (hash: VideoDetailsServerModel) { |
27 | super(hash) | 19 | super(hash) |
28 | 20 | ||
29 | this.privacy = hash.privacy | ||
30 | this.descriptionPath = hash.descriptionPath | 21 | this.descriptionPath = hash.descriptionPath |
31 | this.files = hash.files | 22 | this.files = hash.files |
32 | this.channel = hash.channel | 23 | this.channel = hash.channel |
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index adc248a1e..e25c172e0 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Account } from '@app/shared/account/account.model' | 1 | import { Account } from '@app/shared/account/account.model' |
2 | import { User } from '../' | 2 | import { User } from '../' |
3 | import { Video as VideoServerModel } from '../../../../../shared' | 3 | import { Video as VideoServerModel, VideoPrivacy } from '../../../../../shared' |
4 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' | 4 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' |
5 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' | 5 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' |
6 | import { getAbsoluteAPIUrl } from '../misc/utils' | 6 | import { getAbsoluteAPIUrl } from '../misc/utils' |
@@ -14,6 +14,7 @@ export class Video implements VideoServerModel { | |||
14 | category: VideoConstant<number> | 14 | category: VideoConstant<number> |
15 | licence: VideoConstant<number> | 15 | licence: VideoConstant<number> |
16 | language: VideoConstant<number> | 16 | language: VideoConstant<number> |
17 | privacy: VideoConstant<VideoPrivacy> | ||
17 | description: string | 18 | description: string |
18 | duration: number | 19 | duration: number |
19 | durationLabel: string | 20 | durationLabel: string |
@@ -62,6 +63,7 @@ export class Video implements VideoServerModel { | |||
62 | this.category = hash.category | 63 | this.category = hash.category |
63 | this.licence = hash.licence | 64 | this.licence = hash.licence |
64 | this.language = hash.language | 65 | this.language = hash.language |
66 | this.privacy = hash.privacy | ||
65 | this.description = hash.description | 67 | this.description = hash.description |
66 | this.duration = hash.duration | 68 | this.duration = hash.duration |
67 | this.durationLabel = Video.createDurationString(hash.duration) | 69 | this.durationLabel = Video.createDurationString(hash.duration) |
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) |
diff --git a/shared/models/videos/video.model.ts b/shared/models/videos/video.model.ts index 1b5f1a09c..70132c050 100644 --- a/shared/models/videos/video.model.ts +++ b/shared/models/videos/video.model.ts | |||
@@ -26,6 +26,7 @@ export interface Video { | |||
26 | category: VideoConstant<number> | 26 | category: VideoConstant<number> |
27 | licence: VideoConstant<number> | 27 | licence: VideoConstant<number> |
28 | language: VideoConstant<number> | 28 | language: VideoConstant<number> |
29 | privacy: VideoConstant<VideoPrivacy> | ||
29 | description: string | 30 | description: string |
30 | duration: number | 31 | duration: number |
31 | isLocal: boolean | 32 | isLocal: boolean |
@@ -48,7 +49,6 @@ export interface Video { | |||
48 | } | 49 | } |
49 | 50 | ||
50 | export interface VideoDetails extends Video { | 51 | export interface VideoDetails extends Video { |
51 | privacy: VideoConstant<VideoPrivacy> | ||
52 | descriptionPath: string | 52 | descriptionPath: string |
53 | support: string | 53 | support: string |
54 | channel: VideoChannel | 54 | channel: VideoChannel |