aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/url.ts
blob: 17395a99b81291d091877fbc2ad48741a9bd5e57 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { CONFIG } from '../../initializers/constants'
import { VideoInstance } from '../../models/video/video-interface'
import { VideoChannelInstance } from '../../models/video/video-channel-interface'
import { VideoAbuseInstance } from '../../models/video/video-abuse-interface'
import { AccountFollowInstance } from '../../models/account/account-follow-interface'
import { AccountInstance } from '../../models/account/account-interface'

function getVideoActivityPubUrl (video: VideoInstance) {
  return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
}

function getVideoChannelActivityPubUrl (videoChannel: VideoChannelInstance) {
  return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannel.uuid
}

function getAccountActivityPubUrl (accountName: string) {
  return CONFIG.WEBSERVER.URL + '/account/' + accountName
}

function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseInstance) {
  return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
}

function getVideoViewActivityPubUrl (byAccount: AccountInstance, video: VideoInstance) {
  return video.url + '#views/' + byAccount.uuid + '/' + new Date().toISOString()
}

function getVideoLikeActivityPubUrl (byAccount: AccountInstance, video: VideoInstance) {
  return byAccount.url + '#likes/' + video.id
}

function getVideoDislikeActivityPubUrl (byAccount: AccountInstance, video: VideoInstance) {
  return byAccount.url + '#dislikes/' + video.id
}

function getAccountFollowActivityPubUrl (accountFollow: AccountFollowInstance) {
  const me = accountFollow.AccountFollower
  const following = accountFollow.AccountFollowing

  return me.url + '#follows/' + following.id
}

function getAccountFollowAcceptActivityPubUrl (accountFollow: AccountFollowInstance) {
  const follower = accountFollow.AccountFollower
  const me = accountFollow.AccountFollowing

  return follower.url + '#accepts/follows/' + me.id
}

function getAnnounceActivityPubUrl (originalUrl: string, byAccount: AccountInstance) {
  return originalUrl + '#announces/' + byAccount.id
}

function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
  return originalUrl + '#updates/' + updatedAt
}

function getUndoActivityPubUrl (originalUrl: string) {
  return originalUrl + '/undo'
}

export {
  getVideoActivityPubUrl,
  getVideoChannelActivityPubUrl,
  getAccountActivityPubUrl,
  getVideoAbuseActivityPubUrl,
  getAccountFollowActivityPubUrl,
  getAccountFollowAcceptActivityPubUrl,
  getAnnounceActivityPubUrl,
  getUpdateActivityPubUrl,
  getUndoActivityPubUrl,
  getVideoViewActivityPubUrl,
  getVideoLikeActivityPubUrl,
  getVideoDislikeActivityPubUrl
}