]>
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 { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model' | |
9 | import { VideoStreamingPlaylistModel } from '../../models/video/video-streaming-playlist' | |
10 | ||
11 | function getVideoActivityPubUrl (video: VideoModel) { | |
12 | return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid | |
13 | } | |
14 | ||
15 | function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) { | |
16 | const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : '' | |
17 | ||
18 | return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}` | |
19 | } | |
20 | ||
21 | function getVideoCacheStreamingPlaylistActivityPubUrl (video: VideoModel, playlist: VideoStreamingPlaylistModel) { | |
22 | return `${CONFIG.WEBSERVER.URL}/redundancy/video-playlists/${playlist.getStringType()}/${video.uuid}` | |
23 | } | |
24 | ||
25 | function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) { | |
26 | return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id | |
27 | } | |
28 | ||
29 | function getVideoChannelActivityPubUrl (videoChannelName: string) { | |
30 | return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName | |
31 | } | |
32 | ||
33 | function getAccountActivityPubUrl (accountName: string) { | |
34 | return CONFIG.WEBSERVER.URL + '/accounts/' + accountName | |
35 | } | |
36 | ||
37 | function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) { | |
38 | return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id | |
39 | } | |
40 | ||
41 | function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) { | |
42 | return byActor.url + '/views/videos/' + video.id + '/' + new Date().toISOString() | |
43 | } | |
44 | ||
45 | function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) { | |
46 | return byActor.url + '/likes/' + video.id | |
47 | } | |
48 | ||
49 | function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel | { id: number }) { | |
50 | return byActor.url + '/dislikes/' + video.id | |
51 | } | |
52 | ||
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 | ||
69 | function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) { | |
70 | const me = actorFollow.ActorFollower | |
71 | const following = actorFollow.ActorFollowing | |
72 | ||
73 | return me.url + '/follows/' + following.id | |
74 | } | |
75 | ||
76 | function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) { | |
77 | const follower = actorFollow.ActorFollower | |
78 | const me = actorFollow.ActorFollowing | |
79 | ||
80 | return follower.url + '/accepts/follows/' + me.id | |
81 | } | |
82 | ||
83 | function getVideoAnnounceActivityPubUrl (byActor: ActorModel, video: VideoModel) { | |
84 | return video.url + '/announces/' + byActor.id | |
85 | } | |
86 | ||
87 | function getDeleteActivityPubUrl (originalUrl: string) { | |
88 | return originalUrl + '/delete' | |
89 | } | |
90 | ||
91 | function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) { | |
92 | return originalUrl + '/updates/' + updatedAt | |
93 | } | |
94 | ||
95 | function getUndoActivityPubUrl (originalUrl: string) { | |
96 | return originalUrl + '/undo' | |
97 | } | |
98 | ||
99 | export { | |
100 | getVideoActivityPubUrl, | |
101 | getVideoCacheStreamingPlaylistActivityPubUrl, | |
102 | getVideoChannelActivityPubUrl, | |
103 | getAccountActivityPubUrl, | |
104 | getVideoAbuseActivityPubUrl, | |
105 | getActorFollowActivityPubUrl, | |
106 | getActorFollowAcceptActivityPubUrl, | |
107 | getVideoAnnounceActivityPubUrl, | |
108 | getUpdateActivityPubUrl, | |
109 | getUndoActivityPubUrl, | |
110 | getVideoViewActivityPubUrl, | |
111 | getVideoLikeActivityPubUrl, | |
112 | getVideoDislikeActivityPubUrl, | |
113 | getVideoCommentActivityPubUrl, | |
114 | getDeleteActivityPubUrl, | |
115 | getVideoSharesActivityPubUrl, | |
116 | getVideoCommentsActivityPubUrl, | |
117 | getVideoLikesActivityPubUrl, | |
118 | getVideoDislikesActivityPubUrl, | |
119 | getVideoCacheFileActivityPubUrl | |
120 | } |