1
0
Fork 0
peertube/server/lib/activitypub/url.ts

80 lines
2.5 KiB
TypeScript
Raw Normal View History

2017-12-12 11:53:50 -05:00
import { CONFIG } from '../../initializers'
2017-12-14 11:38:41 -05:00
import { ActorModel } from '../../models/activitypub/actor'
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
2017-12-12 11:53:50 -05:00
import { VideoModel } from '../../models/video/video'
import { VideoAbuseModel } from '../../models/video/video-abuse'
2017-12-12 11:53:50 -05:00
function getVideoActivityPubUrl (video: VideoModel) {
return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
}
2017-12-14 11:38:41 -05:00
function getVideoChannelActivityPubUrl (videoChannelUUID: string) {
return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelUUID
}
function getApplicationActivityPubUrl () {
return CONFIG.WEBSERVER.URL + '/application/peertube'
}
function getAccountActivityPubUrl (accountName: string) {
return CONFIG.WEBSERVER.URL + '/account/' + accountName
}
2017-12-12 11:53:50 -05:00
function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
}
2017-12-14 11:38:41 -05:00
function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
return video.url + '/views/' + byActor.uuid + '/' + new Date().toISOString()
2017-11-22 10:25:03 -05:00
}
2017-12-14 11:38:41 -05:00
function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
return byActor.url + '/likes/' + video.id
2017-11-23 08:19:55 -05:00
}
2017-12-14 11:38:41 -05:00
function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
return byActor.url + '/dislikes/' + video.id
2017-11-23 08:19:55 -05:00
}
2017-12-14 11:38:41 -05:00
function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) {
const me = actorFollow.ActorFollower
const following = actorFollow.ActorFollowing
return me.url + '/follows/' + following.id
}
2017-12-14 11:38:41 -05:00
function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) {
const follower = actorFollow.ActorFollower
const me = actorFollow.ActorFollowing
return follower.url + '/accepts/follows/' + me.id
}
2017-12-14 11:38:41 -05:00
function getAnnounceActivityPubUrl (originalUrl: string, byActor: ActorModel) {
return originalUrl + '/announces/' + byActor.id
}
function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
return originalUrl + '/updates/' + updatedAt
}
function getUndoActivityPubUrl (originalUrl: string) {
return originalUrl + '/undo'
}
export {
2017-12-14 11:38:41 -05:00
getApplicationActivityPubUrl,
getVideoActivityPubUrl,
getVideoChannelActivityPubUrl,
getAccountActivityPubUrl,
getVideoAbuseActivityPubUrl,
2017-12-14 11:38:41 -05:00
getActorFollowActivityPubUrl,
getActorFollowAcceptActivityPubUrl,
getAnnounceActivityPubUrl,
getUpdateActivityPubUrl,
2017-11-22 10:25:03 -05:00
getUndoActivityPubUrl,
2017-11-23 08:19:55 -05:00
getVideoViewActivityPubUrl,
getVideoLikeActivityPubUrl,
getVideoDislikeActivityPubUrl
}