]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/activitypub/url.ts
bb2d4d11e7b4dfc6f15600c42365af9937f6a1da
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / url.ts
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
7 function getVideoActivityPubUrl (video: VideoModel) {
8 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
9 }
10
11 function getVideoChannelActivityPubUrl (videoChannelUUID: string) {
12 return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelUUID
13 }
14
15 function getApplicationActivityPubUrl () {
16 return CONFIG.WEBSERVER.URL + '/application/peertube'
17 }
18
19 function getAccountActivityPubUrl (accountName: string) {
20 return CONFIG.WEBSERVER.URL + '/account/' + accountName
21 }
22
23 function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
24 return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
25 }
26
27 function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
28 return video.url + '/views/' + byActor.uuid + '/' + new Date().toISOString()
29 }
30
31 function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
32 return byActor.url + '/likes/' + video.id
33 }
34
35 function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
36 return byActor.url + '/dislikes/' + video.id
37 }
38
39 function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) {
40 const me = actorFollow.ActorFollower
41 const following = actorFollow.ActorFollowing
42
43 return me.url + '/follows/' + following.id
44 }
45
46 function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) {
47 const follower = actorFollow.ActorFollower
48 const me = actorFollow.ActorFollowing
49
50 return follower.url + '/accepts/follows/' + me.id
51 }
52
53 function getAnnounceActivityPubUrl (originalUrl: string, byActor: ActorModel) {
54 return originalUrl + '/announces/' + byActor.id
55 }
56
57 function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
58 return originalUrl + '/updates/' + updatedAt
59 }
60
61 function getUndoActivityPubUrl (originalUrl: string) {
62 return originalUrl + '/undo'
63 }
64
65 export {
66 getApplicationActivityPubUrl,
67 getVideoActivityPubUrl,
68 getVideoChannelActivityPubUrl,
69 getAccountActivityPubUrl,
70 getVideoAbuseActivityPubUrl,
71 getActorFollowActivityPubUrl,
72 getActorFollowAcceptActivityPubUrl,
73 getAnnounceActivityPubUrl,
74 getUpdateActivityPubUrl,
75 getUndoActivityPubUrl,
76 getVideoViewActivityPubUrl,
77 getVideoLikeActivityPubUrl,
78 getVideoDislikeActivityPubUrl
79 }