diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-10 14:34:45 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | 0d0e8dd0904b380b70e19ebcb4763d65601c4632 (patch) | |
tree | acb625d7c88fbe863fa14bf6783fafe4a8e35137 /server/models/video/video.ts | |
parent | e4f97babf701481b55cc10fb3448feab5f97c867 (diff) | |
download | PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.tar.gz PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.tar.zst PeerTube-0d0e8dd0904b380b70e19ebcb4763d65601c4632.zip |
Continue activitypub
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: { |