diff options
Diffstat (limited to 'server/lib/activitypub/url.ts')
-rw-r--r-- | server/lib/activitypub/url.ts | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/server/lib/activitypub/url.ts b/server/lib/activitypub/url.ts new file mode 100644 index 000000000..41ac0f9a8 --- /dev/null +++ b/server/lib/activitypub/url.ts | |||
@@ -0,0 +1,60 @@ | |||
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 getAccountFollowActivityPubUrl (accountFollow: AccountFollowInstance) { | ||
25 | const me = accountFollow.AccountFollower | ||
26 | const following = accountFollow.AccountFollowing | ||
27 | |||
28 | return me.url + '#follows/' + following.id | ||
29 | } | ||
30 | |||
31 | function getAccountFollowAcceptActivityPubUrl (accountFollow: AccountFollowInstance) { | ||
32 | const follower = accountFollow.AccountFollower | ||
33 | const me = accountFollow.AccountFollowing | ||
34 | |||
35 | return follower.url + '#accepts/follows/' + me.id | ||
36 | } | ||
37 | |||
38 | function getAnnounceActivityPubUrl (originalUrl: string, byAccount: AccountInstance) { | ||
39 | return originalUrl + '#announces/' + byAccount.id | ||
40 | } | ||
41 | |||
42 | function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) { | ||
43 | return originalUrl + '#updates/' + updatedAt | ||
44 | } | ||
45 | |||
46 | function getUndoActivityPubUrl (originalUrl: string) { | ||
47 | return originalUrl + '/undo' | ||
48 | } | ||
49 | |||
50 | export { | ||
51 | getVideoActivityPubUrl, | ||
52 | getVideoChannelActivityPubUrl, | ||
53 | getAccountActivityPubUrl, | ||
54 | getVideoAbuseActivityPubUrl, | ||
55 | getAccountFollowActivityPubUrl, | ||
56 | getAccountFollowAcceptActivityPubUrl, | ||
57 | getAnnounceActivityPubUrl, | ||
58 | getUpdateActivityPubUrl, | ||
59 | getUndoActivityPubUrl | ||
60 | } | ||