X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Furl.ts;h=2e7c56955523241ed6856100e16e504225efceff;hb=d4defe07d26013a75577b30608841fe3f8334308;hp=d98561e3328874119c325a5ccb26bcc04885a624;hpb=40ff57078e15d5b86ee6b71e198b95d3feb78eaf;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts index d98561e33..2e7c56955 100644 --- a/server/lib/activitypub/url.ts +++ b/server/lib/activitypub/url.ts @@ -1,50 +1,89 @@ -import { CONFIG } from '../../initializers/constants' -import { VideoInstance } from '../../models/video/video-interface' -import { VideoChannelInstance } from '../../models/video/video-channel-interface' -import { VideoAbuseInstance } from '../../models/video/video-abuse-interface' -import { AccountFollowInstance } from '../../models/account/account-follow-interface' -import { AccountInstance } from '../../models/account/account-interface' - -function getVideoActivityPubUrl (video: VideoInstance) { +import { CONFIG } from '../../initializers' +import { ActorModel } from '../../models/activitypub/actor' +import { ActorFollowModel } from '../../models/activitypub/actor-follow' +import { VideoModel } from '../../models/video/video' +import { VideoAbuseModel } from '../../models/video/video-abuse' +import { VideoCommentModel } from '../../models/video/video-comment' +import { VideoFileModel } from '../../models/video/video-file' + +function getVideoActivityPubUrl (video: VideoModel) { return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid } -function getVideoChannelActivityPubUrl (videoChannel: VideoChannelInstance) { - return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannel.uuid +function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) { + const suffixFPS = videoFile.fps ? '-' + videoFile.fps : '' + + return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` +} + +function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { + return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id +} + +function getVideoChannelActivityPubUrl (videoChannelName: string) { + return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName } function getAccountActivityPubUrl (accountName: string) { - return CONFIG.WEBSERVER.URL + '/account/' + accountName + return CONFIG.WEBSERVER.URL + '/accounts/' + accountName } -function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseInstance) { +function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) { return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id } -function getVideoViewActivityPubUrl (byAccount: AccountInstance, video: VideoInstance) { - return video.url + '#views/' + byAccount.uuid + '/' + new Date().toISOString() +function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) { + return video.url + '/views/' + byActor.uuid + '/' + new Date().toISOString() +} + +function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel) { + return byActor.url + '/likes/' + video.id +} + +function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel) { + return byActor.url + '/dislikes/' + video.id } -function getAccountFollowActivityPubUrl (accountFollow: AccountFollowInstance) { - const me = accountFollow.AccountFollower - const following = accountFollow.AccountFollowing +function getVideoSharesActivityPubUrl (video: VideoModel) { + return video.url + '/announces' +} + +function getVideoCommentsActivityPubUrl (video: VideoModel) { + return video.url + '/comments' +} + +function getVideoLikesActivityPubUrl (video: VideoModel) { + return video.url + '/likes' +} - return me.url + '#follows/' + following.id +function getVideoDislikesActivityPubUrl (video: VideoModel) { + return video.url + '/dislikes' } -function getAccountFollowAcceptActivityPubUrl (accountFollow: AccountFollowInstance) { - const follower = accountFollow.AccountFollower - const me = accountFollow.AccountFollowing +function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) { + const me = actorFollow.ActorFollower + const following = actorFollow.ActorFollowing + + return me.url + '/follows/' + following.id +} + +function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) { + const follower = actorFollow.ActorFollower + const me = actorFollow.ActorFollowing + + return follower.url + '/accepts/follows/' + me.id +} - return follower.url + '#accepts/follows/' + me.id +function getAnnounceActivityPubUrl (originalUrl: string, byActor: ActorModel) { + return originalUrl + '/announces/' + byActor.id } -function getAnnounceActivityPubUrl (originalUrl: string, byAccount: AccountInstance) { - return originalUrl + '#announces/' + byAccount.id +function getDeleteActivityPubUrl (originalUrl: string) { + return originalUrl + '/delete' } function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) { - return originalUrl + '#updates/' + updatedAt + return originalUrl + '/updates/' + updatedAt } function getUndoActivityPubUrl (originalUrl: string) { @@ -56,10 +95,19 @@ export { getVideoChannelActivityPubUrl, getAccountActivityPubUrl, getVideoAbuseActivityPubUrl, - getAccountFollowActivityPubUrl, - getAccountFollowAcceptActivityPubUrl, + getActorFollowActivityPubUrl, + getActorFollowAcceptActivityPubUrl, getAnnounceActivityPubUrl, getUpdateActivityPubUrl, getUndoActivityPubUrl, - getVideoViewActivityPubUrl + getVideoViewActivityPubUrl, + getVideoLikeActivityPubUrl, + getVideoDislikeActivityPubUrl, + getVideoCommentActivityPubUrl, + getDeleteActivityPubUrl, + getVideoSharesActivityPubUrl, + getVideoCommentsActivityPubUrl, + getVideoLikesActivityPubUrl, + getVideoDislikesActivityPubUrl, + getVideoCacheFileActivityPubUrl }