diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-27 13:33:56 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-03-27 13:33:56 +0200 |
commit | 07197db4c567f22bbc9c12339062896dc76bac2f (patch) | |
tree | 5682f0d88fc1b4032018e5122ed42eb9967fd743 /server/controllers | |
parent | da99ccf2681bcbc172a96cf30e7b733948767faa (diff) | |
download | PeerTube-07197db4c567f22bbc9c12339062896dc76bac2f.tar.gz PeerTube-07197db4c567f22bbc9c12339062896dc76bac2f.tar.zst PeerTube-07197db4c567f22bbc9c12339062896dc76bac2f.zip |
Try to refractor activities sending
There is still a need for work on this part though
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/client.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 8 | ||||
-rw-r--r-- | server/controllers/api/videos/rate.ts | 8 |
3 files changed, 6 insertions, 14 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 347079816..8e295b4f9 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts | |||
@@ -4,7 +4,7 @@ import { VideoPrivacy } from '../../../shared/models/videos' | |||
4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' | 4 | import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' |
5 | import { pageToStartAndCount } from '../../helpers/core-utils' | 5 | import { pageToStartAndCount } from '../../helpers/core-utils' |
6 | import { ACTIVITY_PUB, CONFIG } from '../../initializers' | 6 | import { ACTIVITY_PUB, CONFIG } from '../../initializers' |
7 | import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' | 7 | import { buildVideoAnnounce } from '../../lib/activitypub/send' |
8 | import { audiencify, getAudience } from '../../lib/activitypub/send/misc' | 8 | import { audiencify, getAudience } from '../../lib/activitypub/send/misc' |
9 | import { createActivityData } from '../../lib/activitypub/send/send-create' | 9 | import { createActivityData } from '../../lib/activitypub/send/send-create' |
10 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' | 10 | import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' |
@@ -130,7 +130,7 @@ async function videoController (req: express.Request, res: express.Response, nex | |||
130 | 130 | ||
131 | async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { | 131 | async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { |
132 | const share = res.locals.videoShare as VideoShareModel | 132 | const share = res.locals.videoShare as VideoShareModel |
133 | const object = await buildVideoAnnounceToFollowers(share.Actor, share, res.locals.video, undefined) | 133 | const object = await buildVideoAnnounce(share.Actor, share, res.locals.video, undefined) |
134 | 134 | ||
135 | return res.json(activityPubContextify(object)) | 135 | return res.json(activityPubContextify(object)) |
136 | } | 136 | } |
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 { | |||
20 | VIDEO_PRIVACIES | 20 | VIDEO_PRIVACIES |
21 | } from '../../../initializers' | 21 | } from '../../../initializers' |
22 | import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' | 22 | import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' |
23 | import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' | 23 | import { sendCreateVideo, sendCreateView, sendUpdateVideo } from '../../../lib/activitypub/send' |
24 | import { JobQueue } from '../../../lib/job-queue' | 24 | import { JobQueue } from '../../../lib/job-queue' |
25 | import { Redis } from '../../../lib/redis' | 25 | import { Redis } from '../../../lib/redis' |
26 | import { | 26 | import { |
@@ -365,11 +365,7 @@ async function viewVideo (req: express.Request, res: express.Response) { | |||
365 | 365 | ||
366 | const serverAccount = await getServerActor() | 366 | const serverAccount = await getServerActor() |
367 | 367 | ||
368 | if (videoInstance.isOwned()) { | 368 | await sendCreateView(serverAccount, videoInstance, undefined) |
369 | await sendCreateViewToVideoFollowers(serverAccount, videoInstance, undefined) | ||
370 | } else { | ||
371 | await sendCreateViewToOrigin(serverAccount, videoInstance, undefined) | ||
372 | } | ||
373 | 369 | ||
374 | return res.status(204).end() | 370 | return res.status(204).end() |
375 | } | 371 | } |
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' | |||
3 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 3 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
4 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
5 | import { sequelizeTypescript, VIDEO_RATE_TYPES } from '../../../initializers' | 5 | import { sequelizeTypescript, VIDEO_RATE_TYPES } from '../../../initializers' |
6 | import { sendVideoRateChangeToFollowers, sendVideoRateChangeToOrigin } from '../../../lib/activitypub' | 6 | import { sendVideoRateChange } from '../../../lib/activitypub' |
7 | import { asyncMiddleware, authenticate, videoRateValidator } from '../../../middlewares' | 7 | import { asyncMiddleware, authenticate, videoRateValidator } from '../../../middlewares' |
8 | import { AccountModel } from '../../../models/account/account' | 8 | import { AccountModel } from '../../../models/account/account' |
9 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 9 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
@@ -83,11 +83,7 @@ async function rateVideo (req: express.Request, res: express.Response) { | |||
83 | // It is useful for the user to have a feedback | 83 | // It is useful for the user to have a feedback |
84 | await videoInstance.increment(incrementQuery, sequelizeOptions) | 84 | await videoInstance.increment(incrementQuery, sequelizeOptions) |
85 | 85 | ||
86 | if (videoInstance.isOwned()) { | 86 | await sendVideoRateChange(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) |
87 | await sendVideoRateChangeToFollowers(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) | ||
88 | } else { | ||
89 | await sendVideoRateChangeToOrigin(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) | ||
90 | } | ||
91 | }) | 87 | }) |
92 | 88 | ||
93 | logger.info('Account video rate for video %s of account %s updated.', videoInstance.name, accountInstance.name) | 89 | logger.info('Account video rate for video %s of account %s updated.', videoInstance.name, accountInstance.name) |