- const { baseUrlHttp, baseUrlWs } = this.getBaseUrls()
- if (!this.Tags) this.Tags = []
-
- const tag = this.Tags.map(t => ({
- type: 'Hashtag' as 'Hashtag',
- name: t.name
- }))
-
- let language
- if (this.language) {
- language = {
- identifier: this.language + '',
- name: this.getLanguageLabel()
- }
- }
-
- let category
- if (this.category) {
- category = {
- identifier: this.category + '',
- name: this.getCategoryLabel()
- }
- }
-
- let licence
- if (this.licence) {
- licence = {
- identifier: this.licence + '',
- name: this.getLicenceLabel()
- }
- }
-
- let likesObject
- let dislikesObject
-
- if (Array.isArray(this.AccountVideoRates)) {
- const likes: string[] = []
- const dislikes: string[] = []
-
- for (const rate of this.AccountVideoRates) {
- if (rate.type === 'like') {
- likes.push(rate.Account.Actor.url)
- } else if (rate.type === 'dislike') {
- dislikes.push(rate.Account.Actor.url)
- }
- }
-
- likesObject = activityPubCollection(likes)
- dislikesObject = activityPubCollection(dislikes)
- }
-
- let sharesObject
- if (Array.isArray(this.VideoShares)) {
- const shares: string[] = []
-
- for (const videoShare of this.VideoShares) {
- const shareUrl = getAnnounceActivityPubUrl(this.url, videoShare.Actor)
- shares.push(shareUrl)
- }
-
- sharesObject = activityPubCollection(shares)
- }
-
- let commentsObject
- if (Array.isArray(this.VideoComments)) {
- const comments: string[] = []
-
- for (const videoComment of this.VideoComments) {
- comments.push(videoComment.url)
- }
-
- commentsObject = activityPubCollection(comments)
- }
-
- const url = []
- for (const file of this.VideoFiles) {
- url.push({
- type: 'Link',
- mimeType: 'video/' + file.extname.replace('.', ''),
- url: this.getVideoFileUrl(file, baseUrlHttp),
- width: file.resolution,
- size: file.size
- })
-
- url.push({
- type: 'Link',
- mimeType: 'application/x-bittorrent',
- url: this.getTorrentUrl(file, baseUrlHttp),
- width: file.resolution
- })
-
- url.push({
- type: 'Link',
- mimeType: 'application/x-bittorrent;x-scheme-handler/magnet',
- url: this.generateMagnetUri(file, baseUrlHttp, baseUrlWs),
- width: file.resolution
- })
- }
-
- // Add video url too
- url.push({
- type: 'Link',
- mimeType: 'text/html',
- url: CONFIG.WEBSERVER.URL + '/videos/watch/' + this.uuid
- })
-
- return {
- type: 'Video' as 'Video',
- id: this.url,
- name: this.name,
- // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
- duration: 'PT' + this.duration + 'S',
- uuid: this.uuid,
- tag,
- category,
- licence,
- language,
- views: this.views,
- nsfw: this.nsfw,
- commentsEnabled: this.commentsEnabled,
- published: this.createdAt.toISOString(),
- updated: this.updatedAt.toISOString(),
- mediaType: 'text/markdown',
- content: this.getTruncatedDescription(),
- icon: {
- type: 'Image',
- url: this.getThumbnailUrl(baseUrlHttp),
- mediaType: 'image/jpeg',
- width: THUMBNAILS_SIZE.width,
- height: THUMBNAILS_SIZE.height
- },
- url,
- likes: likesObject,
- dislikes: dislikesObject,
- shares: sharesObject,
- comments: commentsObject,
- attributedTo: [
- {
- type: 'Group',
- id: this.VideoChannel.Actor.url
- }
- ]
- }