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