mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Try to refractor activities sending
There is still a need for work on this part though
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user