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