server-hook.model.ts 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. // {hookType}:{root}.{location}.{subLocation?}.{actionType}.{target}
  2. export const serverFilterHookObject = {
  3. // Filter params/result used to list videos for the REST API
  4. // (used by the trending page, recently-added page, local page etc)
  5. 'filter:api.videos.list.params': true,
  6. 'filter:api.videos.list.result': true,
  7. // Filter params/result used to list a video playlists videos
  8. // for the REST API
  9. 'filter:api.video-playlist.videos.list.params': true,
  10. 'filter:api.video-playlist.videos.list.result': true,
  11. // Filter params/result used to list account videos for the REST API
  12. 'filter:api.accounts.videos.list.params': true,
  13. 'filter:api.accounts.videos.list.result': true,
  14. // Filter params/result used to list channel videos for the REST API
  15. 'filter:api.video-channels.videos.list.params': true,
  16. 'filter:api.video-channels.videos.list.result': true,
  17. // Filter params/result used to list my user videos for the REST API
  18. 'filter:api.user.me.videos.list.params': true,
  19. 'filter:api.user.me.videos.list.result': true,
  20. // Filter params/result used to list overview videos for the REST API
  21. 'filter:api.overviews.videos.list.params': true,
  22. 'filter:api.overviews.videos.list.result': true,
  23. // Filter params/result used to list subscription videos for the REST API
  24. 'filter:api.user.me.subscription-videos.list.params': true,
  25. 'filter:api.user.me.subscription-videos.list.result': true,
  26. // Filter params/results to search videos/channels in the DB or on the remote index
  27. 'filter:api.search.videos.local.list.params': true,
  28. 'filter:api.search.videos.local.list.result': true,
  29. 'filter:api.search.videos.index.list.params': true,
  30. 'filter:api.search.videos.index.list.result': true,
  31. 'filter:api.search.video-channels.local.list.params': true,
  32. 'filter:api.search.video-channels.local.list.result': true,
  33. 'filter:api.search.video-channels.index.list.params': true,
  34. 'filter:api.search.video-channels.index.list.result': true,
  35. 'filter:api.search.video-playlists.local.list.params': true,
  36. 'filter:api.search.video-playlists.local.list.result': true,
  37. 'filter:api.search.video-playlists.index.list.params': true,
  38. 'filter:api.search.video-playlists.index.list.result': true,
  39. // Filter the result of the get function
  40. // Used to get detailed video information (video watch page for example)
  41. 'filter:api.video.get.result': true,
  42. // Filter params/results when listing video channels
  43. 'filter:api.video-channels.list.params': true,
  44. 'filter:api.video-channels.list.result': true,
  45. // Filter the result when getting a video channel
  46. 'filter:api.video-channel.get.result': true,
  47. // Filter the result of the accept upload/live, import via torrent/url functions
  48. // If this function returns false then the upload is aborted with an error
  49. 'filter:api.video.upload.accept.result': true,
  50. 'filter:api.live-video.create.accept.result': true,
  51. 'filter:api.video.pre-import-url.accept.result': true,
  52. 'filter:api.video.pre-import-torrent.accept.result': true,
  53. 'filter:api.video.post-import-url.accept.result': true,
  54. 'filter:api.video.post-import-torrent.accept.result': true,
  55. 'filter:api.video.update-file.accept.result': true,
  56. // PeerTube >= 6.1
  57. 'filter:api.video.user-import.accept.result': true,
  58. // Filter the result of the accept comment (thread or reply) functions
  59. // If the functions return false then the user cannot post its comment
  60. 'filter:api.video-thread.create.accept.result': true,
  61. 'filter:api.video-comment-reply.create.accept.result': true,
  62. // Filter attributes when creating video object
  63. 'filter:api.video.upload.video-attribute.result': true,
  64. 'filter:api.video.import-url.video-attribute.result': true,
  65. 'filter:api.video.import-torrent.video-attribute.result': true,
  66. 'filter:api.video.live.video-attribute.result': true,
  67. // PeerTube >= 6.1
  68. 'filter:api.video.user-import.video-attribute.result': true,
  69. // Filter params/result used to list threads of a specific video
  70. // (used by the video watch page)
  71. 'filter:api.video-threads.list.params': true,
  72. 'filter:api.video-threads.list.result': true,
  73. // Filter params/result used to list replies of a specific thread
  74. // (used by the video watch page when we click on the "View replies" button)
  75. 'filter:api.video-thread-comments.list.params': true,
  76. 'filter:api.video-thread-comments.list.result': true,
  77. // Filter get stats result
  78. 'filter:api.server.stats.get.result': true,
  79. // Filter result used to check if we need to auto blacklist a video
  80. // (fired when a local or remote video is created or updated)
  81. 'filter:video.auto-blacklist.result': true,
  82. // Filter result used to check if a user can register on the instance
  83. 'filter:api.user.signup.allowed.result': true,
  84. // Filter result used to check if a user can send a registration request on the instance
  85. // PeerTube >= 5.1
  86. 'filter:api.user.request-signup.allowed.result': true,
  87. // Filter result used to check if video/torrent download is allowed
  88. 'filter:api.download.video.allowed.result': true,
  89. 'filter:api.download.torrent.allowed.result': true,
  90. // Filter result to check if the embed is allowed for a particular request
  91. 'filter:html.embed.video.allowed.result': true,
  92. 'filter:html.embed.video-playlist.allowed.result': true,
  93. // Peertube >= 5.2
  94. 'filter:html.client.json-ld.result': true,
  95. 'filter:job-queue.process.params': true,
  96. 'filter:job-queue.process.result': true,
  97. 'filter:transcoding.manual.resolutions-to-transcode.result': true,
  98. 'filter:transcoding.auto.resolutions-to-transcode.result': true,
  99. 'filter:activity-pub.remote-video-comment.create.accept.result': true,
  100. 'filter:activity-pub.activity.context.build.result': true,
  101. // Filter the result of video JSON LD builder
  102. // You may also need to use filter:activity-pub.activity.context.build.result to also update JSON LD context
  103. 'filter:activity-pub.video.json-ld.build.result': true,
  104. // Filter result to allow custom XMLNS definitions in podcast RSS feeds
  105. // Peertube >= 5.2
  106. 'filter:feed.podcast.rss.create-custom-xmlns.result': true,
  107. // Filter result to allow custom tags in podcast RSS feeds
  108. // Peertube >= 5.2
  109. 'filter:feed.podcast.channel.create-custom-tags.result': true,
  110. // Peertube >= 5.2
  111. 'filter:feed.podcast.video.create-custom-tags.result': true,
  112. // Peertube >= 6.1
  113. 'filter:api.user.me.get.result': true
  114. }
  115. export type ServerFilterHookName = keyof typeof serverFilterHookObject
  116. export const serverActionHookObject = {
  117. // Fired when the application has been loaded and is listening HTTP requests
  118. 'action:application.listening': true,
  119. // Fired when a new notification is created
  120. 'action:notifier.notification.created': true,
  121. // API actions hooks give access to the original express `req` and `res` parameters
  122. // Fired when a local video is updated
  123. 'action:api.video.updated': true,
  124. // Fired when a local video is deleted
  125. 'action:api.video.deleted': true,
  126. // Fired when a local video is uploaded
  127. 'action:api.video.uploaded': true,
  128. // Fired when a local video is viewed
  129. 'action:api.video.viewed': true,
  130. // Fired when a local video file has been replaced by a new one
  131. 'action:api.video.file-updated': true,
  132. // Fired when a video channel is created
  133. 'action:api.video-channel.created': true,
  134. // Fired when a video channel is updated
  135. 'action:api.video-channel.updated': true,
  136. // Fired when a video channel is deleted
  137. 'action:api.video-channel.deleted': true,
  138. // Fired when a live video is created
  139. 'action:api.live-video.created': true,
  140. // Fired when a live video starts or ends
  141. // Peertube >= 5.2
  142. 'action:live.video.state.updated': true,
  143. // Fired when a thread is created
  144. 'action:api.video-thread.created': true,
  145. // Fired when a reply to a thread is created
  146. 'action:api.video-comment-reply.created': true,
  147. // Fired when a comment (thread or reply) is deleted
  148. 'action:api.video-comment.deleted': true,
  149. // Fired when a caption is created
  150. 'action:api.video-caption.created': true,
  151. // Fired when a caption is deleted
  152. 'action:api.video-caption.deleted': true,
  153. // Fired when a user is blocked (banned)
  154. 'action:api.user.blocked': true,
  155. // Fired when a user is unblocked (unbanned)
  156. 'action:api.user.unblocked': true,
  157. // Fired when a user registered on the instance
  158. 'action:api.user.registered': true,
  159. // Fired when a user requested registration on the instance
  160. // PeerTube >= 5.1
  161. 'action:api.user.requested-registration': true,
  162. // Fired when an admin/moderator created a user
  163. 'action:api.user.created': true,
  164. // Fired when a user is removed by an admin/moderator
  165. 'action:api.user.deleted': true,
  166. // Fired when a user is updated by an admin/moderator
  167. 'action:api.user.updated': true,
  168. // Fired when a user got a new oauth2 token
  169. 'action:api.user.oauth2-got-token': true,
  170. // Fired when a video is added to a playlist
  171. 'action:api.video-playlist-element.created': true,
  172. // Fired when a remote video has been created/updated
  173. 'action:activity-pub.remote-video.created': true,
  174. 'action:activity-pub.remote-video.updated': true
  175. }
  176. export type ServerActionHookName = keyof typeof serverActionHookObject
  177. export const serverHookObject = Object.assign({}, serverFilterHookObject, serverActionHookObject)
  178. export type ServerHookName = keyof typeof serverHookObject
  179. export interface ServerHook {
  180. runHook <T> (hookName: ServerHookName, result?: T, params?: any): Promise<T>
  181. }