api.rb 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. # frozen_string_literal: true
  2. namespace :api, format: false do
  3. # OEmbed
  4. get '/oembed', to: 'oembed#show', as: :oembed
  5. # JSON / REST API
  6. namespace :v1 do
  7. resources :statuses, only: [:index, :create, :show, :update, :destroy] do
  8. scope module: :statuses do
  9. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  10. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  11. resource :reblog, only: :create
  12. post :unreblog, to: 'reblogs#destroy'
  13. resource :favourite, only: :create
  14. post :unfavourite, to: 'favourites#destroy'
  15. resource :bookmark, only: :create
  16. post :unbookmark, to: 'bookmarks#destroy'
  17. resource :mute, only: :create
  18. post :unmute, to: 'mutes#destroy'
  19. resource :pin, only: :create
  20. post :unpin, to: 'pins#destroy'
  21. resource :history, only: :show
  22. resource :source, only: :show
  23. post :translate, to: 'translations#create'
  24. end
  25. member do
  26. get :context
  27. end
  28. end
  29. namespace :timelines do
  30. resource :home, only: :show, controller: :home
  31. resource :public, only: :show, controller: :public
  32. resource :link, only: :show, controller: :link
  33. resources :tag, only: :show
  34. resources :list, only: :show
  35. end
  36. with_options to: 'streaming#index' do
  37. get '/streaming'
  38. get '/streaming/(*any)'
  39. end
  40. resources :custom_emojis, only: [:index]
  41. resources :suggestions, only: [:index, :destroy]
  42. resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
  43. resources :preferences, only: [:index]
  44. resources :annual_reports, only: [:index, :show] do
  45. member do
  46. post :read
  47. end
  48. end
  49. resources :announcements, only: [:index] do
  50. scope module: :announcements do
  51. resources :reactions, only: [:update, :destroy]
  52. end
  53. member do
  54. post :dismiss
  55. end
  56. end
  57. resources :conversations, only: [:index, :destroy] do
  58. member do
  59. post :read
  60. post :unread
  61. end
  62. end
  63. resources :media, only: [:create, :update, :show]
  64. resources :blocks, only: [:index]
  65. resources :mutes, only: [:index]
  66. resources :favourites, only: [:index]
  67. resources :bookmarks, only: [:index]
  68. resources :reports, only: [:create]
  69. resources :trends, only: [:index], controller: 'trends/tags'
  70. resources :filters, only: [:index, :create, :show, :update, :destroy]
  71. resources :endorsements, only: [:index]
  72. resources :markers, only: [:index, :create]
  73. namespace :profile do
  74. resource :avatar, only: :destroy
  75. resource :header, only: :destroy
  76. end
  77. namespace :apps do
  78. get :verify_credentials, to: 'credentials#show'
  79. end
  80. resources :apps, only: [:create]
  81. namespace :trends do
  82. resources :tags, only: [:index]
  83. resources :links, only: [:index]
  84. resources :statuses, only: [:index]
  85. end
  86. namespace :emails do
  87. resources :confirmations, only: [:create]
  88. get :check_confirmation, to: 'confirmations#check'
  89. end
  90. resource :instance, only: [:show] do
  91. scope module: :instances do
  92. resources :peers, only: [:index]
  93. resources :rules, only: [:index]
  94. resources :domain_blocks, only: [:index]
  95. resource :privacy_policy, only: [:show]
  96. resource :extended_description, only: [:show]
  97. resource :translation_languages, only: [:show]
  98. resource :languages, only: [:show]
  99. resource :activity, only: [:show], controller: :activity
  100. end
  101. end
  102. namespace :peers do
  103. get :search, to: 'search#index'
  104. end
  105. namespace :domain_blocks do
  106. resource :preview, only: [:show]
  107. end
  108. resource :domain_blocks, only: [:show, :create, :destroy]
  109. resource :directory, only: [:show]
  110. resources :follow_requests, only: [:index] do
  111. member do
  112. post :authorize
  113. post :reject
  114. end
  115. end
  116. namespace :notifications do
  117. resources :requests, only: [:index, :show] do
  118. collection do
  119. post :accept, to: 'requests#accept_bulk'
  120. post :dismiss, to: 'requests#dismiss_bulk'
  121. get :merged, to: 'requests#merged?'
  122. end
  123. member do
  124. post :accept
  125. post :dismiss
  126. end
  127. end
  128. resource :policy, only: [:show, :update]
  129. end
  130. resources :notifications, only: [:index, :show] do
  131. collection do
  132. post :clear
  133. get :unread_count
  134. end
  135. member do
  136. post :dismiss
  137. end
  138. end
  139. namespace :accounts do
  140. get :verify_credentials, to: 'credentials#show'
  141. patch :update_credentials, to: 'credentials#update'
  142. resource :search, only: :show, controller: :search
  143. resource :lookup, only: :show, controller: :lookup
  144. resources :relationships, only: :index
  145. resources :familiar_followers, only: :index
  146. end
  147. resources :accounts, only: [:index, :create, :show] do
  148. scope module: :accounts do
  149. resources :statuses, only: :index
  150. resources :followers, only: :index, controller: :follower_accounts
  151. resources :following, only: :index, controller: :following_accounts
  152. resources :lists, only: :index
  153. resources :identity_proofs, only: :index
  154. resources :featured_tags, only: :index
  155. end
  156. member do
  157. post :follow
  158. post :unfollow
  159. post :remove_from_followers
  160. post :block
  161. post :unblock
  162. post :mute
  163. post :unmute
  164. end
  165. scope module: :accounts do
  166. resource :pin, only: :create
  167. post :unpin, to: 'pins#destroy'
  168. resource :note, only: :create
  169. end
  170. end
  171. resources :tags, only: [:show] do
  172. member do
  173. post :follow
  174. post :unfollow
  175. end
  176. end
  177. resources :followed_tags, only: [:index]
  178. resources :lists, only: [:index, :create, :show, :update, :destroy] do
  179. resource :accounts, only: [:show, :create, :destroy], module: :lists
  180. end
  181. namespace :featured_tags do
  182. get :suggestions, to: 'suggestions#index'
  183. end
  184. resources :featured_tags, only: [:index, :create, :destroy]
  185. resources :polls, only: [:show] do
  186. resources :votes, only: :create, module: :polls
  187. end
  188. namespace :push do
  189. resource :subscription, only: [:create, :show, :update, :destroy]
  190. end
  191. namespace :admin do
  192. resources :accounts, only: [:index, :show, :destroy] do
  193. member do
  194. post :enable
  195. post :unsensitive
  196. post :unsilence
  197. post :unsuspend
  198. post :approve
  199. post :reject
  200. end
  201. resource :action, only: [:create], controller: 'account_actions'
  202. end
  203. resources :reports, only: [:index, :update, :show] do
  204. member do
  205. post :assign_to_self
  206. post :unassign
  207. post :reopen
  208. post :resolve
  209. end
  210. end
  211. resources :domain_allows, only: [:index, :show, :create, :destroy]
  212. resources :domain_blocks, only: [:index, :show, :update, :create, :destroy]
  213. resources :email_domain_blocks, only: [:index, :show, :create, :destroy]
  214. resources :ip_blocks, only: [:index, :show, :update, :create, :destroy]
  215. namespace :trends do
  216. resources :tags, only: [:index] do
  217. member do
  218. post :approve
  219. post :reject
  220. end
  221. end
  222. resources :links, only: [:index] do
  223. member do
  224. post :approve
  225. post :reject
  226. end
  227. end
  228. resources :statuses, only: [:index] do
  229. member do
  230. post :approve
  231. post :reject
  232. end
  233. end
  234. namespace :links do
  235. resources :preview_card_providers, only: [:index], path: :publishers do
  236. member do
  237. post :approve
  238. post :reject
  239. end
  240. end
  241. end
  242. end
  243. post :measures, to: 'measures#create'
  244. post :dimensions, to: 'dimensions#create'
  245. post :retention, to: 'retention#create'
  246. resources :canonical_email_blocks, only: [:index, :create, :show, :destroy] do
  247. collection do
  248. post :test
  249. end
  250. end
  251. resources :tags, only: [:index, :show, :update]
  252. end
  253. end
  254. namespace :v2 do
  255. get '/search', to: 'search#index', as: :search
  256. resources :media, only: [:create]
  257. resources :suggestions, only: [:index]
  258. resource :instance, only: [:show]
  259. resources :filters, only: [:index, :create, :show, :update, :destroy] do
  260. scope module: :filters do
  261. resources :keywords, only: [:index, :create]
  262. resources :statuses, only: [:index, :create]
  263. end
  264. end
  265. namespace :filters do
  266. resources :keywords, only: [:show, :update, :destroy]
  267. resources :statuses, only: [:show, :destroy]
  268. end
  269. namespace :admin do
  270. resources :accounts, only: [:index]
  271. end
  272. namespace :notifications do
  273. resource :policy, only: [:show, :update]
  274. end
  275. resources :notifications, param: :group_key, only: [:index, :show] do
  276. collection do
  277. post :clear
  278. get :unread_count
  279. end
  280. member do
  281. post :dismiss
  282. end
  283. resources :accounts, only: [:index], module: :notifications
  284. end
  285. end
  286. namespace :web do
  287. resource :settings, only: [:update]
  288. resources :embeds, only: [:show]
  289. resources :push_subscriptions, only: [:create, :destroy] do
  290. member do
  291. put :update
  292. end
  293. end
  294. end
  295. end