diff options
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 94af1ece5..b5d333347 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -25,7 +25,8 @@ import { | |||
25 | statPromise, | 25 | statPromise, |
26 | generateImageFromVideoFile, | 26 | generateImageFromVideoFile, |
27 | transcode, | 27 | transcode, |
28 | getVideoFileHeight | 28 | getVideoFileHeight, |
29 | getActivityPubUrl | ||
29 | } from '../../helpers' | 30 | } from '../../helpers' |
30 | import { | 31 | import { |
31 | CONFIG, | 32 | CONFIG, |
@@ -88,7 +89,7 @@ let listOwnedAndPopulateAccountAndTags: VideoMethods.ListOwnedAndPopulateAccount | |||
88 | let listOwnedByAccount: VideoMethods.ListOwnedByAccount | 89 | let listOwnedByAccount: VideoMethods.ListOwnedByAccount |
89 | let load: VideoMethods.Load | 90 | let load: VideoMethods.Load |
90 | let loadByUUID: VideoMethods.LoadByUUID | 91 | let loadByUUID: VideoMethods.LoadByUUID |
91 | let loadByUrl: VideoMethods.LoadByUrl | 92 | let loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL |
92 | let loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID | 93 | let loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID |
93 | let loadAndPopulateAccount: VideoMethods.LoadAndPopulateAccount | 94 | let loadAndPopulateAccount: VideoMethods.LoadAndPopulateAccount |
94 | let loadAndPopulateAccountAndPodAndTags: VideoMethods.LoadAndPopulateAccountAndPodAndTags | 95 | let loadAndPopulateAccountAndPodAndTags: VideoMethods.LoadAndPopulateAccountAndPodAndTags |
@@ -277,6 +278,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
277 | loadAndPopulateAccount, | 278 | loadAndPopulateAccount, |
278 | loadAndPopulateAccountAndPodAndTags, | 279 | loadAndPopulateAccountAndPodAndTags, |
279 | loadByHostAndUUID, | 280 | loadByHostAndUUID, |
281 | loadByUUIDOrURL, | ||
280 | loadByUUID, | 282 | loadByUUID, |
281 | loadLocalVideoByUUID, | 283 | loadLocalVideoByUUID, |
282 | loadByUUIDAndPopulateAccountAndPodAndTags, | 284 | loadByUUIDAndPopulateAccountAndPodAndTags, |
@@ -595,6 +597,7 @@ toActivityPubObject = function (this: VideoInstance) { | |||
595 | 597 | ||
596 | const videoObject: VideoTorrentObject = { | 598 | const videoObject: VideoTorrentObject = { |
597 | type: 'Video', | 599 | type: 'Video', |
600 | id: getActivityPubUrl('video', this.uuid), | ||
598 | name: this.name, | 601 | name: this.name, |
599 | // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration | 602 | // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration |
600 | duration: 'PT' + this.duration + 'S', | 603 | duration: 'PT' + this.duration + 'S', |
@@ -731,6 +734,7 @@ getCategoryLabel = function (this: VideoInstance) { | |||
731 | 734 | ||
732 | getLicenceLabel = function (this: VideoInstance) { | 735 | getLicenceLabel = function (this: VideoInstance) { |
733 | let licenceLabel = VIDEO_LICENCES[this.licence] | 736 | let licenceLabel = VIDEO_LICENCES[this.licence] |
737 | |||
734 | // Maybe our pod is not up to date and there are new licences since our version | 738 | // Maybe our pod is not up to date and there are new licences since our version |
735 | if (!licenceLabel) licenceLabel = 'Unknown' | 739 | if (!licenceLabel) licenceLabel = 'Unknown' |
736 | 740 | ||
@@ -946,6 +950,22 @@ loadByUUID = function (uuid: string, t?: Sequelize.Transaction) { | |||
946 | return Video.findOne(query) | 950 | return Video.findOne(query) |
947 | } | 951 | } |
948 | 952 | ||
953 | loadByUUIDOrURL = function (uuid: string, url: string, t?: Sequelize.Transaction) { | ||
954 | const query: Sequelize.FindOptions<VideoAttributes> = { | ||
955 | where: { | ||
956 | [Sequelize.Op.or]: [ | ||
957 | { uuid }, | ||
958 | { url } | ||
959 | ] | ||
960 | }, | ||
961 | include: [ Video['sequelize'].models.VideoFile ] | ||
962 | } | ||
963 | |||
964 | if (t !== undefined) query.transaction = t | ||
965 | |||
966 | return Video.findOne(query) | ||
967 | } | ||
968 | |||
949 | loadLocalVideoByUUID = function (uuid: string, t?: Sequelize.Transaction) { | 969 | loadLocalVideoByUUID = function (uuid: string, t?: Sequelize.Transaction) { |
950 | const query: Sequelize.FindOptions<VideoAttributes> = { | 970 | const query: Sequelize.FindOptions<VideoAttributes> = { |
951 | where: { | 971 | where: { |