- return
-}
-
-async function processCreateDislike (byActor: ActorModel, activity: ActivityCreate) {
- const options = {
- arguments: [ byActor, activity ],
- errorMessage: 'Cannot dislike the video with many retries.'
- }
-
- return retryTransactionWrapper(createVideoDislike, options)
-}
-
-async function createVideoDislike (byActor: ActorModel, activity: ActivityCreate) {
- const dislike = activity.object as DislikeObject
- const byAccount = byActor.Account
-
- if (!byAccount) throw new Error('Cannot create dislike with the non account actor ' + byActor.url)
-
- const { video } = await getOrCreateAccountAndVideoAndChannel(dislike.object)
-
- return sequelizeTypescript.transaction(async t => {
- const rate = {
- type: 'dislike' as 'dislike',
- videoId: video.id,
- accountId: byAccount.id
- }
- const [ , created ] = await AccountVideoRateModel.findOrCreate({
- where: rate,
- defaults: rate,
- transaction: t
- })
- if (created === true) await video.increment('dislikes', { transaction: t })
-
- if (video.isOwned() && created === true) {
- // Don't resend the activity to the sender
- const exceptions = [ byActor ]
- await forwardActivity(activity, t, exceptions)
- }
+ await sequelizeTypescript.transaction(async t => {
+ return createOrUpdateCacheFile(cacheFile, video, byActor, t)