diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-15 14:46:26 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-15 15:29:07 +0100 |
commit | 2422c46b27790d94fd29a7092170cee5a1b56008 (patch) | |
tree | d5c1942ce20cadb27a551d87c789edfe92f5b105 /server/models/video/video.ts | |
parent | 34cbef8c6cc912143a421413bdd832c4adcc556a (diff) | |
download | PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.gz PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.zst PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.zip |
Implement support field in video and video channel
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index ff82fb3b2..d748e81bd 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -40,7 +40,7 @@ import { | |||
40 | isVideoLanguageValid, | 40 | isVideoLanguageValid, |
41 | isVideoLicenceValid, | 41 | isVideoLicenceValid, |
42 | isVideoNameValid, | 42 | isVideoNameValid, |
43 | isVideoPrivacyValid | 43 | isVideoPrivacyValid, isVideoSupportValid |
44 | } from '../../helpers/custom-validators/videos' | 44 | } from '../../helpers/custom-validators/videos' |
45 | import { generateImageFromVideoFile, getVideoFileHeight, transcode } from '../../helpers/ffmpeg-utils' | 45 | import { generateImageFromVideoFile, getVideoFileHeight, transcode } from '../../helpers/ffmpeg-utils' |
46 | import { logger } from '../../helpers/logger' | 46 | import { logger } from '../../helpers/logger' |
@@ -299,6 +299,12 @@ export class VideoModel extends Model<VideoModel> { | |||
299 | @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max)) | 299 | @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max)) |
300 | description: string | 300 | description: string |
301 | 301 | ||
302 | @AllowNull(true) | ||
303 | @Default(null) | ||
304 | @Is('VideoSupport', value => throwIfNotValid(value, isVideoSupportValid, 'support')) | ||
305 | @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.SUPPORT.max)) | ||
306 | support: string | ||
307 | |||
302 | @AllowNull(false) | 308 | @AllowNull(false) |
303 | @Is('VideoDuration', value => throwIfNotValid(value, isVideoDurationValid, 'duration')) | 309 | @Is('VideoDuration', value => throwIfNotValid(value, isVideoDurationValid, 'duration')) |
304 | @Column | 310 | @Column |
@@ -841,7 +847,7 @@ export class VideoModel extends Model<VideoModel> { | |||
841 | return join(STATIC_PATHS.PREVIEWS, this.getPreviewName()) | 847 | return join(STATIC_PATHS.PREVIEWS, this.getPreviewName()) |
842 | } | 848 | } |
843 | 849 | ||
844 | toFormattedJSON () { | 850 | toFormattedJSON (): Video { |
845 | let serverHost | 851 | let serverHost |
846 | 852 | ||
847 | if (this.VideoChannel.Account.Actor.Server) { | 853 | if (this.VideoChannel.Account.Actor.Server) { |
@@ -875,10 +881,10 @@ export class VideoModel extends Model<VideoModel> { | |||
875 | embedPath: this.getEmbedPath(), | 881 | embedPath: this.getEmbedPath(), |
876 | createdAt: this.createdAt, | 882 | createdAt: this.createdAt, |
877 | updatedAt: this.updatedAt | 883 | updatedAt: this.updatedAt |
878 | } as Video | 884 | } |
879 | } | 885 | } |
880 | 886 | ||
881 | toFormattedDetailsJSON () { | 887 | toFormattedDetailsJSON (): VideoDetails { |
882 | const formattedJson = this.toFormattedJSON() | 888 | const formattedJson = this.toFormattedJSON() |
883 | 889 | ||
884 | // Maybe our server is not up to date and there are new privacy settings since our version | 890 | // Maybe our server is not up to date and there are new privacy settings since our version |
@@ -888,6 +894,7 @@ export class VideoModel extends Model<VideoModel> { | |||
888 | const detailsJson = { | 894 | const detailsJson = { |
889 | privacyLabel, | 895 | privacyLabel, |
890 | privacy: this.privacy, | 896 | privacy: this.privacy, |
897 | support: this.support, | ||
891 | descriptionPath: this.getDescriptionPath(), | 898 | descriptionPath: this.getDescriptionPath(), |
892 | channel: this.VideoChannel.toFormattedJSON(), | 899 | channel: this.VideoChannel.toFormattedJSON(), |
893 | account: this.VideoChannel.Account.toFormattedJSON(), | 900 | account: this.VideoChannel.Account.toFormattedJSON(), |
@@ -917,7 +924,7 @@ export class VideoModel extends Model<VideoModel> { | |||
917 | return -1 | 924 | return -1 |
918 | }) | 925 | }) |
919 | 926 | ||
920 | return Object.assign(formattedJson, detailsJson) as VideoDetails | 927 | return Object.assign(formattedJson, detailsJson) |
921 | } | 928 | } |
922 | 929 | ||
923 | toActivityPubObject (): VideoTorrentObject { | 930 | toActivityPubObject (): VideoTorrentObject { |
@@ -957,17 +964,6 @@ export class VideoModel extends Model<VideoModel> { | |||
957 | let dislikesObject | 964 | let dislikesObject |
958 | 965 | ||
959 | if (Array.isArray(this.AccountVideoRates)) { | 966 | if (Array.isArray(this.AccountVideoRates)) { |
960 | const likes: string[] = [] | ||
961 | const dislikes: string[] = [] | ||
962 | |||
963 | for (const rate of this.AccountVideoRates) { | ||
964 | if (rate.type === 'like') { | ||
965 | likes.push(rate.Account.Actor.url) | ||
966 | } else if (rate.type === 'dislike') { | ||
967 | dislikes.push(rate.Account.Actor.url) | ||
968 | } | ||
969 | } | ||
970 | |||
971 | const res = this.toRatesActivityPubObjects() | 967 | const res = this.toRatesActivityPubObjects() |
972 | likesObject = res.likesObject | 968 | likesObject = res.likesObject |
973 | dislikesObject = res.dislikesObject | 969 | dislikesObject = res.dislikesObject |
@@ -1032,6 +1028,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1032 | updated: this.updatedAt.toISOString(), | 1028 | updated: this.updatedAt.toISOString(), |
1033 | mediaType: 'text/markdown', | 1029 | mediaType: 'text/markdown', |
1034 | content: this.getTruncatedDescription(), | 1030 | content: this.getTruncatedDescription(), |
1031 | support: this.support, | ||
1035 | icon: { | 1032 | icon: { |
1036 | type: 'Image', | 1033 | type: 'Image', |
1037 | url: this.getThumbnailUrl(baseUrlHttp), | 1034 | url: this.getThumbnailUrl(baseUrlHttp), |