Try to refractor activities sending

There is still a need for work on this part though
This commit is contained in:
Chocobozzz
2018-03-27 13:33:56 +02:00
parent da99ccf268
commit 07197db4c5
11 changed files with 100 additions and 169 deletions

View File

@@ -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()
}

View File

@@ -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)