]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/activitypub/url.ts
d98561e3328874119c325a5ccb26bcc04885a624
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / url.ts
1 import { CONFIG } from '../../initializers/constants'
2 import { VideoInstance } from '../../models/video/video-interface'
3 import { VideoChannelInstance } from '../../models/video/video-channel-interface'
4 import { VideoAbuseInstance } from '../../models/video/video-abuse-interface'
5 import { AccountFollowInstance } from '../../models/account/account-follow-interface'
6 import { AccountInstance } from '../../models/account/account-interface'
7
8 function getVideoActivityPubUrl (video: VideoInstance) {
9 return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
10 }
11
12 function getVideoChannelActivityPubUrl (videoChannel: VideoChannelInstance) {
13 return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannel.uuid
14 }
15
16 function getAccountActivityPubUrl (accountName: string) {
17 return CONFIG.WEBSERVER.URL + '/account/' + accountName
18 }
19
20 function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseInstance) {
21 return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
22 }
23
24 function getVideoViewActivityPubUrl (byAccount: AccountInstance, video: VideoInstance) {
25 return video.url + '#views/' + byAccount.uuid + '/' + new Date().toISOString()
26 }
27
28 function getAccountFollowActivityPubUrl (accountFollow: AccountFollowInstance) {
29 const me = accountFollow.AccountFollower
30 const following = accountFollow.AccountFollowing
31
32 return me.url + '#follows/' + following.id
33 }
34
35 function getAccountFollowAcceptActivityPubUrl (accountFollow: AccountFollowInstance) {
36 const follower = accountFollow.AccountFollower
37 const me = accountFollow.AccountFollowing
38
39 return follower.url + '#accepts/follows/' + me.id
40 }
41
42 function getAnnounceActivityPubUrl (originalUrl: string, byAccount: AccountInstance) {
43 return originalUrl + '#announces/' + byAccount.id
44 }
45
46 function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
47 return originalUrl + '#updates/' + updatedAt
48 }
49
50 function getUndoActivityPubUrl (originalUrl: string) {
51 return originalUrl + '/undo'
52 }
53
54 export {
55 getVideoActivityPubUrl,
56 getVideoChannelActivityPubUrl,
57 getAccountActivityPubUrl,
58 getVideoAbuseActivityPubUrl,
59 getAccountFollowActivityPubUrl,
60 getAccountFollowAcceptActivityPubUrl,
61 getAnnounceActivityPubUrl,
62 getUpdateActivityPubUrl,
63 getUndoActivityPubUrl,
64 getVideoViewActivityPubUrl
65 }