- if (!byAccount) throw new Error('Cannot create dislike with the non account actor ' + byActor.url)
-
- const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: 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: Object.assign({}, rate, { url: getVideoDislikeActivityPubUrl(byActor, video) }),
- 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 forwardVideoRelatedActivity(activity, t, exceptions, video)
- }
- })