- const [ , created ] = await AccountVideoRateModel.findOrCreate({
- where: rate,
- defaults: immutableAssign(rate, { url: getVideoLikeActivityPubUrl(byActor, video) }),
- transaction: t
- })
- if (created === true) await video.increment('likes', { transaction: t })
-
- if (video.isOwned() && created === true) {
+
+ await video.increment('likes', { transaction: t })
+
+ const rate = existingRate || new AccountVideoRateModel()
+ rate.type = 'like'
+ rate.videoId = video.id
+ rate.accountId = byAccount.id
+ rate.url = activity.id
+
+ await rate.save({ transaction: t })
+
+ if (video.isOwned()) {