]>
Commit | Line | Data |
---|---|---|
3fd3ab2d | 1 | import { CONFIG } from '../../initializers' |
50d6de9c C |
2 | import { ActorModel } from '../../models/activitypub/actor' |
3 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | |
3fd3ab2d C |
4 | import { VideoModel } from '../../models/video/video' |
5 | import { VideoAbuseModel } from '../../models/video/video-abuse' | |
bf1f6508 | 6 | import { VideoCommentModel } from '../../models/video/video-comment' |
c48e82b5 | 7 | import { VideoFileModel } from '../../models/video/video-file' |
09209296 C |
8 | import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' |
9 | import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist' | |
892211e8 | 10 | |
3fd3ab2d | 11 | function getVideoActivityPubUrl (video: VideoModel) { |
892211e8 C |
12 | return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid |
13 | } | |
14 | ||
c48e82b5 | 15 | function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) { |
d05be4d9 | 16 | const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' |
c48e82b5 C |
17 | |
18 | return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` | |
19 | } | |
20 | ||
09209296 C |
21 | function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { |
22 | return `${CONFIG.WEBSERVER.URL}/redundancy/video-playlists/${playlist.getStringType()}/${video.uuid}` | |
23 | } | |
24 | ||
bf1f6508 | 25 | function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { |
da854ddd | 26 | return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id |
50d6de9c C |
27 | } |
28 | ||
8a19bee1 C |
29 | function getVideoChannelActivityPubUrl (videoChannelName: string) { |
30 | return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName | |
892211e8 C |
31 | } |
32 | ||
33 | function getAccountActivityPubUrl (accountName: string) { | |
c5911fd3 | 34 | return CONFIG.WEBSERVER.URL + '/accounts/' + accountName |
892211e8 C |
35 | } |
36 | ||
3fd3ab2d | 37 | function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) { |
892211e8 C |
38 | return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id |
39 | } | |
40 | ||
50d6de9c | 41 | function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) { |
5c6d985f | 42 | return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString() |
40ff5707 C |
43 | } |
44 | ||
5c6d985f | 45 | function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) { |
50d6de9c | 46 | return byActor.url + '/likes/' + video.id |
0032ebe9 C |
47 | } |
48 | ||
5c6d985f | 49 | function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) { |
50d6de9c | 50 | return byActor.url + '/dislikes/' + video.id |
0032ebe9 C |
51 | } |
52 | ||
46531a0a C |
53 | function getVideoSharesActivityPubUrl (video: VideoModel) { |
54 | return video.url + '/announces' | |
55 | } | |
56 | ||
57 | function getVideoCommentsActivityPubUrl (video: VideoModel) { | |
58 | return video.url + '/comments' | |
59 | } | |
60 | ||
61 | function getVideoLikesActivityPubUrl (video: VideoModel) { | |
62 | return video.url + '/likes' | |
63 | } | |
64 | ||
65 | function getVideoDislikesActivityPubUrl (video: VideoModel) { | |
66 | return video.url + '/dislikes' | |
67 | } | |
68 | ||
50d6de9c C |
69 | function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) { |
70 | const me = actorFollow.ActorFollower | |
71 | const following = actorFollow.ActorFollowing | |
892211e8 | 72 | |
4e50b6a1 | 73 | return me.url + '/follows/' + following.id |
892211e8 C |
74 | } |
75 | ||
50d6de9c C |
76 | function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) { |
77 | const follower = actorFollow.ActorFollower | |
78 | const me = actorFollow.ActorFollowing | |
892211e8 | 79 | |
4e50b6a1 | 80 | return follower.url + '/accepts/follows/' + me.id |
892211e8 C |
81 | } |
82 | ||
5c6d985f C |
83 | function getVideoAnnounceActivityPubUrl (byActor: ActorModel, video: VideoModel) { |
84 | return video.url + '/announces/' + byActor.id | |
892211e8 C |
85 | } |
86 | ||
c3badc81 C |
87 | function getDeleteActivityPubUrl (originalUrl: string) { |
88 | return originalUrl + '/delete' | |
89 | } | |
90 | ||
892211e8 | 91 | function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) { |
4e50b6a1 | 92 | return originalUrl + '/updates/' + updatedAt |
892211e8 C |
93 | } |
94 | ||
95 | function getUndoActivityPubUrl (originalUrl: string) { | |
96 | return originalUrl + '/undo' | |
97 | } | |
98 | ||
99 | export { | |
100 | getVideoActivityPubUrl, | |
09209296 | 101 | getVideoCacheStreamingPlaylistActivityPubUrl, |
892211e8 C |
102 | getVideoChannelActivityPubUrl, |
103 | getAccountActivityPubUrl, | |
104 | getVideoAbuseActivityPubUrl, | |
50d6de9c C |
105 | getActorFollowActivityPubUrl, |
106 | getActorFollowAcceptActivityPubUrl, | |
5c6d985f | 107 | getVideoAnnounceActivityPubUrl, |
892211e8 | 108 | getUpdateActivityPubUrl, |
40ff5707 | 109 | getUndoActivityPubUrl, |
0032ebe9 C |
110 | getVideoViewActivityPubUrl, |
111 | getVideoLikeActivityPubUrl, | |
bf1f6508 | 112 | getVideoDislikeActivityPubUrl, |
c3badc81 | 113 | getVideoCommentActivityPubUrl, |
46531a0a C |
114 | getDeleteActivityPubUrl, |
115 | getVideoSharesActivityPubUrl, | |
116 | getVideoCommentsActivityPubUrl, | |
117 | getVideoLikesActivityPubUrl, | |
c48e82b5 C |
118 | getVideoDislikesActivityPubUrl, |
119 | getVideoCacheFileActivityPubUrl | |
892211e8 | 120 | } |