2017-12-12 11:53:50 -05:00
|
|
|
import { CONFIG } from '../../initializers'
|
2017-12-14 11:38:41 -05:00
|
|
|
import { ActorModel } from '../../models/activitypub/actor'
|
|
|
|
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
|
2017-12-12 11:53:50 -05:00
|
|
|
import { VideoModel } from '../../models/video/video'
|
|
|
|
import { VideoAbuseModel } from '../../models/video/video-abuse'
|
2017-12-22 04:50:07 -05:00
|
|
|
import { VideoCommentModel } from '../../models/video/video-comment'
|
2018-09-11 10:27:07 -04:00
|
|
|
import { VideoFileModel } from '../../models/video/video-file'
|
2019-01-29 02:37:25 -05:00
|
|
|
import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist'
|
2019-02-26 04:55:40 -05:00
|
|
|
import { VideoPlaylistModel } from '../../models/video/video-playlist'
|
2017-11-20 04:24:29 -05:00
|
|
|
|
2017-12-12 11:53:50 -05:00
|
|
|
function getVideoActivityPubUrl (video: VideoModel) {
|
2017-11-20 04:24:29 -05:00
|
|
|
return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
|
|
|
|
}
|
|
|
|
|
2019-02-26 04:55:40 -05:00
|
|
|
function getVideoPlaylistActivityPubUrl (videoPlaylist: VideoPlaylistModel) {
|
|
|
|
return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid
|
|
|
|
}
|
|
|
|
|
|
|
|
function getVideoPlaylistElementActivityPubUrl (videoPlaylist: VideoPlaylistModel, video: VideoModel) {
|
|
|
|
return CONFIG.WEBSERVER.URL + '/video-playlists/' + videoPlaylist.uuid + '/' + video.uuid
|
|
|
|
}
|
|
|
|
|
2018-09-11 10:27:07 -04:00
|
|
|
function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
|
2018-10-01 12:40:17 -04:00
|
|
|
const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
|
2018-09-11 10:27:07 -04:00
|
|
|
|
|
|
|
return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
|
|
|
|
}
|
|
|
|
|
2019-01-29 02:37:25 -05:00
|
|
|
function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) {
|
|
|
|
return `${CONFIG.WEBSERVER.URL}/redundancy/video-playlists/${playlist.getStringType()}/${video.uuid}`
|
|
|
|
}
|
|
|
|
|
2017-12-22 04:50:07 -05:00
|
|
|
function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
|
2017-12-28 05:16:08 -05:00
|
|
|
return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
|
2017-12-14 11:38:41 -05:00
|
|
|
}
|
|
|
|
|
2018-08-17 09:45:42 -04:00
|
|
|
function getVideoChannelActivityPubUrl (videoChannelName: string) {
|
|
|
|
return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName
|
2017-11-20 04:24:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function getAccountActivityPubUrl (accountName: string) {
|
2017-12-29 13:10:13 -05:00
|
|
|
return CONFIG.WEBSERVER.URL + '/accounts/' + accountName
|
2017-11-20 04:24:29 -05:00
|
|
|
}
|
|
|
|
|
2017-12-12 11:53:50 -05:00
|
|
|
function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
|
2017-11-20 04:24:29 -05:00
|
|
|
return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
|
|
|
|
}
|
|
|
|
|
2017-12-14 11:38:41 -05:00
|
|
|
function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
|
2018-11-14 09:01:28 -05:00
|
|
|
return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString()
|
2017-11-22 10:25:03 -05:00
|
|
|
}
|
|
|
|
|
2018-11-14 09:01:28 -05:00
|
|
|
function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) {
|
2017-12-14 11:38:41 -05:00
|
|
|
return byActor.url + '/likes/' + video.id
|
2017-11-23 08:19:55 -05:00
|
|
|
}
|
|
|
|
|
2018-11-14 09:01:28 -05:00
|
|
|
function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) {
|
2017-12-14 11:38:41 -05:00
|
|
|
return byActor.url + '/dislikes/' + video.id
|
2017-11-23 08:19:55 -05:00
|
|
|
}
|
|
|
|
|
2018-01-29 04:52:19 -05: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 11:38:41 -05:00
|
|
|
function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) {
|
|
|
|
const me = actorFollow.ActorFollower
|
|
|
|
const following = actorFollow.ActorFollowing
|
2017-11-20 04:24:29 -05:00
|
|
|
|
2017-11-27 08:44:51 -05:00
|
|
|
return me.url + '/follows/' + following.id
|
2017-11-20 04:24:29 -05:00
|
|
|
}
|
|
|
|
|
2017-12-14 11:38:41 -05:00
|
|
|
function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) {
|
|
|
|
const follower = actorFollow.ActorFollower
|
|
|
|
const me = actorFollow.ActorFollowing
|
2017-11-20 04:24:29 -05:00
|
|
|
|
2017-11-27 08:44:51 -05:00
|
|
|
return follower.url + '/accepts/follows/' + me.id
|
2017-11-20 04:24:29 -05:00
|
|
|
}
|
|
|
|
|
2018-11-14 09:01:28 -05:00
|
|
|
function getVideoAnnounceActivityPubUrl (byActor: ActorModel, video: VideoModel) {
|
|
|
|
return video.url + '/announces/' + byActor.id
|
2017-11-20 04:24:29 -05:00
|
|
|
}
|
|
|
|
|
2018-01-04 10:56:36 -05:00
|
|
|
function getDeleteActivityPubUrl (originalUrl: string) {
|
|
|
|
return originalUrl + '/delete'
|
|
|
|
}
|
|
|
|
|
2017-11-20 04:24:29 -05:00
|
|
|
function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
|
2017-11-27 08:44:51 -05:00
|
|
|
return originalUrl + '/updates/' + updatedAt
|
2017-11-20 04:24:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function getUndoActivityPubUrl (originalUrl: string) {
|
|
|
|
return originalUrl + '/undo'
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
getVideoActivityPubUrl,
|
2019-02-26 04:55:40 -05:00
|
|
|
getVideoPlaylistElementActivityPubUrl,
|
|
|
|
getVideoPlaylistActivityPubUrl,
|
2019-01-29 02:37:25 -05:00
|
|
|
getVideoCacheStreamingPlaylistActivityPubUrl,
|
2017-11-20 04:24:29 -05:00
|
|
|
getVideoChannelActivityPubUrl,
|
|
|
|
getAccountActivityPubUrl,
|
|
|
|
getVideoAbuseActivityPubUrl,
|
2017-12-14 11:38:41 -05:00
|
|
|
getActorFollowActivityPubUrl,
|
|
|
|
getActorFollowAcceptActivityPubUrl,
|
2018-11-14 09:01:28 -05:00
|
|
|
getVideoAnnounceActivityPubUrl,
|
2017-11-20 04:24:29 -05:00
|
|
|
getUpdateActivityPubUrl,
|
2017-11-22 10:25:03 -05:00
|
|
|
getUndoActivityPubUrl,
|
2017-11-23 08:19:55 -05:00
|
|
|
getVideoViewActivityPubUrl,
|
|
|
|
getVideoLikeActivityPubUrl,
|
2017-12-22 04:50:07 -05:00
|
|
|
getVideoDislikeActivityPubUrl,
|
2018-01-04 10:56:36 -05:00
|
|
|
getVideoCommentActivityPubUrl,
|
2018-01-29 04:52:19 -05:00
|
|
|
getDeleteActivityPubUrl,
|
|
|
|
getVideoSharesActivityPubUrl,
|
|
|
|
getVideoCommentsActivityPubUrl,
|
|
|
|
getVideoLikesActivityPubUrl,
|
2018-09-11 10:27:07 -04:00
|
|
|
getVideoDislikesActivityPubUrl,
|
|
|
|
getVideoCacheFileActivityPubUrl
|
2017-11-20 04:24:29 -05:00
|
|
|
}
|