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