url.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { CONFIG } from '../../initializers'
  2. import { ActorModel } from '../../models/activitypub/actor'
  3. import { ActorFollowModel } from '../../models/activitypub/actor-follow'
  4. import { VideoModel } from '../../models/video/video'
  5. import { VideoAbuseModel } from '../../models/video/video-abuse'
  6. import { VideoCommentModel } from '../../models/video/video-comment'
  7. import { VideoFileModel } from '../../models/video/video-file'
  8. function getVideoActivityPubUrl (video: VideoModel) {
  9. return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid
  10. }
  11. function getVideoCacheFileActivityPubUrl (videoFile: VideoFileModel) {
  12. const suffixFPS = videoFile.fps && videoFile.fps !== -1 ? '-' + videoFile.fps : ''
  13. return `${CONFIG.WEBSERVER.URL}/redundancy/videos/${videoFile.Video.uuid}/${videoFile.resolution}${suffixFPS}`
  14. }
  15. function getVideoCommentActivityPubUrl (video: VideoModel, videoComment: VideoCommentModel) {
  16. return CONFIG.WEBSERVER.URL + '/videos/watch/' + video.uuid + '/comments/' + videoComment.id
  17. }
  18. function getVideoChannelActivityPubUrl (videoChannelName: string) {
  19. return CONFIG.WEBSERVER.URL + '/video-channels/' + videoChannelName
  20. }
  21. function getAccountActivityPubUrl (accountName: string) {
  22. return CONFIG.WEBSERVER.URL + '/accounts/' + accountName
  23. }
  24. function getVideoAbuseActivityPubUrl (videoAbuse: VideoAbuseModel) {
  25. return CONFIG.WEBSERVER.URL + '/admin/video-abuses/' + videoAbuse.id
  26. }
  27. function getVideoViewActivityPubUrl (byActor: ActorModel, video: VideoModel) {
  28. return video.url + '/views/' + byActor.uuid + '/' + new Date().toISOString()
  29. }
  30. function getVideoLikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
  31. return byActor.url + '/likes/' + video.id
  32. }
  33. function getVideoDislikeActivityPubUrl (byActor: ActorModel, video: VideoModel) {
  34. return byActor.url + '/dislikes/' + video.id
  35. }
  36. function getVideoSharesActivityPubUrl (video: VideoModel) {
  37. return video.url + '/announces'
  38. }
  39. function getVideoCommentsActivityPubUrl (video: VideoModel) {
  40. return video.url + '/comments'
  41. }
  42. function getVideoLikesActivityPubUrl (video: VideoModel) {
  43. return video.url + '/likes'
  44. }
  45. function getVideoDislikesActivityPubUrl (video: VideoModel) {
  46. return video.url + '/dislikes'
  47. }
  48. function getActorFollowActivityPubUrl (actorFollow: ActorFollowModel) {
  49. const me = actorFollow.ActorFollower
  50. const following = actorFollow.ActorFollowing
  51. return me.url + '/follows/' + following.id
  52. }
  53. function getActorFollowAcceptActivityPubUrl (actorFollow: ActorFollowModel) {
  54. const follower = actorFollow.ActorFollower
  55. const me = actorFollow.ActorFollowing
  56. return follower.url + '/accepts/follows/' + me.id
  57. }
  58. function getAnnounceActivityPubUrl (originalUrl: string, byActor: ActorModel) {
  59. return originalUrl + '/announces/' + byActor.id
  60. }
  61. function getDeleteActivityPubUrl (originalUrl: string) {
  62. return originalUrl + '/delete'
  63. }
  64. function getUpdateActivityPubUrl (originalUrl: string, updatedAt: string) {
  65. return originalUrl + '/updates/' + updatedAt
  66. }
  67. function getUndoActivityPubUrl (originalUrl: string) {
  68. return originalUrl + '/undo'
  69. }
  70. export {
  71. getVideoActivityPubUrl,
  72. getVideoChannelActivityPubUrl,
  73. getAccountActivityPubUrl,
  74. getVideoAbuseActivityPubUrl,
  75. getActorFollowActivityPubUrl,
  76. getActorFollowAcceptActivityPubUrl,
  77. getAnnounceActivityPubUrl,
  78. getUpdateActivityPubUrl,
  79. getUndoActivityPubUrl,
  80. getVideoViewActivityPubUrl,
  81. getVideoLikeActivityPubUrl,
  82. getVideoDislikeActivityPubUrl,
  83. getVideoCommentActivityPubUrl,
  84. getDeleteActivityPubUrl,
  85. getVideoSharesActivityPubUrl,
  86. getVideoCommentsActivityPubUrl,
  87. getVideoLikesActivityPubUrl,
  88. getVideoDislikesActivityPubUrl,
  89. getVideoCacheFileActivityPubUrl
  90. }