- const rate = {
- type: 'like' as 'like',
- videoId: video.id,
- accountId: byAccount.id
+ const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id, t)
+ if (existingRate && existingRate.type === 'like') return
+
+ if (existingRate && existingRate.type === 'dislike') {
+ await video.decrement('dislikes', { transaction: t })