From 40ff57078e15d5b86ee6b71e198b95d3feb78eaf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Nov 2017 16:25:03 +0100 Subject: Federate video views --- server/models/video/video-interface.ts | 2 +- server/models/video/video.ts | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'server/models') diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts index 391ecff43..b97f163ab 100644 --- a/server/models/video/video-interface.ts +++ b/server/models/video/video-interface.ts @@ -122,7 +122,7 @@ export interface VideoAttributes { VideoChannel?: VideoChannelInstance Tags?: TagInstance[] VideoFiles?: VideoFileInstance[] - VideoShare?: VideoShareInstance + VideoShares?: VideoShareInstance[] } export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance { diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 9b411a92e..052fc0ae8 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -567,6 +567,14 @@ toActivityPubObject = function (this: VideoInstance) { name: t.name })) + let language + if (this.language) { + language = { + identifier: this.language + '', + name: this.getLanguageLabel() + } + } + const url = [] for (const file of this.VideoFiles) { url.push({ @@ -608,10 +616,7 @@ toActivityPubObject = function (this: VideoInstance) { identifier: this.licence + '', name: this.getLicenceLabel() }, - language: { - identifier: this.language + '', - name: this.getLanguageLabel() - }, + language, views: this.views, nsfw: this.nsfw, published: this.createdAt.toISOString(), @@ -816,7 +821,19 @@ listAllAndSharedByAccountForOutbox = function (accountId: number, start: number, include: [ { model: Video['sequelize'].models.VideoShare, - required: false + required: false, + where: { + [Sequelize.Op.and]: [ + { + id: { + [Sequelize.Op.not]: null + } + }, + { + accountId + } + ] + } }, { model: Video['sequelize'].models.VideoChannel, -- cgit v1.2.3