]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/process/process-like.ts
Merge branch 'release/v1.2.0'
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / process / process-like.ts
index 0dca175511b9bb9854939b841136db03589ab043..2a04167d78a5c72364981a75c8f6fc5d64493096 100644 (file)
@@ -5,8 +5,8 @@ import { AccountVideoRateModel } from '../../../models/account/account-video-rat
 import { ActorModel } from '../../../models/activitypub/actor'
 import { forwardVideoRelatedActivity } from '../send/utils'
 import { getOrCreateVideoAndAccountAndChannel } from '../videos'
-import { immutableAssign } from '../../../tests/utils'
-import { getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url'
+import { getVideoLikeActivityPubUrl } from '../url'
+import { getAPId } from '../../../helpers/activitypub'
 
 async function processLikeActivity (activity: ActivityLike, byActor: ActorModel) {
   return retryTransactionWrapper(processLikeVideo, byActor, activity)
@@ -21,7 +21,7 @@ export {
 // ---------------------------------------------------------------------------
 
 async function processLikeVideo (byActor: ActorModel, activity: ActivityLike) {
-  const videoUrl = activity.object
+  const videoUrl = getAPId(activity.object)
 
   const byAccount = byActor.Account
   if (!byAccount) throw new Error('Cannot create like with the non account actor ' + byActor.url)
@@ -36,7 +36,7 @@ async function processLikeVideo (byActor: ActorModel, activity: ActivityLike) {
     }
     const [ , created ] = await AccountVideoRateModel.findOrCreate({
       where: rate,
-      defaults: immutableAssign(rate, { url: getVideoLikeActivityPubUrl(byActor, video) }),
+      defaults: Object.assign({}, rate, { url: getVideoLikeActivityPubUrl(byActor, video) }),
       transaction: t
     })
     if (created === true) await video.increment('likes', { transaction: t })