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