routes.rb 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. # frozen_string_literal: true
  2. require 'sidekiq_unique_jobs/web'
  3. require 'sidekiq-scheduler/web'
  4. Rails.application.routes.draw do
  5. root 'home#index'
  6. mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
  7. get 'health', to: 'health#show'
  8. authenticate :user, lambda { |u| u.admin? } do
  9. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  10. mount PgHero::Engine, at: 'pghero', as: :pghero
  11. end
  12. use_doorkeeper do
  13. controllers authorizations: 'oauth/authorizations',
  14. authorized_applications: 'oauth/authorized_applications',
  15. tokens: 'oauth/tokens'
  16. end
  17. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  18. get '.well-known/nodeinfo', to: 'well_known/nodeinfo#index', as: :nodeinfo, defaults: { format: 'json' }
  19. get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
  20. get '.well-known/change-password', to: redirect('/auth/edit')
  21. get '/nodeinfo/2.0', to: 'well_known/nodeinfo#show', as: :nodeinfo_schema
  22. get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
  23. get 'intent', to: 'intents#show'
  24. get 'custom.css', to: 'custom_css#show', as: :custom_css
  25. resource :instance_actor, path: 'actor', only: [:show] do
  26. resource :inbox, only: [:create], module: :activitypub
  27. resource :outbox, only: [:show], module: :activitypub
  28. end
  29. devise_scope :user do
  30. get '/invite/:invite_code', to: 'auth/registrations#new', as: :public_invite
  31. namespace :auth do
  32. resource :setup, only: [:show, :update], controller: :setup
  33. resource :challenge, only: [:create], controller: :challenges
  34. get 'sessions/security_key_options', to: 'sessions#webauthn_options'
  35. end
  36. end
  37. devise_for :users, path: 'auth', controllers: {
  38. omniauth_callbacks: 'auth/omniauth_callbacks',
  39. sessions: 'auth/sessions',
  40. registrations: 'auth/registrations',
  41. passwords: 'auth/passwords',
  42. confirmations: 'auth/confirmations',
  43. }
  44. get '/users/:username', to: redirect('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  45. get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
  46. resources :accounts, path: 'users', only: [:show], param: :username do
  47. get :remote_follow, to: 'remote_follow#new'
  48. post :remote_follow, to: 'remote_follow#create'
  49. resources :statuses, only: [:show] do
  50. member do
  51. get :activity
  52. get :embed
  53. end
  54. resources :replies, only: [:index], module: :activitypub
  55. end
  56. resources :followers, only: [:index], controller: :follower_accounts
  57. resources :following, only: [:index], controller: :following_accounts
  58. resource :follow, only: [:create], controller: :account_follow
  59. resource :unfollow, only: [:create], controller: :account_unfollow
  60. resource :outbox, only: [:show], module: :activitypub
  61. resource :inbox, only: [:create], module: :activitypub
  62. resource :claim, only: [:create], module: :activitypub
  63. resources :collections, only: [:show], module: :activitypub
  64. resource :followers_synchronization, only: [:show], module: :activitypub
  65. end
  66. resource :inbox, only: [:create], module: :activitypub
  67. get '/@:username', to: 'accounts#show', as: :short_account
  68. get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
  69. get '/@:username/media', to: 'accounts#show', as: :short_account_media
  70. get '/@:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag
  71. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  72. get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
  73. get '/interact/:id', to: 'remote_interaction#new', as: :remote_interaction
  74. post '/interact/:id', to: 'remote_interaction#create'
  75. get '/explore', to: 'directories#index', as: :explore
  76. get '/settings', to: redirect('/settings/profile')
  77. namespace :settings do
  78. resource :profile, only: [:show, :update] do
  79. resources :pictures, only: :destroy
  80. end
  81. get :preferences, to: redirect('/settings/preferences/appearance')
  82. namespace :preferences do
  83. resource :appearance, only: [:show, :update], controller: :appearance
  84. resource :notifications, only: [:show, :update]
  85. resource :other, only: [:show, :update], controller: :other
  86. end
  87. resource :import, only: [:show, :create]
  88. resource :export, only: [:show, :create]
  89. namespace :exports, constraints: { format: :csv } do
  90. resources :follows, only: :index, controller: :following_accounts
  91. resources :blocks, only: :index, controller: :blocked_accounts
  92. resources :mutes, only: :index, controller: :muted_accounts
  93. resources :lists, only: :index, controller: :lists
  94. resources :domain_blocks, only: :index, controller: :blocked_domains
  95. resources :bookmarks, only: :index, controller: :bookmarks
  96. end
  97. resources :two_factor_authentication_methods, only: [:index] do
  98. collection do
  99. post :disable
  100. end
  101. end
  102. resource :otp_authentication, only: [:show, :create], controller: 'two_factor_authentication/otp_authentication'
  103. resources :webauthn_credentials, only: [:index, :new, :create, :destroy],
  104. path: 'security_keys',
  105. controller: 'two_factor_authentication/webauthn_credentials' do
  106. collection do
  107. get :options
  108. end
  109. end
  110. namespace :two_factor_authentication do
  111. resources :recovery_codes, only: [:create]
  112. resource :confirmation, only: [:new, :create]
  113. end
  114. resources :applications, except: [:edit] do
  115. member do
  116. post :regenerate
  117. end
  118. end
  119. resource :delete, only: [:show, :destroy]
  120. resource :migration, only: [:show, :create]
  121. namespace :migration do
  122. resource :redirect, only: [:new, :create, :destroy]
  123. end
  124. resources :aliases, only: [:index, :create, :destroy]
  125. resources :sessions, only: [:destroy]
  126. resources :featured_tags, only: [:index, :create, :destroy]
  127. resources :login_activities, only: [:index]
  128. end
  129. namespace :disputes do
  130. resources :strikes, only: [:show, :index] do
  131. resource :appeal, only: [:create]
  132. end
  133. end
  134. resources :media, only: [:show] do
  135. get :player
  136. end
  137. resources :tags, only: [:show]
  138. resources :emojis, only: [:show]
  139. resources :invites, only: [:index, :create, :destroy]
  140. resources :filters, except: [:show]
  141. resource :relationships, only: [:show, :update]
  142. resource :statuses_cleanup, controller: :statuses_cleanup, only: [:show, :update]
  143. get '/public', to: 'public_timelines#show', as: :public_timeline
  144. get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy
  145. resource :authorize_interaction, only: [:show, :create]
  146. resource :share, only: [:show, :create]
  147. namespace :admin do
  148. get '/dashboard', to: 'dashboard#index'
  149. resources :domain_allows, only: [:new, :create, :show, :destroy]
  150. resources :domain_blocks, only: [:new, :create, :destroy, :update, :edit]
  151. resources :email_domain_blocks, only: [:index, :new, :create] do
  152. collection do
  153. post :batch
  154. end
  155. end
  156. resources :action_logs, only: [:index]
  157. resources :warning_presets, except: [:new]
  158. resources :announcements, except: [:show] do
  159. member do
  160. post :publish
  161. post :unpublish
  162. end
  163. end
  164. resource :settings, only: [:edit, :update]
  165. resources :site_uploads, only: [:destroy]
  166. resources :invites, only: [:index, :create, :destroy] do
  167. collection do
  168. post :deactivate_all
  169. end
  170. end
  171. resources :relays, only: [:index, :new, :create, :destroy] do
  172. member do
  173. post :enable
  174. post :disable
  175. end
  176. end
  177. resources :instances, only: [:index, :show, :destroy], constraints: { id: /[^\/]+/ } do
  178. member do
  179. post :clear_delivery_errors
  180. post :restart_delivery
  181. post :stop_delivery
  182. end
  183. end
  184. resources :rules
  185. resources :reports, only: [:index, :show] do
  186. resources :actions, only: [:create], controller: 'reports/actions'
  187. member do
  188. post :assign_to_self
  189. post :unassign
  190. post :reopen
  191. post :resolve
  192. end
  193. end
  194. resources :report_notes, only: [:create, :destroy]
  195. resources :accounts, only: [:index, :show, :destroy] do
  196. member do
  197. post :enable
  198. post :unsensitive
  199. post :unsilence
  200. post :unsuspend
  201. post :redownload
  202. post :remove_avatar
  203. post :remove_header
  204. post :memorialize
  205. post :approve
  206. post :reject
  207. post :unblock_email
  208. end
  209. collection do
  210. post :batch
  211. end
  212. resource :change_email, only: [:show, :update]
  213. resource :reset, only: [:create]
  214. resource :action, only: [:new, :create], controller: 'account_actions'
  215. resources :statuses, only: [:index] do
  216. collection do
  217. post :batch
  218. end
  219. end
  220. resources :relationships, only: [:index]
  221. resource :confirmation, only: [:create] do
  222. collection do
  223. post :resend
  224. end
  225. end
  226. resource :role, only: [] do
  227. member do
  228. post :promote
  229. post :demote
  230. end
  231. end
  232. end
  233. resources :users, only: [] do
  234. resource :two_factor_authentication, only: [:destroy]
  235. resource :sign_in_token_authentication, only: [:create, :destroy]
  236. end
  237. resources :custom_emojis, only: [:index, :new, :create] do
  238. collection do
  239. post :batch
  240. end
  241. end
  242. resources :ip_blocks, only: [:index, :new, :create] do
  243. collection do
  244. post :batch
  245. end
  246. end
  247. resources :account_moderation_notes, only: [:create, :destroy]
  248. resource :follow_recommendations, only: [:show, :update]
  249. resources :tags, only: [:show, :update]
  250. namespace :trends do
  251. resources :links, only: [:index] do
  252. collection do
  253. post :batch
  254. end
  255. end
  256. resources :tags, only: [:index] do
  257. collection do
  258. post :batch
  259. end
  260. end
  261. resources :statuses, only: [:index] do
  262. collection do
  263. post :batch
  264. end
  265. end
  266. namespace :links do
  267. resources :preview_card_providers, only: [:index], path: :publishers do
  268. collection do
  269. post :batch
  270. end
  271. end
  272. end
  273. end
  274. namespace :disputes do
  275. resources :appeals, only: [:index] do
  276. member do
  277. post :approve
  278. post :reject
  279. end
  280. end
  281. end
  282. end
  283. get '/admin', to: redirect('/admin/dashboard', status: 302)
  284. namespace :api do
  285. # OEmbed
  286. get '/oembed', to: 'oembed#show', as: :oembed
  287. # JSON / REST API
  288. namespace :v1 do
  289. resources :statuses, only: [:create, :show, :update, :destroy] do
  290. scope module: :statuses do
  291. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  292. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  293. resource :reblog, only: :create
  294. post :unreblog, to: 'reblogs#destroy'
  295. resource :favourite, only: :create
  296. post :unfavourite, to: 'favourites#destroy'
  297. resource :bookmark, only: :create
  298. post :unbookmark, to: 'bookmarks#destroy'
  299. resource :mute, only: :create
  300. post :unmute, to: 'mutes#destroy'
  301. resource :pin, only: :create
  302. post :unpin, to: 'pins#destroy'
  303. resource :history, only: :show
  304. resource :source, only: :show
  305. end
  306. member do
  307. get :context
  308. end
  309. end
  310. namespace :timelines do
  311. resource :home, only: :show, controller: :home
  312. resource :public, only: :show, controller: :public
  313. resources :tag, only: :show
  314. resources :list, only: :show
  315. end
  316. resources :streaming, only: [:index]
  317. resources :custom_emojis, only: [:index]
  318. resources :suggestions, only: [:index, :destroy]
  319. resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
  320. resources :preferences, only: [:index]
  321. resources :announcements, only: [:index] do
  322. scope module: :announcements do
  323. resources :reactions, only: [:update, :destroy]
  324. end
  325. member do
  326. post :dismiss
  327. end
  328. end
  329. # namespace :crypto do
  330. # resources :deliveries, only: :create
  331. # namespace :keys do
  332. # resource :upload, only: [:create]
  333. # resource :query, only: [:create]
  334. # resource :claim, only: [:create]
  335. # resource :count, only: [:show]
  336. # end
  337. # resources :encrypted_messages, only: [:index] do
  338. # collection do
  339. # post :clear
  340. # end
  341. # end
  342. # end
  343. resources :conversations, only: [:index, :destroy] do
  344. member do
  345. post :read
  346. end
  347. end
  348. resources :media, only: [:create, :update, :show]
  349. resources :blocks, only: [:index]
  350. resources :mutes, only: [:index]
  351. resources :favourites, only: [:index]
  352. resources :bookmarks, only: [:index]
  353. resources :reports, only: [:create]
  354. resources :trends, only: [:index], controller: 'trends/tags'
  355. resources :filters, only: [:index, :create, :show, :update, :destroy]
  356. resources :endorsements, only: [:index]
  357. resources :markers, only: [:index, :create]
  358. namespace :apps do
  359. get :verify_credentials, to: 'credentials#show'
  360. end
  361. resources :apps, only: [:create]
  362. namespace :trends do
  363. resources :links, only: [:index]
  364. resources :tags, only: [:index]
  365. resources :statuses, only: [:index]
  366. end
  367. namespace :emails do
  368. resources :confirmations, only: [:create]
  369. end
  370. resource :instance, only: [:show] do
  371. resources :peers, only: [:index], controller: 'instances/peers'
  372. resource :activity, only: [:show], controller: 'instances/activity'
  373. resources :rules, only: [:index], controller: 'instances/rules'
  374. end
  375. resource :domain_blocks, only: [:show, :create, :destroy]
  376. resource :directory, only: [:show]
  377. resources :follow_requests, only: [:index] do
  378. member do
  379. post :authorize
  380. post :reject
  381. end
  382. end
  383. resources :notifications, only: [:index, :show] do
  384. collection do
  385. post :clear
  386. end
  387. member do
  388. post :dismiss
  389. end
  390. end
  391. namespace :accounts do
  392. get :verify_credentials, to: 'credentials#show'
  393. patch :update_credentials, to: 'credentials#update'
  394. resource :search, only: :show, controller: :search
  395. resource :lookup, only: :show, controller: :lookup
  396. resources :relationships, only: :index
  397. resources :familiar_followers, only: :index
  398. end
  399. resources :accounts, only: [:create, :show] do
  400. resources :statuses, only: :index, controller: 'accounts/statuses'
  401. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  402. resources :following, only: :index, controller: 'accounts/following_accounts'
  403. resources :lists, only: :index, controller: 'accounts/lists'
  404. resources :identity_proofs, only: :index, controller: 'accounts/identity_proofs'
  405. resources :featured_tags, only: :index, controller: 'accounts/featured_tags'
  406. member do
  407. post :follow
  408. post :unfollow
  409. post :remove_from_followers
  410. post :block
  411. post :unblock
  412. post :mute
  413. post :unmute
  414. end
  415. resource :pin, only: :create, controller: 'accounts/pins'
  416. post :unpin, to: 'accounts/pins#destroy'
  417. resource :note, only: :create, controller: 'accounts/notes'
  418. end
  419. resources :lists, only: [:index, :create, :show, :update, :destroy] do
  420. resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts'
  421. end
  422. namespace :featured_tags do
  423. get :suggestions, to: 'suggestions#index'
  424. end
  425. resources :featured_tags, only: [:index, :create, :destroy]
  426. resources :polls, only: [:create, :show] do
  427. resources :votes, only: :create, controller: 'polls/votes'
  428. end
  429. namespace :push do
  430. resource :subscription, only: [:create, :show, :update, :destroy]
  431. end
  432. namespace :admin do
  433. resources :accounts, only: [:index, :show, :destroy] do
  434. member do
  435. post :enable
  436. post :unsensitive
  437. post :unsilence
  438. post :unsuspend
  439. post :approve
  440. post :reject
  441. end
  442. resource :action, only: [:create], controller: 'account_actions'
  443. end
  444. resources :reports, only: [:index, :update, :show] do
  445. member do
  446. post :assign_to_self
  447. post :unassign
  448. post :reopen
  449. post :resolve
  450. end
  451. end
  452. namespace :trends do
  453. resources :tags, only: [:index]
  454. resources :links, only: [:index]
  455. resources :statuses, only: [:index]
  456. end
  457. post :measures, to: 'measures#create'
  458. post :dimensions, to: 'dimensions#create'
  459. post :retention, to: 'retention#create'
  460. end
  461. end
  462. namespace :v2 do
  463. resources :media, only: [:create]
  464. get '/search', to: 'search#index', as: :search
  465. resources :suggestions, only: [:index]
  466. end
  467. namespace :web do
  468. resource :settings, only: [:update]
  469. resource :embed, only: [:create]
  470. resources :push_subscriptions, only: [:create] do
  471. member do
  472. put :update
  473. end
  474. end
  475. end
  476. end
  477. get '/web/(*any)', to: 'home#index', as: :web
  478. get '/about', to: 'about#show'
  479. get '/about/more', to: 'about#more'
  480. get '/terms', to: 'about#terms'
  481. match '/', via: [:post, :put, :patch, :delete], to: 'application#raise_not_found', format: false
  482. match '*unmatched_route', via: :all, to: 'application#raise_not_found', format: false
  483. end