PeerTube/server/lib/activitypub/url.ts

114 lines
3.6 KiB
TypeScript
Raw Normal View History

2017-12-12 10:53:50 -06:00
import { CONFIG } from '../../initializers'
2017-12-14 10:38:41 -06:00
import { ActorModel } from '../../models/activitypub/actor'
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
2017-12-12 10:53:50 -06:00
import { VideoModel } from '../../models/video/video'
import { VideoAbuseModel } from '../../models/video/video-abuse'
2017-12-22 03:50:07 -06:00
import { VideoCommentModel } from '../../models/video/video-comment'
2018-09-11 09:27:07 -05:00
import { VideoFileModel } from '../../models/video/video-file'
2017-12-12 10:53:50 -06:00
function getVideoActivityPubUrl (video: VideoModel) {
return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
}
2018-09-11 09:27:07 -05:00
function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
const suffixFPS = videoFile.fps ? '-' + videoFile.fps : ''
return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
}
2017-12-22 03:50:07 -06:00
function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
2017-12-28 04:16:08 -06:00
return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
2017-12-14 10:38:41 -06:00
}
2018-08-17 08:45:42 -05:00
function getVideoChannelActivityPubUrl (videoChannelName: string) {
return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName
}
function getAccountActivityPubUrl (accountName: string) {
2017-12-29 12:10:13 -06:00
return CONFIG.WEBSERVER.URL + '/accounts/' + accountName
}
2017-12-12 10:53:50 -06:00
function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
}
2017-12-14 10:38:41 -06:00
function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
return video.url + '/views/' + byActor.uuid + '/' + new Date().toISOString()
2017-11-22 09:25:03 -06:00
}
2017-12-14 10:38:41 -06:00
function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
return byActor.url + '/likes/' + video.id
2017-11-23 07:19:55 -06:00
}
2017-12-14 10:38:41 -06:00
function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
return byActor.url + '/dislikes/' + video.id
2017-11-23 07:19:55 -06:00
}
function getVideoSharesActivityPubUrl (video: VideoModel) {
return video.url + '/announces'
}
function getVideoCommentsActivityPubUrl (video: VideoModel) {
return video.url + '/comments'
}
function getVideoLikesActivityPubUrl (video: VideoModel) {
return video.url + '/likes'
}
function getVideoDislikesActivityPubUrl (video: VideoModel) {
return video.url + '/dislikes'
}
2017-12-14 10:38:41 -06:00
function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) {
const me = actorFollow.ActorFollower
const following = actorFollow.ActorFollowing
return me.url + '/follows/' + following.id
}
2017-12-14 10:38:41 -06:00
function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) {
const follower = actorFollow.ActorFollower
const me = actorFollow.ActorFollowing
return follower.url + '/accepts/follows/' + me.id
}
2017-12-14 10:38:41 -06:00
function getAnnounceActivityPubUrl (originalUrl: string, byActor: ActorModel) {
return originalUrl + '/announces/' + byActor.id
}
2018-01-04 09:56:36 -06:00
function getDeleteActivityPubUrl (originalUrl: string) {
return originalUrl + '/delete'
}
function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
return originalUrl + '/updates/' + updatedAt
}
function getUndoActivityPubUrl (originalUrl: string) {
return originalUrl + '/undo'
}
export {
getVideoActivityPubUrl,
getVideoChannelActivityPubUrl,
getAccountActivityPubUrl,
getVideoAbuseActivityPubUrl,
2017-12-14 10:38:41 -06:00
getActorFollowActivityPubUrl,
getActorFollowAcceptActivityPubUrl,
getAnnounceActivityPubUrl,
getUpdateActivityPubUrl,
2017-11-22 09:25:03 -06:00
getUndoActivityPubUrl,
2017-11-23 07:19:55 -06:00
getVideoViewActivityPubUrl,
getVideoLikeActivityPubUrl,
2017-12-22 03:50:07 -06:00
getVideoDislikeActivityPubUrl,
2018-01-04 09:56:36 -06:00
getVideoCommentActivityPubUrl,
getDeleteActivityPubUrl,
getVideoSharesActivityPubUrl,
getVideoCommentsActivityPubUrl,
getVideoLikesActivityPubUrl,
2018-09-11 09:27:07 -05:00
getVideoDislikesActivityPubUrl,
getVideoCacheFileActivityPubUrl
}