]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/send/send-reject.ts
Use unique AP id for accept/reject
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-reject.ts
index 643c468a9d169a3be6d261f74cb0969f7baaa125..a5f8c2ecfc75b55df4735788cba33e2ef5f4b96b 100644 (file)
@@ -1,11 +1,11 @@
-import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub'
-import { getActorFollowActivityPubUrl, getActorFollowRejectActivityPubUrl } from '../url'
-import { unicastTo } from './utils'
-import { buildFollowActivity } from './send-follow'
+import { ActivityFollow, ActivityReject } from '@shared/models'
 import { logger } from '../../../helpers/logger'
-import { MActor } from '../../../typings/models'
+import { MActor } from '../../../types/models'
+import { getLocalActorFollowRejectActivityPubUrl } from '../url'
+import { buildFollowActivity } from './send-follow'
+import { unicastTo } from './shared/send-utils'
 
-function sendReject (follower: MActor, following: MActor) {
+function sendReject (followUrl: string, follower: MActor, following: MActor) {
   if (!follower.serverId) { // This should never happen
     logger.warn('Do not sending reject to local follower.')
     return
@@ -13,13 +13,12 @@ function sendReject (follower: MActor, following: MActor) {
 
   logger.info('Creating job to reject follower %s.', follower.url)
 
-  const followUrl = getActorFollowActivityPubUrl(follower, following)
   const followData = buildFollowActivity(followUrl, follower, following)
 
-  const url = getActorFollowRejectActivityPubUrl(follower, following)
+  const url = getLocalActorFollowRejectActivityPubUrl()
   const data = buildRejectActivity(url, following, followData)
 
-  return unicastTo(data, following, follower.inboxUrl)
+  return unicastTo({ data, byActor: following, toActorUrl: follower.inboxUrl, contextType: 'Reject' })
 }
 
 // ---------------------------------------------------------------------------