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 | |
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')
-rw-r--r-- | server/lib/activitypub/process/process-dislike.ts | 16 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-follow.ts | 16 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-like.ts | 13 | ||||
-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 | ||||
-rw-r--r-- | server/lib/activitypub/share.ts | 6 | ||||
-rw-r--r-- | server/lib/activitypub/url.ts | 93 | ||||
-rw-r--r-- | server/lib/activitypub/video-rates.ts | 10 |
14 files changed, 118 insertions, 118 deletions
diff --git a/server/lib/activitypub/process/process-dislike.ts b/server/lib/activitypub/process/process-dislike.ts index 0cd204501..635c8bfcc 100644 --- a/server/lib/activitypub/process/process-dislike.ts +++ b/server/lib/activitypub/process/process-dislike.ts | |||
@@ -3,11 +3,10 @@ import { DislikeObject } from '../../../../shared/models/activitypub/objects' | |||
3 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 3 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
4 | import { sequelizeTypescript } from '../../../initializers/database' | 4 | import { sequelizeTypescript } from '../../../initializers/database' |
5 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 5 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
6 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | ||
7 | import { forwardVideoRelatedActivity } from '../send/utils' | ||
8 | import { getVideoDislikeActivityPubUrl } from '../url' | ||
9 | import { APProcessorOptions } from '../../../types/activitypub-processor.model' | 6 | import { APProcessorOptions } from '../../../types/activitypub-processor.model' |
10 | import { MActorSignature } from '../../../types/models' | 7 | import { MActorSignature } from '../../../types/models' |
8 | import { forwardVideoRelatedActivity } from '../send/utils' | ||
9 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | ||
11 | 10 | ||
12 | async function processDislikeActivity (options: APProcessorOptions<ActivityCreate | ActivityDislike>) { | 11 | async function processDislikeActivity (options: APProcessorOptions<ActivityCreate | ActivityDislike>) { |
13 | const { activity, byActor } = options | 12 | const { activity, byActor } = options |
@@ -23,7 +22,10 @@ export { | |||
23 | // --------------------------------------------------------------------------- | 22 | // --------------------------------------------------------------------------- |
24 | 23 | ||
25 | async function processDislike (activity: ActivityCreate | ActivityDislike, byActor: MActorSignature) { | 24 | async function processDislike (activity: ActivityCreate | ActivityDislike, byActor: MActorSignature) { |
26 | const dislikeObject = activity.type === 'Dislike' ? activity.object : (activity.object as DislikeObject).object | 25 | const dislikeObject = activity.type === 'Dislike' |
26 | ? activity.object | ||
27 | : (activity.object as DislikeObject).object | ||
28 | |||
27 | const byAccount = byActor.Account | 29 | const byAccount = byActor.Account |
28 | 30 | ||
29 | if (!byAccount) throw new Error('Cannot create dislike with the non account actor ' + byActor.url) | 31 | if (!byAccount) throw new Error('Cannot create dislike with the non account actor ' + byActor.url) |
@@ -31,9 +33,7 @@ async function processDislike (activity: ActivityCreate | ActivityDislike, byAct | |||
31 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: dislikeObject }) | 33 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: dislikeObject }) |
32 | 34 | ||
33 | return sequelizeTypescript.transaction(async t => { | 35 | return sequelizeTypescript.transaction(async t => { |
34 | const url = getVideoDislikeActivityPubUrl(byActor, video) | 36 | const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id) |
35 | |||
36 | const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, url) | ||
37 | if (existingRate && existingRate.type === 'dislike') return | 37 | if (existingRate && existingRate.type === 'dislike') return |
38 | 38 | ||
39 | await video.increment('dislikes', { transaction: t }) | 39 | await video.increment('dislikes', { transaction: t }) |
@@ -46,7 +46,7 @@ async function processDislike (activity: ActivityCreate | ActivityDislike, byAct | |||
46 | rate.type = 'dislike' | 46 | rate.type = 'dislike' |
47 | rate.videoId = video.id | 47 | rate.videoId = video.id |
48 | rate.accountId = byAccount.id | 48 | rate.accountId = byAccount.id |
49 | rate.url = url | 49 | rate.url = activity.id |
50 | 50 | ||
51 | await rate.save({ transaction: t }) | 51 | await rate.save({ transaction: t }) |
52 | 52 | ||
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index 7eb7e828d..076ad9cf4 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts | |||
@@ -15,9 +15,11 @@ import { getServerActor } from '@server/models/application/application' | |||
15 | 15 | ||
16 | async function processFollowActivity (options: APProcessorOptions<ActivityFollow>) { | 16 | async function processFollowActivity (options: APProcessorOptions<ActivityFollow>) { |
17 | const { activity, byActor } = options | 17 | const { activity, byActor } = options |
18 | const activityObject = getAPId(activity.object) | ||
19 | 18 | ||
20 | return retryTransactionWrapper(processFollow, byActor, activityObject) | 19 | const activityId = activity.id |
20 | const objectId = getAPId(activity.object) | ||
21 | |||
22 | return retryTransactionWrapper(processFollow, byActor, activityId, objectId) | ||
21 | } | 23 | } |
22 | 24 | ||
23 | // --------------------------------------------------------------------------- | 25 | // --------------------------------------------------------------------------- |
@@ -28,7 +30,7 @@ export { | |||
28 | 30 | ||
29 | // --------------------------------------------------------------------------- | 31 | // --------------------------------------------------------------------------- |
30 | 32 | ||
31 | async function processFollow (byActor: MActorSignature, targetActorURL: string) { | 33 | async function processFollow (byActor: MActorSignature, activityId: string, targetActorURL: string) { |
32 | const { actorFollow, created, isFollowingInstance, targetActor } = await sequelizeTypescript.transaction(async t => { | 34 | const { actorFollow, created, isFollowingInstance, targetActor } = await sequelizeTypescript.transaction(async t => { |
33 | const targetActor = await ActorModel.loadByUrlAndPopulateAccountAndChannel(targetActorURL, t) | 35 | const targetActor = await ActorModel.loadByUrlAndPopulateAccountAndChannel(targetActorURL, t) |
34 | 36 | ||
@@ -41,7 +43,7 @@ async function processFollow (byActor: MActorSignature, targetActorURL: string) | |||
41 | if (isFollowingInstance && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { | 43 | if (isFollowingInstance && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) { |
42 | logger.info('Rejecting %s because instance followers are disabled.', targetActor.url) | 44 | logger.info('Rejecting %s because instance followers are disabled.', targetActor.url) |
43 | 45 | ||
44 | await sendReject(byActor, targetActor) | 46 | await sendReject(activityId, byActor, targetActor) |
45 | 47 | ||
46 | return { actorFollow: undefined as MActorFollowActors } | 48 | return { actorFollow: undefined as MActorFollowActors } |
47 | } | 49 | } |
@@ -54,7 +56,11 @@ async function processFollow (byActor: MActorSignature, targetActorURL: string) | |||
54 | defaults: { | 56 | defaults: { |
55 | actorId: byActor.id, | 57 | actorId: byActor.id, |
56 | targetActorId: targetActor.id, | 58 | targetActorId: targetActor.id, |
57 | state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL ? 'pending' : 'accepted' | 59 | url: activityId, |
60 | |||
61 | state: CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL | ||
62 | ? 'pending' | ||
63 | : 'accepted' | ||
58 | }, | 64 | }, |
59 | transaction: t | 65 | transaction: t |
60 | }) | 66 | }) |
diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts index b800a5618..6acc097b1 100644 --- a/server/lib/activitypub/process/process-like.ts +++ b/server/lib/activitypub/process/process-like.ts | |||
@@ -1,13 +1,12 @@ | |||
1 | import { ActivityLike } from '../../../../shared/models/activitypub' | 1 | import { ActivityLike } from '../../../../shared/models/activitypub' |
2 | import { getAPId } from '../../../helpers/activitypub' | ||
2 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 3 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
3 | import { sequelizeTypescript } from '../../../initializers/database' | 4 | import { sequelizeTypescript } from '../../../initializers/database' |
4 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 5 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
5 | import { forwardVideoRelatedActivity } from '../send/utils' | ||
6 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | ||
7 | import { getVideoLikeActivityPubUrl } from '../url' | ||
8 | import { getAPId } from '../../../helpers/activitypub' | ||
9 | import { APProcessorOptions } from '../../../types/activitypub-processor.model' | 6 | import { APProcessorOptions } from '../../../types/activitypub-processor.model' |
10 | import { MActorSignature } from '../../../types/models' | 7 | import { MActorSignature } from '../../../types/models' |
8 | import { forwardVideoRelatedActivity } from '../send/utils' | ||
9 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | ||
11 | 10 | ||
12 | async function processLikeActivity (options: APProcessorOptions<ActivityLike>) { | 11 | async function processLikeActivity (options: APProcessorOptions<ActivityLike>) { |
13 | const { activity, byActor } = options | 12 | const { activity, byActor } = options |
@@ -31,9 +30,7 @@ async function processLikeVideo (byActor: MActorSignature, activity: ActivityLik | |||
31 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoUrl }) | 30 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoUrl }) |
32 | 31 | ||
33 | return sequelizeTypescript.transaction(async t => { | 32 | return sequelizeTypescript.transaction(async t => { |
34 | const url = getVideoLikeActivityPubUrl(byActor, video) | 33 | const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, activity.id) |
35 | |||
36 | const existingRate = await AccountVideoRateModel.loadByAccountAndVideoOrUrl(byAccount.id, video.id, url) | ||
37 | if (existingRate && existingRate.type === 'like') return | 34 | if (existingRate && existingRate.type === 'like') return |
38 | 35 | ||
39 | if (existingRate && existingRate.type === 'dislike') { | 36 | if (existingRate && existingRate.type === 'dislike') { |
@@ -46,7 +43,7 @@ async function processLikeVideo (byActor: MActorSignature, activity: ActivityLik | |||
46 | rate.type = 'like' | 43 | rate.type = 'like' |
47 | rate.videoId = video.id | 44 | rate.videoId = video.id |
48 | rate.accountId = byAccount.id | 45 | rate.accountId = byAccount.id |
49 | rate.url = url | 46 | rate.url = activity.id |
50 | 47 | ||
51 | await rate.save({ transaction: t }) | 48 | await rate.save({ transaction: t }) |
52 | 49 | ||
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 | } |
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index 5e426f5db..1f8a8f3c4 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { VideoShareModel } from '../../models/video/video-share' | 2 | import { VideoShareModel } from '../../models/video/video-share' |
3 | import { sendUndoAnnounce, sendVideoAnnounce } from './send' | 3 | import { sendUndoAnnounce, sendVideoAnnounce } from './send' |
4 | import { getVideoAnnounceActivityPubUrl } from './url' | 4 | import { getLocalVideoAnnounceActivityPubUrl } from './url' |
5 | import * as Bluebird from 'bluebird' | 5 | import * as Bluebird from 'bluebird' |
6 | import { doRequest } from '../../helpers/requests' | 6 | import { doRequest } from '../../helpers/requests' |
7 | import { getOrCreateActorAndServerAndModel } from './actor' | 7 | import { getOrCreateActorAndServerAndModel } from './actor' |
@@ -74,7 +74,7 @@ export { | |||
74 | async function shareByServer (video: MVideo, t: Transaction) { | 74 | async function shareByServer (video: MVideo, t: Transaction) { |
75 | const serverActor = await getServerActor() | 75 | const serverActor = await getServerActor() |
76 | 76 | ||
77 | const serverShareUrl = getVideoAnnounceActivityPubUrl(serverActor, video) | 77 | const serverShareUrl = getLocalVideoAnnounceActivityPubUrl(serverActor, video) |
78 | const [ serverShare ] = await VideoShareModel.findOrCreate({ | 78 | const [ serverShare ] = await VideoShareModel.findOrCreate({ |
79 | defaults: { | 79 | defaults: { |
80 | actorId: serverActor.id, | 80 | actorId: serverActor.id, |
@@ -91,7 +91,7 @@ async function shareByServer (video: MVideo, t: Transaction) { | |||
91 | } | 91 | } |
92 | 92 | ||
93 | async function shareByVideoChannel (video: MVideoAccountLight, t: Transaction) { | 93 | async function shareByVideoChannel (video: MVideoAccountLight, t: Transaction) { |
94 | const videoChannelShareUrl = getVideoAnnounceActivityPubUrl(video.VideoChannel.Actor, video) | 94 | const videoChannelShareUrl = getLocalVideoAnnounceActivityPubUrl(video.VideoChannel.Actor, video) |
95 | const [ videoChannelShare ] = await VideoShareModel.findOrCreate({ | 95 | const [ videoChannelShare ] = await VideoShareModel.findOrCreate({ |
96 | defaults: { | 96 | defaults: { |
97 | actorId: video.VideoChannel.actorId, | 97 | actorId: video.VideoChannel.actorId, |
diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts index 58030be2c..ad6a1d1fd 100644 --- a/server/lib/activitypub/url.ts +++ b/server/lib/activitypub/url.ts | |||
@@ -1,102 +1,102 @@ | |||
1 | import { WEBSERVER } from '../../initializers/constants' | 1 | import { WEBSERVER } from '../../initializers/constants' |
2 | import { | 2 | import { |
3 | MAbuseId, | ||
3 | MActor, | 4 | MActor, |
4 | MActorFollowActors, | 5 | MActorFollowActors, |
5 | MActorId, | 6 | MActorId, |
6 | MActorUrl, | 7 | MActorUrl, |
7 | MCommentId, | 8 | MCommentId, |
8 | MVideoId, | 9 | MVideoId, |
10 | MVideoPlaylistElement, | ||
9 | MVideoUrl, | 11 | MVideoUrl, |
10 | MVideoUUID, | 12 | MVideoUUID |
11 | MAbuseId, | ||
12 | MVideoPlaylistElement | ||
13 | } from '../../types/models' | 13 | } from '../../types/models' |
14 | import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist' | ||
15 | import { MVideoFileVideoUUID } from '../../types/models/video/video-file' | 14 | import { MVideoFileVideoUUID } from '../../types/models/video/video-file' |
15 | import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist' | ||
16 | import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist' | 16 | import { MStreamingPlaylist } from '../../types/models/video/video-streaming-playlist' |
17 | 17 | ||
18 | function getVideoActivityPubUrl (video: MVideoUUID) { | 18 | function getLocalVideoActivityPubUrl (video: MVideoUUID) { |
19 | return WEBSERVER.URL + '/videos/watch/' + video.uuid | 19 | return WEBSERVER.URL + '/videos/watch/' + video.uuid |
20 | } | 20 | } |
21 | 21 | ||
22 | function getVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) { | 22 | function getLocalVideoPlaylistActivityPubUrl (videoPlaylist: MVideoPlaylist) { |
23 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid | 23 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid |
24 | } | 24 | } |
25 | 25 | ||
26 | function getVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) { | 26 | function getLocalVideoPlaylistElementActivityPubUrl (videoPlaylist: MVideoPlaylistUUID, videoPlaylistElement: MVideoPlaylistElement) { |
27 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id | 27 | return WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/videos/' + videoPlaylistElement.id |
28 | } | 28 | } |
29 | 29 | ||
30 | function getVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) { | 30 | function getLocalVideoCacheFileActivityPubUrl (videoFile: MVideoFileVideoUUID) { |
31 | const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' | 31 | const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' |
32 | 32 | ||
33 | return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` | 33 | return `${WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` |
34 | } | 34 | } |
35 | 35 | ||
36 | function getVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) { | 36 | function getLocalVideoCacheStreamingPlaylistActivityPubUrl (video: MVideoUUID, playlist: MStreamingPlaylist) { |
37 | return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` | 37 | return `${WEBSERVER.URL}/redundancy/streaming-playlists/${playlist.getStringType()}/${video.uuid}` |
38 | } | 38 | } |
39 | 39 | ||
40 | function getVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) { | 40 | function getLocalVideoCommentActivityPubUrl (video: MVideoUUID, videoComment: MCommentId) { |
41 | return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id | 41 | return WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id |
42 | } | 42 | } |
43 | 43 | ||
44 | function getVideoChannelActivityPubUrl (videoChannelName: string) { | 44 | function getLocalVideoChannelActivityPubUrl (videoChannelName: string) { |
45 | return WEBSERVER.URL + '/video-channels/' + videoChannelName | 45 | return WEBSERVER.URL + '/video-channels/' + videoChannelName |
46 | } | 46 | } |
47 | 47 | ||
48 | function getAccountActivityPubUrl (accountName: string) { | 48 | function getLocalAccountActivityPubUrl (accountName: string) { |
49 | return WEBSERVER.URL + '/accounts/' + accountName | 49 | return WEBSERVER.URL + '/accounts/' + accountName |
50 | } | 50 | } |
51 | 51 | ||
52 | function getAbuseActivityPubUrl (abuse: MAbuseId) { | 52 | function getLocalAbuseActivityPubUrl (abuse: MAbuseId) { |
53 | return WEBSERVER.URL + '/admin/abuses/' + abuse.id | 53 | return WEBSERVER.URL + '/admin/abuses/' + abuse.id |
54 | } | 54 | } |
55 | 55 | ||
56 | function getVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) { | 56 | function getLocalVideoViewActivityPubUrl (byActor: MActorUrl, video: MVideoId) { |
57 | return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString() | 57 | return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString() |
58 | } | 58 | } |
59 | 59 | ||
60 | function getVideoLikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) { | 60 | function getVideoLikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) { |
61 | return byActor.url + '/likes/' + video.id | 61 | return byActor.url + '/likes/' + video.id |
62 | } | 62 | } |
63 | 63 | ||
64 | function getVideoDislikeActivityPubUrl (byActor: MActorUrl, video: MVideoId) { | 64 | function getVideoDislikeActivityPubUrlByLocalActor (byActor: MActorUrl, video: MVideoId) { |
65 | return byActor.url + '/dislikes/' + video.id | 65 | return byActor.url + '/dislikes/' + video.id |
66 | } | 66 | } |
67 | 67 | ||
68 | function getVideoSharesActivityPubUrl (video: MVideoUrl) { | 68 | function getLocalVideoSharesActivityPubUrl (video: MVideoUrl) { |
69 | return video.url + '/announces' | 69 | return video.url + '/announces' |
70 | } | 70 | } |
71 | 71 | ||
72 | function getVideoCommentsActivityPubUrl (video: MVideoUrl) { | 72 | function getLocalVideoCommentsActivityPubUrl (video: MVideoUrl) { |
73 | return video.url + '/comments' | 73 | return video.url + '/comments' |
74 | } | 74 | } |
75 | 75 | ||
76 | function getVideoLikesActivityPubUrl (video: MVideoUrl) { | 76 | function getLocalVideoLikesActivityPubUrl (video: MVideoUrl) { |
77 | return video.url + '/likes' | 77 | return video.url + '/likes' |
78 | } | 78 | } |
79 | 79 | ||
80 | function getVideoDislikesActivityPubUrl (video: MVideoUrl) { | 80 | function getLocalVideoDislikesActivityPubUrl (video: MVideoUrl) { |
81 | return video.url + '/dislikes' | 81 | return video.url + '/dislikes' |
82 | } | 82 | } |
83 | 83 | ||
84 | function getActorFollowActivityPubUrl (follower: MActor, following: MActorId) { | 84 | function getLocalActorFollowActivityPubUrl (follower: MActor, following: MActorId) { |
85 | return follower.url + '/follows/' + following.id | 85 | return follower.url + '/follows/' + following.id |
86 | } | 86 | } |
87 | 87 | ||
88 | function getActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) { | 88 | function getLocalActorFollowAcceptActivityPubUrl (actorFollow: MActorFollowActors) { |
89 | const follower = actorFollow.ActorFollower | 89 | const follower = actorFollow.ActorFollower |
90 | const me = actorFollow.ActorFollowing | 90 | const me = actorFollow.ActorFollowing |
91 | 91 | ||
92 | return follower.url + '/accepts/follows/' + me.id | 92 | return WEBSERVER.URL + '/accepts/follows/' + follower.id + '/' + me.id |
93 | } | 93 | } |
94 | 94 | ||
95 | function getActorFollowRejectActivityPubUrl (follower: MActorUrl, following: MActorId) { | 95 | function getLocalActorFollowRejectActivityPubUrl (follower: MActorId, following: MActorId) { |
96 | return follower.url + '/rejects/follows/' + following.id | 96 | return WEBSERVER.URL + '/rejects/follows/' + follower.id + '/' + following.id |
97 | } | 97 | } |
98 | 98 | ||
99 | function getVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) { | 99 | function getLocalVideoAnnounceActivityPubUrl (byActor: MActorId, video: MVideoUrl) { |
100 | return video.url + '/announces/' + byActor.id | 100 | return video.url + '/announces/' + byActor.id |
101 | } | 101 | } |
102 | 102 | ||
@@ -113,27 +113,28 @@ function getUndoActivityPubUrl (originalUrl: string) { | |||
113 | } | 113 | } |
114 | 114 | ||
115 | export { | 115 | export { |
116 | getVideoActivityPubUrl, | 116 | getLocalVideoActivityPubUrl, |
117 | getVideoPlaylistElementActivityPubUrl, | 117 | getLocalVideoPlaylistActivityPubUrl, |
118 | getVideoPlaylistActivityPubUrl, | 118 | getLocalVideoPlaylistElementActivityPubUrl, |
119 | getVideoCacheStreamingPlaylistActivityPubUrl, | 119 | getLocalVideoCacheFileActivityPubUrl, |
120 | getVideoChannelActivityPubUrl, | 120 | getLocalVideoCacheStreamingPlaylistActivityPubUrl, |
121 | getAccountActivityPubUrl, | 121 | getLocalVideoCommentActivityPubUrl, |
122 | getAbuseActivityPubUrl, | 122 | getLocalVideoChannelActivityPubUrl, |
123 | getActorFollowActivityPubUrl, | 123 | getLocalAccountActivityPubUrl, |
124 | getActorFollowAcceptActivityPubUrl, | 124 | getLocalAbuseActivityPubUrl, |
125 | getVideoAnnounceActivityPubUrl, | 125 | getLocalActorFollowActivityPubUrl, |
126 | getLocalActorFollowAcceptActivityPubUrl, | ||
127 | getLocalVideoAnnounceActivityPubUrl, | ||
126 | getUpdateActivityPubUrl, | 128 | getUpdateActivityPubUrl, |
127 | getUndoActivityPubUrl, | 129 | getUndoActivityPubUrl, |
128 | getVideoViewActivityPubUrl, | 130 | getVideoLikeActivityPubUrlByLocalActor, |
129 | getVideoLikeActivityPubUrl, | 131 | getLocalVideoViewActivityPubUrl, |
130 | getVideoDislikeActivityPubUrl, | 132 | getVideoDislikeActivityPubUrlByLocalActor, |
131 | getActorFollowRejectActivityPubUrl, | 133 | getLocalActorFollowRejectActivityPubUrl, |
132 | getVideoCommentActivityPubUrl, | ||
133 | getDeleteActivityPubUrl, | 134 | getDeleteActivityPubUrl, |
134 | getVideoSharesActivityPubUrl, | 135 | getLocalVideoSharesActivityPubUrl, |
135 | getVideoCommentsActivityPubUrl, | 136 | getLocalVideoCommentsActivityPubUrl, |
136 | getVideoLikesActivityPubUrl, | 137 | getLocalVideoLikesActivityPubUrl, |
137 | getVideoDislikesActivityPubUrl, | 138 | getLocalVideoDislikesActivityPubUrl, |
138 | getVideoCacheFileActivityPubUrl | 139 | |
139 | } | 140 | } |
diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts index e09e5d9ec..581a2bca1 100644 --- a/server/lib/activitypub/video-rates.ts +++ b/server/lib/activitypub/video-rates.ts | |||
@@ -8,7 +8,7 @@ import { logger } from '../../helpers/logger' | |||
8 | import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' | 8 | import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' |
9 | import { doRequest } from '../../helpers/requests' | 9 | import { doRequest } from '../../helpers/requests' |
10 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' | 10 | import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' |
11 | import { getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from './url' | 11 | import { getVideoDislikeActivityPubUrlByLocalActor, getVideoLikeActivityPubUrlByLocalActor } from './url' |
12 | import { sendDislike } from './send/send-dislike' | 12 | import { sendDislike } from './send/send-dislike' |
13 | import { MAccountActor, MActorUrl, MVideo, MVideoAccountLight, MVideoId } from '../../types/models' | 13 | import { MAccountActor, MActorUrl, MVideo, MVideoAccountLight, MVideoId } from '../../types/models' |
14 | 14 | ||
@@ -82,14 +82,14 @@ async function sendVideoRateChange ( | |||
82 | if (dislikes > 0) await sendDislike(actor, video, t) | 82 | if (dislikes > 0) await sendDislike(actor, video, t) |
83 | } | 83 | } |
84 | 84 | ||
85 | function getRateUrl (rateType: VideoRateType, actor: MActorUrl, video: MVideoId) { | 85 | function getLocalRateUrl (rateType: VideoRateType, actor: MActorUrl, video: MVideoId) { |
86 | return rateType === 'like' | 86 | return rateType === 'like' |
87 | ? getVideoLikeActivityPubUrl(actor, video) | 87 | ? getVideoLikeActivityPubUrlByLocalActor(actor, video) |
88 | : getVideoDislikeActivityPubUrl(actor, video) | 88 | : getVideoDislikeActivityPubUrlByLocalActor(actor, video) |
89 | } | 89 | } |
90 | 90 | ||
91 | export { | 91 | export { |
92 | getRateUrl, | 92 | getLocalRateUrl, |
93 | createRates, | 93 | createRates, |
94 | sendVideoRateChange | 94 | sendVideoRateChange |
95 | } | 95 | } |