]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/video-rates.ts
Fix incorrect IDs in AP federation
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / video-rates.ts
index 6bd46bb585654582bdfde6121f64f75139b27ef7..581a2bca1d1f94dcccec032955112baa025d4c21 100644 (file)
@@ -8,9 +8,9 @@ import { logger } from '../../helpers/logger'
 import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants'
 import { doRequest } from '../../helpers/requests'
 import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
-import { getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from './url'
+import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlByLocalActor } from './url'
 import { sendDislike } from './send/send-dislike'
-import { MAccountActor, MActorUrl, MVideo, MVideoAccountLight, MVideoId } from '../../typings/models'
+import { MAccountActor, MActorUrl, MVideo, MVideoAccountLight, MVideoId } from '../../types/models'
 
 async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateType) {
   let rateCounts = 0
@@ -18,7 +18,7 @@ async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateTy
   await Bluebird.map(ratesUrl, async rateUrl => {
     try {
       // Fetch url
-      const { body } = await doRequest({
+      const { body } = await doRequest<any>({
         uri: rateUrl,
         json: true,
         activityPub: true
@@ -58,8 +58,6 @@ async function createRates (ratesUrl: string[], video: MVideo, rate: VideoRateTy
     const field = rate === 'like' ? 'likes' : 'dislikes'
     await video.increment(field, { by: rateCounts })
   }
-
-  return
 }
 
 async function sendVideoRateChange (
@@ -84,14 +82,14 @@ async function sendVideoRateChange (
   if (dislikes > 0) await sendDislike(actor, video, t)
 }
 
-function getRateUrl (rateType: VideoRateType, actor: MActorUrl, video: MVideoId) {
+function getLocalRateUrl (rateType: VideoRateType, actor: MActorUrl, video: MVideoId) {
   return rateType === 'like'
-    ? getVideoLikeActivityPubUrl(actor, video)
-    : getVideoDislikeActivityPubUrl(actor, video)
+    ? getVideoLikeActivityPubUrlByLocalActor(actor, video)
+    : getVideoDislikeActivityPubUrlByLocalActor(actor, video)
 }
 
 export {
-  getRateUrl,
+  getLocalRateUrl,
   createRates,
   sendVideoRateChange
 }