diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-20 11:21:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-11-20 11:21:08 +0100 |
commit | de94ac86a211dec657332d964693857ec235ce40 (patch) | |
tree | 3bff96a40e7c862d83561a26249992b07331b0a2 /server/lib/activitypub/send | |
parent | 3fba4b6bce69247b1d37f923894d8f44818a891c (diff) | |
download | PeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.gz PeerTube-de94ac86a211dec657332d964693857ec235ce40.tar.zst PeerTube-de94ac86a211dec657332d964693857ec235ce40.zip |
Fix incorrect IDs in AP federation
Diffstat (limited to 'server/lib/activitypub/send')
-rw-r--r-- | server/lib/activitypub/send/send-accept.ts | 11 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-dislike.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-flag.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-follow.ts | 8 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-like.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-reject.ts | 11 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-undo.ts | 30 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-view.ts | 10 |
8 files changed, 39 insertions, 43 deletions
diff --git a/server/lib/activitypub/send/send-accept.ts b/server/lib/activitypub/send/send-accept.ts index 50e192bdd..bb387e2c0 100644 --- a/server/lib/activitypub/send/send-accept.ts +++ b/server/lib/activitypub/send/send-accept.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { ActivityAccept, ActivityFollow } from '../../../../shared/models/activitypub' | 1 | import { ActivityAccept, ActivityFollow } from '../../../../shared/models/activitypub' |
2 | import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url' | ||
3 | import { unicastTo } from './utils' | ||
4 | import { buildFollowActivity } from './send-follow' | ||
5 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
6 | import { MActor, MActorFollowActors } from '../../../types/models' | 3 | import { MActor, MActorFollowActors } from '../../../types/models' |
4 | import { getLocalActorFollowAcceptActivityPubUrl } from '../url' | ||
5 | import { buildFollowActivity } from './send-follow' | ||
6 | import { unicastTo } from './utils' | ||
7 | 7 | ||
8 | function sendAccept (actorFollow: MActorFollowActors) { | 8 | function sendAccept (actorFollow: MActorFollowActors) { |
9 | const follower = actorFollow.ActorFollower | 9 | const follower = actorFollow.ActorFollower |
@@ -16,10 +16,9 @@ function sendAccept (actorFollow: MActorFollowActors) { | |||
16 | 16 | ||
17 | logger.info('Creating job to accept follower %s.', follower.url) | 17 | logger.info('Creating job to accept follower %s.', follower.url) |
18 | 18 | ||
19 | const followUrl = getActorFollowActivityPubUrl(follower, me) | 19 | const followData = buildFollowActivity(actorFollow.url, follower, me) |
20 | const followData = buildFollowActivity(followUrl, follower, me) | ||
21 | 20 | ||
22 | const url = getActorFollowAcceptActivityPubUrl(actorFollow) | 21 | const url = getLocalActorFollowAcceptActivityPubUrl(actorFollow) |
23 | const data = buildAcceptActivity(url, me, followData) | 22 | const data = buildAcceptActivity(url, me, followData) |
24 | 23 | ||
25 | return unicastTo(data, me, follower.inboxUrl) | 24 | return unicastTo(data, me, follower.inboxUrl) |
diff --git a/server/lib/activitypub/send/send-dislike.ts b/server/lib/activitypub/send/send-dislike.ts index 1bb7dc937..274230535 100644 --- a/server/lib/activitypub/send/send-dislike.ts +++ b/server/lib/activitypub/send/send-dislike.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { getVideoDislikeActivityPubUrl } from '../url' | 2 | import { getVideoDislikeActivityPubUrlByLocalActor } from '../url' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { ActivityAudience, ActivityDislike } from '../../../../shared/models/activitypub' | 4 | import { ActivityAudience, ActivityDislike } from '../../../../shared/models/activitypub' |
5 | import { sendVideoRelatedActivity } from './utils' | 5 | import { sendVideoRelatedActivity } from './utils' |
@@ -10,7 +10,7 @@ function sendDislike (byActor: MActor, video: MVideoAccountLight, t: Transaction | |||
10 | logger.info('Creating job to dislike %s.', video.url) | 10 | logger.info('Creating job to dislike %s.', video.url) |
11 | 11 | ||
12 | const activityBuilder = (audience: ActivityAudience) => { | 12 | const activityBuilder = (audience: ActivityAudience) => { |
13 | const url = getVideoDislikeActivityPubUrl(byActor, video) | 13 | const url = getVideoDislikeActivityPubUrlByLocalActor(byActor, video) |
14 | 14 | ||
15 | return buildDislikeActivity(url, byActor, video, audience) | 15 | return buildDislikeActivity(url, byActor, video, audience) |
16 | } | 16 | } |
diff --git a/server/lib/activitypub/send/send-flag.ts b/server/lib/activitypub/send/send-flag.ts index 821637ec8..b0483b5a0 100644 --- a/server/lib/activitypub/send/send-flag.ts +++ b/server/lib/activitypub/send/send-flag.ts | |||
@@ -3,13 +3,13 @@ import { ActivityAudience, ActivityFlag } from '../../../../shared/models/activi | |||
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { MAbuseAP, MAccountLight, MActor } from '../../../types/models' | 4 | import { MAbuseAP, MAccountLight, MActor } from '../../../types/models' |
5 | import { audiencify, getAudience } from '../audience' | 5 | import { audiencify, getAudience } from '../audience' |
6 | import { getAbuseActivityPubUrl } from '../url' | 6 | import { getLocalAbuseActivityPubUrl } from '../url' |
7 | import { unicastTo } from './utils' | 7 | import { unicastTo } from './utils' |
8 | 8 | ||
9 | function sendAbuse (byActor: MActor, abuse: MAbuseAP, flaggedAccount: MAccountLight, t: Transaction) { | 9 | function sendAbuse (byActor: MActor, abuse: MAbuseAP, flaggedAccount: MAccountLight, t: Transaction) { |
10 | if (!flaggedAccount.Actor.serverId) return // Local user | 10 | if (!flaggedAccount.Actor.serverId) return // Local user |
11 | 11 | ||
12 | const url = getAbuseActivityPubUrl(abuse) | 12 | const url = getLocalAbuseActivityPubUrl(abuse) |
13 | 13 | ||
14 | logger.info('Creating job to send abuse %s.', url) | 14 | logger.info('Creating job to send abuse %s.', url) |
15 | 15 | ||
diff --git a/server/lib/activitypub/send/send-follow.ts b/server/lib/activitypub/send/send-follow.ts index 08f1d83f9..9219640dd 100644 --- a/server/lib/activitypub/send/send-follow.ts +++ b/server/lib/activitypub/send/send-follow.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | import { Transaction } from 'sequelize' | ||
1 | import { ActivityFollow } from '../../../../shared/models/activitypub' | 2 | import { ActivityFollow } from '../../../../shared/models/activitypub' |
2 | import { getActorFollowActivityPubUrl } from '../url' | ||
3 | import { unicastTo } from './utils' | ||
4 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
5 | import { Transaction } from 'sequelize' | ||
6 | import { MActor, MActorFollowActors } from '../../../types/models' | 4 | import { MActor, MActorFollowActors } from '../../../types/models' |
5 | import { unicastTo } from './utils' | ||
7 | 6 | ||
8 | function sendFollow (actorFollow: MActorFollowActors, t: Transaction) { | 7 | function sendFollow (actorFollow: MActorFollowActors, t: Transaction) { |
9 | const me = actorFollow.ActorFollower | 8 | const me = actorFollow.ActorFollower |
@@ -14,8 +13,7 @@ function sendFollow (actorFollow: MActorFollowActors, t: Transaction) { | |||
14 | 13 | ||
15 | logger.info('Creating job to send follow request to %s.', following.url) | 14 | logger.info('Creating job to send follow request to %s.', following.url) |
16 | 15 | ||
17 | const url = getActorFollowActivityPubUrl(me, following) | 16 | const data = buildFollowActivity(actorFollow.url, me, following) |
18 | const data = buildFollowActivity(url, me, following) | ||
19 | 17 | ||
20 | t.afterCommit(() => unicastTo(data, me, following.inboxUrl)) | 18 | t.afterCommit(() => unicastTo(data, me, following.inboxUrl)) |
21 | } | 19 | } |
diff --git a/server/lib/activitypub/send/send-like.ts b/server/lib/activitypub/send/send-like.ts index 29fcfc404..ed6dfcf56 100644 --- a/server/lib/activitypub/send/send-like.ts +++ b/server/lib/activitypub/send/send-like.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { ActivityAudience, ActivityLike } from '../../../../shared/models/activitypub' | 2 | import { ActivityAudience, ActivityLike } from '../../../../shared/models/activitypub' |
3 | import { getVideoLikeActivityPubUrl } from '../url' | 3 | import { getVideoLikeActivityPubUrlByLocalActor } from '../url' |
4 | import { sendVideoRelatedActivity } from './utils' | 4 | import { sendVideoRelatedActivity } from './utils' |
5 | import { audiencify, getAudience } from '../audience' | 5 | import { audiencify, getAudience } from '../audience' |
6 | import { logger } from '../../../helpers/logger' | 6 | import { logger } from '../../../helpers/logger' |
@@ -10,7 +10,7 @@ function sendLike (byActor: MActor, video: MVideoAccountLight, t: Transaction) { | |||
10 | logger.info('Creating job to like %s.', video.url) | 10 | logger.info('Creating job to like %s.', video.url) |
11 | 11 | ||
12 | const activityBuilder = (audience: ActivityAudience) => { | 12 | const activityBuilder = (audience: ActivityAudience) => { |
13 | const url = getVideoLikeActivityPubUrl(byActor, video) | 13 | const url = getVideoLikeActivityPubUrlByLocalActor(byActor, video) |
14 | 14 | ||
15 | return buildLikeActivity(url, byActor, video, audience) | 15 | return buildLikeActivity(url, byActor, video, audience) |
16 | } | 16 | } |
diff --git a/server/lib/activitypub/send/send-reject.ts b/server/lib/activitypub/send/send-reject.ts index befbcb8da..8d74a7848 100644 --- a/server/lib/activitypub/send/send-reject.ts +++ b/server/lib/activitypub/send/send-reject.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub' | 1 | import { ActivityFollow, ActivityReject } from '../../../../shared/models/activitypub' |
2 | import { getActorFollowActivityPubUrl, getActorFollowRejectActivityPubUrl } from '../url' | ||
3 | import { unicastTo } from './utils' | ||
4 | import { buildFollowActivity } from './send-follow' | ||
5 | import { logger } from '../../../helpers/logger' | 2 | import { logger } from '../../../helpers/logger' |
6 | import { MActor } from '../../../types/models' | 3 | import { MActor } from '../../../types/models' |
4 | import { getLocalActorFollowRejectActivityPubUrl } from '../url' | ||
5 | import { buildFollowActivity } from './send-follow' | ||
6 | import { unicastTo } from './utils' | ||
7 | 7 | ||
8 | function sendReject (follower: MActor, following: MActor) { | 8 | function sendReject (followUrl: string, follower: MActor, following: MActor) { |
9 | if (!follower.serverId) { // This should never happen | 9 | if (!follower.serverId) { // This should never happen |
10 | logger.warn('Do not sending reject to local follower.') | 10 | logger.warn('Do not sending reject to local follower.') |
11 | return | 11 | return |
@@ -13,10 +13,9 @@ function sendReject (follower: MActor, following: MActor) { | |||
13 | 13 | ||
14 | logger.info('Creating job to reject follower %s.', follower.url) | 14 | logger.info('Creating job to reject follower %s.', follower.url) |
15 | 15 | ||
16 | const followUrl = getActorFollowActivityPubUrl(follower, following) | ||
17 | const followData = buildFollowActivity(followUrl, follower, following) | 16 | const followData = buildFollowActivity(followUrl, follower, following) |
18 | 17 | ||
19 | const url = getActorFollowRejectActivityPubUrl(follower, following) | 18 | const url = getLocalActorFollowRejectActivityPubUrl(follower, following) |
20 | const data = buildRejectActivity(url, following, followData) | 19 | const data = buildRejectActivity(url, following, followData) |
21 | 20 | ||
22 | return unicastTo(data, following, follower.inboxUrl) | 21 | return unicastTo(data, following, follower.inboxUrl) |
diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts index 6ed343300..352c158fd 100644 --- a/server/lib/activitypub/send/send-undo.ts +++ b/server/lib/activitypub/send/send-undo.ts | |||
@@ -8,18 +8,11 @@ import { | |||
8 | ActivityLike, | 8 | ActivityLike, |
9 | ActivityUndo | 9 | ActivityUndo |
10 | } from '../../../../shared/models/activitypub' | 10 | } from '../../../../shared/models/activitypub' |
11 | import { VideoModel } from '../../../models/video/video' | ||
12 | import { getActorFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url' | ||
13 | import { broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './utils' | ||
14 | import { audiencify, getAudience } from '../audience' | ||
15 | import { buildCreateActivity } from './send-create' | ||
16 | import { buildFollowActivity } from './send-follow' | ||
17 | import { buildLikeActivity } from './send-like' | ||
18 | import { buildAnnounceWithVideoAudience } from './send-announce' | ||
19 | import { logger } from '../../../helpers/logger' | 11 | import { logger } from '../../../helpers/logger' |
20 | import { buildDislikeActivity } from './send-dislike' | 12 | import { VideoModel } from '../../../models/video/video' |
21 | import { | 13 | import { |
22 | MActor, MActorAudience, | 14 | MActor, |
15 | MActorAudience, | ||
23 | MActorFollowActors, | 16 | MActorFollowActors, |
24 | MActorLight, | 17 | MActorLight, |
25 | MVideo, | 18 | MVideo, |
@@ -27,6 +20,14 @@ import { | |||
27 | MVideoRedundancyVideo, | 20 | MVideoRedundancyVideo, |
28 | MVideoShare | 21 | MVideoShare |
29 | } from '../../../types/models' | 22 | } from '../../../types/models' |
23 | import { audiencify, getAudience } from '../audience' | ||
24 | import { getUndoActivityPubUrl, getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlByLocalActor } from '../url' | ||
25 | import { buildAnnounceWithVideoAudience } from './send-announce' | ||
26 | import { buildCreateActivity } from './send-create' | ||
27 | import { buildDislikeActivity } from './send-dislike' | ||
28 | import { buildFollowActivity } from './send-follow' | ||
29 | import { buildLikeActivity } from './send-like' | ||
30 | import { broadcastToFollowers, sendVideoRelatedActivity, unicastTo } from './utils' | ||
30 | 31 | ||
31 | function sendUndoFollow (actorFollow: MActorFollowActors, t: Transaction) { | 32 | function sendUndoFollow (actorFollow: MActorFollowActors, t: Transaction) { |
32 | const me = actorFollow.ActorFollower | 33 | const me = actorFollow.ActorFollower |
@@ -37,10 +38,9 @@ function sendUndoFollow (actorFollow: MActorFollowActors, t: Transaction) { | |||
37 | 38 | ||
38 | logger.info('Creating job to send an unfollow request to %s.', following.url) | 39 | logger.info('Creating job to send an unfollow request to %s.', following.url) |
39 | 40 | ||
40 | const followUrl = getActorFollowActivityPubUrl(me, following) | 41 | const undoUrl = getUndoActivityPubUrl(actorFollow.url) |
41 | const undoUrl = getUndoActivityPubUrl(followUrl) | ||
42 | 42 | ||
43 | const followActivity = buildFollowActivity(followUrl, me, following) | 43 | const followActivity = buildFollowActivity(actorFollow.url, me, following) |
44 | const undoActivity = undoActivityData(undoUrl, me, followActivity) | 44 | const undoActivity = undoActivityData(undoUrl, me, followActivity) |
45 | 45 | ||
46 | t.afterCommit(() => unicastTo(undoActivity, me, following.inboxUrl)) | 46 | t.afterCommit(() => unicastTo(undoActivity, me, following.inboxUrl)) |
@@ -61,7 +61,7 @@ async function sendUndoAnnounce (byActor: MActorLight, videoShare: MVideoShare, | |||
61 | async function sendUndoLike (byActor: MActor, video: MVideoAccountLight, t: Transaction) { | 61 | async function sendUndoLike (byActor: MActor, video: MVideoAccountLight, t: Transaction) { |
62 | logger.info('Creating job to undo a like of video %s.', video.url) | 62 | logger.info('Creating job to undo a like of video %s.', video.url) |
63 | 63 | ||
64 | const likeUrl = getVideoLikeActivityPubUrl(byActor, video) | 64 | const likeUrl = getVideoLikeActivityPubUrlByLocalActor(byActor, video) |
65 | const likeActivity = buildLikeActivity(likeUrl, byActor, video) | 65 | const likeActivity = buildLikeActivity(likeUrl, byActor, video) |
66 | 66 | ||
67 | return sendUndoVideoRelatedActivity({ byActor, video, url: likeUrl, activity: likeActivity, transaction: t }) | 67 | return sendUndoVideoRelatedActivity({ byActor, video, url: likeUrl, activity: likeActivity, transaction: t }) |
@@ -70,7 +70,7 @@ async function sendUndoLike (byActor: MActor, video: MVideoAccountLight, t: Tran | |||
70 | async function sendUndoDislike (byActor: MActor, video: MVideoAccountLight, t: Transaction) { | 70 | async function sendUndoDislike (byActor: MActor, video: MVideoAccountLight, t: Transaction) { |
71 | logger.info('Creating job to undo a dislike of video %s.', video.url) | 71 | logger.info('Creating job to undo a dislike of video %s.', video.url) |
72 | 72 | ||
73 | const dislikeUrl = getVideoDislikeActivityPubUrl(byActor, video) | 73 | const dislikeUrl = getVideoDislikeActivityPubUrlByLocalActor(byActor, video) |
74 | const dislikeActivity = buildDislikeActivity(dislikeUrl, byActor, video) | 74 | const dislikeActivity = buildDislikeActivity(dislikeUrl, byActor, video) |
75 | 75 | ||
76 | return sendUndoVideoRelatedActivity({ byActor, video, url: dislikeUrl, activity: dislikeActivity, transaction: t }) | 76 | return sendUndoVideoRelatedActivity({ byActor, video, url: dislikeUrl, activity: dislikeActivity, transaction: t }) |
diff --git a/server/lib/activitypub/send/send-view.ts b/server/lib/activitypub/send/send-view.ts index 3358188a2..9254dc7c5 100644 --- a/server/lib/activitypub/send/send-view.ts +++ b/server/lib/activitypub/send/send-view.ts | |||
@@ -1,17 +1,17 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { MActorAudience, MVideoImmutable, MVideoUrl } from '@server/types/models' | ||
2 | import { ActivityAudience, ActivityView } from '../../../../shared/models/activitypub' | 3 | import { ActivityAudience, ActivityView } from '../../../../shared/models/activitypub' |
4 | import { logger } from '../../../helpers/logger' | ||
3 | import { ActorModel } from '../../../models/activitypub/actor' | 5 | import { ActorModel } from '../../../models/activitypub/actor' |
4 | import { getVideoLikeActivityPubUrl } from '../url' | ||
5 | import { sendVideoRelatedActivity } from './utils' | ||
6 | import { audiencify, getAudience } from '../audience' | 6 | import { audiencify, getAudience } from '../audience' |
7 | import { logger } from '../../../helpers/logger' | 7 | import { getLocalVideoViewActivityPubUrl } from '../url' |
8 | import { MActorAudience, MVideoImmutable, MVideoUrl } from '@server/types/models' | 8 | import { sendVideoRelatedActivity } from './utils' |
9 | 9 | ||
10 | async function sendView (byActor: ActorModel, video: MVideoImmutable, t: Transaction) { | 10 | async function sendView (byActor: ActorModel, video: MVideoImmutable, t: Transaction) { |
11 | logger.info('Creating job to send view of %s.', video.url) | 11 | logger.info('Creating job to send view of %s.', video.url) |
12 | 12 | ||
13 | const activityBuilder = (audience: ActivityAudience) => { | 13 | const activityBuilder = (audience: ActivityAudience) => { |
14 | const url = getVideoLikeActivityPubUrl(byActor, video) | 14 | const url = getLocalVideoViewActivityPubUrl(byActor, video) |
15 | 15 | ||
16 | return buildViewActivity(url, byActor, video, audience) | 16 | return buildViewActivity(url, byActor, video, audience) |
17 | } | 17 | } |