- const rate = {
- type: 'like' as 'like',
- videoId: video.id,
- accountId: byAccount.id
- }
- const [ , created ] = await AccountVideoRateModel.findOrCreate({
- where: rate,
- defaults: rate,
- transaction: t
- })
- if (created === true) await video.increment('likes', { transaction: t })
-
- if (video.isOwned() && created === true) {
- // Don't resend the activity to the sender
- const exceptions = [ byAccount ]
- await forwardActivity(activity, t, exceptions)
+ if (existingRate && existingRate.type === 'dislike') {
+ await video.decrement('dislikes', { transaction: t })
+ video.dislikes--