From 4e50b6a1c9a3eb261e04ede73241648e6edf21d6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Nov 2017 14:44:51 +0100 Subject: Add shares forward and collection on videos/video channels --- server/lib/activitypub/process/misc.ts | 57 +++++++++++- server/lib/activitypub/process/process-add.ts | 16 ++-- server/lib/activitypub/process/process-announce.ts | 100 +++++++++++++++++---- server/lib/activitypub/process/process-create.ts | 12 ++- server/lib/activitypub/send/misc.ts | 27 ++++-- server/lib/activitypub/send/send-announce.ts | 86 +++++++++++++++--- server/lib/activitypub/send/send-create.ts | 6 +- server/lib/activitypub/send/send-like.ts | 4 +- server/lib/activitypub/send/send-undo.ts | 4 +- server/lib/activitypub/share.ts | 6 +- server/lib/activitypub/url.ts | 14 +-- 11 files changed, 270 insertions(+), 62 deletions(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/process/misc.ts b/server/lib/activitypub/process/misc.ts index eefbe2884..f20e588ab 100644 --- a/server/lib/activitypub/process/misc.ts +++ b/server/lib/activitypub/process/misc.ts @@ -1,13 +1,16 @@ import * as magnetUtil from 'magnet-uri' import { VideoTorrentObject } from '../../../../shared' import { VideoChannelObject } from '../../../../shared/models/activitypub/objects/video-channel-object' +import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' import { isVideoFileInfoHashValid } from '../../../helpers/custom-validators/videos' +import { doRequest } from '../../../helpers/requests' +import { database as db } from '../../../initializers' import { ACTIVITY_PUB, VIDEO_MIMETYPE_EXT } from '../../../initializers/constants' import { AccountInstance } from '../../../models/account/account-interface' import { VideoChannelInstance } from '../../../models/video/video-channel-interface' import { VideoFileAttributes } from '../../../models/video/video-file-interface' import { VideoAttributes, VideoInstance } from '../../../models/video/video-interface' -import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' +import { getOrCreateAccountAndServer } from '../account' function videoChannelActivityObjectToDBAttributes (videoChannelObject: VideoChannelObject, account: AccountInstance) { return { @@ -97,10 +100,60 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoInstance, videoO return attributes } +async function addVideoShares (instance: VideoInstance, shares: string[]) { + for (const share of shares) { + // Fetch url + const json = await doRequest({ + uri: share, + json: true + }) + const actor = json['actor'] + if (!actor) continue + + const account = await getOrCreateAccountAndServer(actor) + + const entry = { + accountId: account.id, + videoId: instance.id + } + + await db.VideoShare.findOrCreate({ + where: entry, + defaults: entry + }) + } +} + +async function addVideoChannelShares (instance: VideoChannelInstance, shares: string[]) { + for (const share of shares) { + // Fetch url + const json = await doRequest({ + uri: share, + json: true + }) + const actor = json['actor'] + if (!actor) continue + + const account = await getOrCreateAccountAndServer(actor) + + const entry = { + accountId: account.id, + videoChannelId: instance.id + } + + await db.VideoChannelShare.findOrCreate({ + where: entry, + defaults: entry + }) + } +} + // --------------------------------------------------------------------------- export { videoFileActivityUrlToDBAttributes, videoActivityObjectToDBAttributes, - videoChannelActivityObjectToDBAttributes + videoChannelActivityObjectToDBAttributes, + addVideoChannelShares, + addVideoShares } diff --git a/server/lib/activitypub/process/process-add.ts b/server/lib/activitypub/process/process-add.ts index 98280b9f0..e6bf63eb2 100644 --- a/server/lib/activitypub/process/process-add.ts +++ b/server/lib/activitypub/process/process-add.ts @@ -11,7 +11,7 @@ import { VideoInstance } from '../../../models/video/video-interface' import { getOrCreateAccountAndServer } from '../account' import { getOrCreateVideoChannel } from '../video-channels' import { generateThumbnailFromUrl } from '../videos' -import { videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc' +import { addVideoShares, videoActivityObjectToDBAttributes, videoFileActivityUrlToDBAttributes } from './misc' async function processAddActivity (activity: ActivityAdd) { const activityObject = activity.object @@ -37,12 +37,10 @@ export { // --------------------------------------------------------------------------- -async function processAddVideo ( - account: AccountInstance, - activity: ActivityAdd, - videoChannel: VideoChannelInstance, - videoToCreateData: VideoTorrentObject -) { +async function processAddVideo (account: AccountInstance, + activity: ActivityAdd, + videoChannel: VideoChannelInstance, + videoToCreateData: VideoTorrentObject) { const options = { arguments: [ account, activity, videoChannel, videoToCreateData ], errorMessage: 'Cannot insert the remote video with many retries.' @@ -59,6 +57,10 @@ async function processAddVideo ( await createRates(videoToCreateData.dislikes.orderedItems, video, 'dislike') } + if (videoToCreateData.shares && Array.isArray(videoToCreateData.shares.orderedItems)) { + await addVideoShares(video, videoToCreateData.shares.orderedItems) + } + return video } diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts index d8532d3a1..2aa9ad5c7 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/lib/activitypub/process/process-announce.ts @@ -1,34 +1,23 @@ -import { ActivityAnnounce } from '../../../../shared/models/activitypub/activity' +import { ActivityAdd, ActivityAnnounce, ActivityCreate } from '../../../../shared/models/activitypub/activity' +import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' import { database as db } from '../../../initializers/index' +import { AccountInstance } from '../../../models/account/account-interface' import { VideoInstance } from '../../../models/index' import { VideoChannelInstance } from '../../../models/video/video-channel-interface' +import { getOrCreateAccountAndServer } from '../account' +import { forwardActivity } from '../send/misc' import { processAddActivity } from './process-add' import { processCreateActivity } from './process-create' -import { getOrCreateAccountAndServer } from '../account' async function processAnnounceActivity (activity: ActivityAnnounce) { const announcedActivity = activity.object const accountAnnouncer = await getOrCreateAccountAndServer(activity.actor) if (announcedActivity.type === 'Create' && announcedActivity.object.type === 'VideoChannel') { - // Add share entry - const videoChannel: VideoChannelInstance = await processCreateActivity(announcedActivity) - await db.VideoChannelShare.create({ - accountId: accountAnnouncer.id, - videoChannelId: videoChannel.id - }) - - return undefined + return processVideoChannelShare(accountAnnouncer, activity) } else if (announcedActivity.type === 'Add' && announcedActivity.object.type === 'Video') { - // Add share entry - const video: VideoInstance = await processAddActivity(announcedActivity) - await db.VideoShare.create({ - accountId: accountAnnouncer.id, - videoId: video.id - }) - - return undefined + return processVideoShare(accountAnnouncer, activity) } logger.warn( @@ -44,3 +33,78 @@ async function processAnnounceActivity (activity: ActivityAnnounce) { export { processAnnounceActivity } + +// --------------------------------------------------------------------------- + +function processVideoChannelShare (accountAnnouncer: AccountInstance, activity: ActivityAnnounce) { + const options = { + arguments: [ accountAnnouncer, activity ], + errorMessage: 'Cannot share the video channel with many retries.' + } + + return retryTransactionWrapper(shareVideoChannel, options) +} + +async function shareVideoChannel (accountAnnouncer: AccountInstance, activity: ActivityAnnounce) { + const announcedActivity = activity.object as ActivityCreate + + return db.sequelize.transaction(async t => { + // Add share entry + const videoChannel: VideoChannelInstance = await processCreateActivity(announcedActivity) + const share = { + accountId: accountAnnouncer.id, + videoChannelId: videoChannel.id + } + + const [ , created ] = await db.VideoChannelShare.findOrCreate({ + where: share, + defaults: share, + transaction: t + }) + + if (videoChannel.isOwned() && created === true) { + // Don't resend the activity to the sender + const exceptions = [ accountAnnouncer ] + await forwardActivity(activity, t, exceptions) + } + + return undefined + }) +} + +function processVideoShare (accountAnnouncer: AccountInstance, activity: ActivityAnnounce) { + const options = { + arguments: [ accountAnnouncer, activity ], + errorMessage: 'Cannot share the video with many retries.' + } + + return retryTransactionWrapper(shareVideo, options) +} + +function shareVideo (accountAnnouncer: AccountInstance, activity: ActivityAnnounce) { + const announcedActivity = activity.object as ActivityAdd + + return db.sequelize.transaction(async t => { + // Add share entry + const video: VideoInstance = await processAddActivity(announcedActivity) + + const share = { + accountId: accountAnnouncer.id, + videoId: video.id + } + + const [ , created ] = await db.VideoShare.findOrCreate({ + where: share, + defaults: share, + transaction: t + }) + + if (video.isOwned() && created === true) { + // Don't resend the activity to the sender + const exceptions = [ accountAnnouncer ] + await forwardActivity(activity, t, exceptions) + } + + return undefined + }) +} diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index 1f982598b..c88082bbf 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts @@ -8,7 +8,7 @@ import { AccountInstance } from '../../../models/account/account-interface' import { getOrCreateAccountAndServer } from '../account' import { forwardActivity } from '../send/misc' import { getVideoChannelActivityPubUrl } from '../url' -import { videoChannelActivityObjectToDBAttributes } from './misc' +import { addVideoChannelShares, videoChannelActivityObjectToDBAttributes } from './misc' async function processCreateActivity (activity: ActivityCreate) { const activityObject = activity.object @@ -92,13 +92,19 @@ async function processCreateView (byAccount: AccountInstance, activity: Activity } } -function processCreateVideoChannel (account: AccountInstance, videoChannelToCreateData: VideoChannelObject) { +async function processCreateVideoChannel (account: AccountInstance, videoChannelToCreateData: VideoChannelObject) { const options = { arguments: [ account, videoChannelToCreateData ], errorMessage: 'Cannot insert the remote video channel with many retries.' } - return retryTransactionWrapper(addRemoteVideoChannel, options) + const videoChannel = await retryTransactionWrapper(addRemoteVideoChannel, options) + + if (videoChannelToCreateData.shares && Array.isArray(videoChannelToCreateData.shares.orderedItems)) { + await addVideoChannelShares(videoChannel, videoChannelToCreateData.shares.orderedItems) + } + + return videoChannel } function addRemoteVideoChannel (account: AccountInstance, videoChannelToCreateData: VideoChannelObject) { diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts index 444c1cbd6..fd1add68e 100644 --- a/server/lib/activitypub/send/misc.ts +++ b/server/lib/activitypub/send/misc.ts @@ -1,13 +1,14 @@ import { Transaction } from 'sequelize' +import { Activity } from '../../../../shared/models/activitypub/activity' import { logger } from '../../../helpers/logger' import { ACTIVITY_PUB, database as db } from '../../../initializers' import { AccountInstance } from '../../../models/account/account-interface' +import { VideoChannelInstance } from '../../../models/index' +import { VideoInstance } from '../../../models/video/video-interface' import { activitypubHttpJobScheduler, ActivityPubHttpPayload } from '../../jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler' -import { VideoInstance } from '../../../models/video/video-interface' -import { Activity } from '../../../../shared/models/activitypub/activity' async function forwardActivity ( activity: Activity, @@ -85,9 +86,16 @@ function getOriginVideoAudience (video: VideoInstance, accountsInvolvedInVideo: } } -function getVideoFollowersAudience (accountsInvolvedInVideo: AccountInstance[]) { +function getOriginVideoChannelAudience (videoChannel: VideoChannelInstance, accountsInvolved: AccountInstance[]) { + return { + to: [ videoChannel.Account.url ], + cc: accountsInvolved.map(a => a.followersUrl) + } +} + +function getObjectFollowersAudience (accountsInvolvedInObject: AccountInstance[]) { return { - to: accountsInvolvedInVideo.map(a => a.followersUrl), + to: accountsInvolvedInObject.map(a => a.followersUrl), cc: [] } } @@ -99,6 +107,13 @@ async function getAccountsInvolvedInVideo (video: VideoInstance) { return accountsToForwardView } +async function getAccountsInvolvedInVideoChannel (videoChannel: VideoChannelInstance) { + const accountsToForwardView = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id) + accountsToForwardView.push(videoChannel.Account) + + return accountsToForwardView +} + async function getAudience (accountSender: AccountInstance, isPublic = true) { const followerInboxUrls = await accountSender.getFollowerSharedInboxUrls() @@ -131,10 +146,12 @@ async function computeFollowerUris (toAccountFollower: AccountInstance[], follow export { broadcastToFollowers, + getOriginVideoChannelAudience, unicastTo, getAudience, getOriginVideoAudience, getAccountsInvolvedInVideo, - getVideoFollowersAudience, + getAccountsInvolvedInVideoChannel, + getObjectFollowersAudience, forwardActivity } diff --git a/server/lib/activitypub/send/send-announce.ts b/server/lib/activitypub/send/send-announce.ts index b8ea51bc0..efc23af46 100644 --- a/server/lib/activitypub/send/send-announce.ts +++ b/server/lib/activitypub/send/send-announce.ts @@ -1,34 +1,96 @@ import { Transaction } from 'sequelize' import { ActivityAdd } from '../../../../shared/index' -import { ActivityAnnounce, ActivityCreate } from '../../../../shared/models/activitypub/activity' +import { ActivityAnnounce, ActivityAudience, ActivityCreate } from '../../../../shared/models/activitypub/activity' import { AccountInstance, VideoInstance } from '../../../models' import { VideoChannelInstance } from '../../../models/video/video-channel-interface' import { getAnnounceActivityPubUrl } from '../url' -import { broadcastToFollowers } from './misc' +import { + broadcastToFollowers, + getAccountsInvolvedInVideo, + getAccountsInvolvedInVideoChannel, + getAudience, + getObjectFollowersAudience, + getOriginVideoAudience, + getOriginVideoChannelAudience, + unicastTo +} from './misc' import { addActivityData } from './send-add' import { createActivityData } from './send-create' -async function sendVideoAnnounce (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { +async function buildVideoAnnounceToFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { const url = getAnnounceActivityPubUrl(video.url, byAccount) const videoChannel = video.VideoChannel const announcedActivity = await addActivityData(url, videoChannel.Account, video, videoChannel.url, video.toActivityPubObject()) - const data = await announceActivityData(url, byAccount, announcedActivity) + const accountsToForwardView = await getAccountsInvolvedInVideo(video) + const audience = getObjectFollowersAudience(accountsToForwardView) + const data = await announceActivityData(url, byAccount, announcedActivity, audience) + + return data +} + +async function sendVideoAnnounceToFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { + const data = await buildVideoAnnounceToFollowers(byAccount, video, t) + return broadcastToFollowers(data, byAccount, [ byAccount ], t) } -async function sendVideoChannelAnnounce (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { +async function sendVideoAnnounceToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { + const url = getAnnounceActivityPubUrl(video.url, byAccount) + + const videoChannel = video.VideoChannel + const announcedActivity = await addActivityData(url, videoChannel.Account, video, videoChannel.url, video.toActivityPubObject()) + + const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video) + const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) + const data = await createActivityData(url, byAccount, announcedActivity, audience) + + return unicastTo(data, byAccount, videoChannel.Account.sharedInboxUrl, t) +} + +async function buildVideoChannelAnnounceToFollowers (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount) const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject()) - const data = await announceActivityData(url, byAccount, announcedActivity) + const accountsToForwardView = await getAccountsInvolvedInVideoChannel(videoChannel) + const audience = getObjectFollowersAudience(accountsToForwardView) + const data = await announceActivityData(url, byAccount, announcedActivity, audience) + + return data +} + +async function sendVideoChannelAnnounceToFollowers (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { + const data = await buildVideoChannelAnnounceToFollowers(byAccount, videoChannel, t) + return broadcastToFollowers(data, byAccount, [ byAccount ], t) } -async function announceActivityData (url: string, byAccount: AccountInstance, object: ActivityCreate | ActivityAdd) { +async function sendVideoChannelAnnounceToOrigin (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { + const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount) + const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject()) + + const accountsInvolvedInVideo = await getAccountsInvolvedInVideoChannel(videoChannel) + const audience = getOriginVideoChannelAudience(videoChannel, accountsInvolvedInVideo) + const data = await createActivityData(url, byAccount, announcedActivity, audience) + + return unicastTo(data, byAccount, videoChannel.Account.sharedInboxUrl, t) +} + +async function announceActivityData ( + url: string, + byAccount: AccountInstance, + object: ActivityCreate | ActivityAdd, + audience?: ActivityAudience +) { + if (!audience) { + audience = await getAudience(byAccount) + } + const activity: ActivityAnnounce = { type: 'Announce', + to: audience.to, + cc: audience.cc, id: url, actor: byAccount.url, object @@ -40,7 +102,11 @@ async function announceActivityData (url: string, byAccount: AccountInstance, ob // --------------------------------------------------------------------------- export { - sendVideoAnnounce, - sendVideoChannelAnnounce, - announceActivityData + sendVideoAnnounceToFollowers, + sendVideoChannelAnnounceToFollowers, + sendVideoAnnounceToOrigin, + sendVideoChannelAnnounceToOrigin, + announceActivityData, + buildVideoAnnounceToFollowers, + buildVideoChannelAnnounceToFollowers } diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index 113d89233..bf66606c1 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts @@ -9,7 +9,7 @@ import { getAccountsInvolvedInVideo, getAudience, getOriginVideoAudience, - getVideoFollowersAudience, + getObjectFollowersAudience, unicastTo } from './misc' @@ -47,7 +47,7 @@ async function sendCreateViewToVideoFollowers (byAccount: AccountInstance, video const viewActivity = createViewActivityData(byAccount, video) const accountsToForwardView = await getAccountsInvolvedInVideo(video) - const audience = getVideoFollowersAudience(accountsToForwardView) + const audience = getObjectFollowersAudience(accountsToForwardView) const data = await createActivityData(url, byAccount, viewActivity, audience) // Use the server account to send the view, because it could be an unregistered account @@ -72,7 +72,7 @@ async function sendCreateDislikeToVideoFollowers (byAccount: AccountInstance, vi const dislikeActivity = createDislikeActivityData(byAccount, video) const accountsToForwardView = await getAccountsInvolvedInVideo(video) - const audience = getVideoFollowersAudience(accountsToForwardView) + const audience = getObjectFollowersAudience(accountsToForwardView) const data = await createActivityData(url, byAccount, dislikeActivity, audience) const followersException = [ byAccount ] diff --git a/server/lib/activitypub/send/send-like.ts b/server/lib/activitypub/send/send-like.ts index 8ca775bf3..41b879b8a 100644 --- a/server/lib/activitypub/send/send-like.ts +++ b/server/lib/activitypub/send/send-like.ts @@ -7,7 +7,7 @@ import { getAccountsInvolvedInVideo, getAudience, getOriginVideoAudience, - getVideoFollowersAudience, + getObjectFollowersAudience, unicastTo } from './misc' @@ -25,7 +25,7 @@ async function sendLikeToVideoFollowers (byAccount: AccountInstance, video: Vide const url = getVideoLikeActivityPubUrl(byAccount, video) const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video) - const audience = getVideoFollowersAudience(accountsInvolvedInVideo) + const audience = getObjectFollowersAudience(accountsInvolvedInVideo) const data = await likeActivityData(url, byAccount, video, audience) const toAccountsFollowers = await getAccountsInvolvedInVideo(video) diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts index 79fc113f0..9b732df40 100644 --- a/server/lib/activitypub/send/send-undo.ts +++ b/server/lib/activitypub/send/send-undo.ts @@ -10,7 +10,7 @@ import { AccountInstance } from '../../../models' import { AccountFollowInstance } from '../../../models/account/account-follow-interface' import { VideoInstance } from '../../../models/video/video-interface' import { getAccountFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url' -import { broadcastToFollowers, getAccountsInvolvedInVideo, getAudience, getVideoFollowersAudience, unicastTo } from './misc' +import { broadcastToFollowers, getAccountsInvolvedInVideo, getAudience, getObjectFollowersAudience, unicastTo } from './misc' import { createActivityData, createDislikeActivityData } from './send-create' import { followActivityData } from './send-follow' import { likeActivityData } from './send-like' @@ -43,7 +43,7 @@ async function sendUndoLikeToVideoFollowers (byAccount: AccountInstance, video: const undoUrl = getUndoActivityPubUrl(likeUrl) const toAccountsFollowers = await getAccountsInvolvedInVideo(video) - const audience = getVideoFollowersAudience(toAccountsFollowers) + const audience = getObjectFollowersAudience(toAccountsFollowers) const object = await likeActivityData(likeUrl, byAccount, video) const data = await undoActivityData(undoUrl, byAccount, object, audience) diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index 689e200a6..e14b0f50c 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts @@ -3,7 +3,7 @@ import { getServerAccount } from '../../helpers/utils' import { database as db } from '../../initializers' import { VideoChannelInstance } from '../../models/index' import { VideoInstance } from '../../models/video/video-interface' -import { sendVideoAnnounce, sendVideoChannelAnnounce } from './send/send-announce' +import { sendVideoAnnounceToFollowers, sendVideoChannelAnnounceToFollowers } from './send/send-announce' async function shareVideoChannelByServer (videoChannel: VideoChannelInstance, t: Transaction) { const serverAccount = await getServerAccount() @@ -13,7 +13,7 @@ async function shareVideoChannelByServer (videoChannel: VideoChannelInstance, t: videoChannelId: videoChannel.id }, { transaction: t }) - return sendVideoChannelAnnounce(serverAccount, videoChannel, t) + return sendVideoChannelAnnounceToFollowers(serverAccount, videoChannel, t) } async function shareVideoByServer (video: VideoInstance, t: Transaction) { @@ -24,7 +24,7 @@ async function shareVideoByServer (video: VideoInstance, t: Transaction) { videoId: video.id }, { transaction: t }) - return sendVideoAnnounce(serverAccount, video, t) + return sendVideoAnnounceToFollowers(serverAccount, video, t) } export { diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts index 17395a99b..6475c4218 100644 --- a/server/lib/activitypub/url.ts +++ b/server/lib/activitypub/url.ts @@ -22,37 +22,37 @@ function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseInstance) { } function getVideoViewActivityPubUrl (byAccount: AccountInstance, video: VideoInstance) { - return video.url + '#views/' + byAccount.uuid + '/' + new Date().toISOString() + return video.url + '/views/' + byAccount.uuid + '/' + new Date().toISOString() } function getVideoLikeActivityPubUrl (byAccount: AccountInstance, video: VideoInstance) { - return byAccount.url + '#likes/' + video.id + return byAccount.url + '/likes/' + video.id } function getVideoDislikeActivityPubUrl (byAccount: AccountInstance, video: VideoInstance) { - return byAccount.url + '#dislikes/' + video.id + return byAccount.url + '/dislikes/' + video.id } function getAccountFollowActivityPubUrl (accountFollow: AccountFollowInstance) { const me = accountFollow.AccountFollower const following = accountFollow.AccountFollowing - return me.url + '#follows/' + following.id + return me.url + '/follows/' + following.id } function getAccountFollowAcceptActivityPubUrl (accountFollow: AccountFollowInstance) { const follower = accountFollow.AccountFollower const me = accountFollow.AccountFollowing - return follower.url + '#accepts/follows/' + me.id + return follower.url + '/accepts/follows/' + me.id } function getAnnounceActivityPubUrl (originalUrl: string, byAccount: AccountInstance) { - return originalUrl + '#announces/' + byAccount.id + return originalUrl + '/announces/' + byAccount.id } function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) { - return originalUrl + '#updates/' + updatedAt + return originalUrl + '/updates/' + updatedAt } function getUndoActivityPubUrl (originalUrl: string) { -- cgit v1.2.3