From 07197db4c567f22bbc9c12339062896dc76bac2f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 27 Mar 2018 13:33:56 +0200 Subject: Try to refractor activities sending There is still a need for work on this part though --- server/controllers/api/videos/index.ts | 8 ++------ server/controllers/api/videos/rate.ts | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 690872320..552e5edac 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -20,7 +20,7 @@ import { VIDEO_PRIVACIES } from '../../../initializers' import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' -import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' +import { sendCreateVideo, sendCreateView, sendUpdateVideo } from '../../../lib/activitypub/send' import { JobQueue } from '../../../lib/job-queue' import { Redis } from '../../../lib/redis' import { @@ -365,11 +365,7 @@ async function viewVideo (req: express.Request, res: express.Response) { const serverAccount = await getServerActor() - if (videoInstance.isOwned()) { - await sendCreateViewToVideoFollowers(serverAccount, videoInstance, undefined) - } else { - await sendCreateViewToOrigin(serverAccount, videoInstance, undefined) - } + await sendCreateView(serverAccount, videoInstance, undefined) return res.status(204).end() } diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index a7bd570eb..23e9de9f3 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -3,7 +3,7 @@ import { UserVideoRateUpdate } from '../../../../shared' import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' import { sequelizeTypescript, VIDEO_RATE_TYPES } from '../../../initializers' -import { sendVideoRateChangeToFollowers, sendVideoRateChangeToOrigin } from '../../../lib/activitypub' +import { sendVideoRateChange } from '../../../lib/activitypub' import { asyncMiddleware, authenticate, videoRateValidator } from '../../../middlewares' import { AccountModel } from '../../../models/account/account' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' @@ -83,11 +83,7 @@ async function rateVideo (req: express.Request, res: express.Response) { // It is useful for the user to have a feedback await videoInstance.increment(incrementQuery, sequelizeOptions) - if (videoInstance.isOwned()) { - await sendVideoRateChangeToFollowers(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) - } else { - await sendVideoRateChangeToOrigin(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) - } + await sendVideoRateChange(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) }) logger.info('Account video rate for video %s of account %s updated.', videoInstance.name, accountInstance.name) -- cgit v1.2.3