import * as express from 'express'
import { UserVideoRateUpdate } from '../../../../shared'
-import { logger, retryTransactionWrapper } from '../../../helpers'
+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'
await previousRate.destroy({ transaction: t })
} else { // Update previous rate
previousRate.type = rateType
-
await previousRate.save({ transaction: t })
}
} else if (rateType !== 'none') { // There was not a previous rate, insert a new one if there is a rate
// 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)