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