routes.rb 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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', format: false, 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, format: false
  145. get '/backups/:id/download', to: 'backups#download', as: :download_backup, format: false
  146. resource :authorize_interaction, only: [:show, :create]
  147. resource :share, only: [:show, :create]
  148. namespace :admin do
  149. get '/dashboard', to: 'dashboard#index'
  150. resources :domain_allows, only: [:new, :create, :show, :destroy]
  151. resources :domain_blocks, only: [:new, :create, :destroy, :update, :edit]
  152. resources :email_domain_blocks, only: [:index, :new, :create] do
  153. collection do
  154. post :batch
  155. end
  156. end
  157. resources :action_logs, only: [:index]
  158. resources :warning_presets, except: [:new]
  159. resources :announcements, except: [:show] do
  160. member do
  161. post :publish
  162. post :unpublish
  163. end
  164. end
  165. resource :settings, only: [:edit, :update]
  166. resources :site_uploads, only: [:destroy]
  167. resources :invites, only: [:index, :create, :destroy] do
  168. collection do
  169. post :deactivate_all
  170. end
  171. end
  172. resources :relays, only: [:index, :new, :create, :destroy] do
  173. member do
  174. post :enable
  175. post :disable
  176. end
  177. end
  178. resources :instances, only: [:index, :show, :destroy], constraints: { id: /[^\/]+/ }, format: 'html' do
  179. member do
  180. post :clear_delivery_errors
  181. post :restart_delivery
  182. post :stop_delivery
  183. end
  184. end
  185. resources :rules
  186. resources :reports, only: [:index, :show] do
  187. resources :actions, only: [:create], controller: 'reports/actions'
  188. member do
  189. post :assign_to_self
  190. post :unassign
  191. post :reopen
  192. post :resolve
  193. end
  194. end
  195. resources :report_notes, only: [:create, :destroy]
  196. resources :accounts, only: [:index, :show, :destroy] do
  197. member do
  198. post :enable
  199. post :unsensitive
  200. post :unsilence
  201. post :unsuspend
  202. post :redownload
  203. post :remove_avatar
  204. post :remove_header
  205. post :memorialize
  206. post :approve
  207. post :reject
  208. post :unblock_email
  209. end
  210. collection do
  211. post :batch
  212. end
  213. resource :change_email, only: [:show, :update]
  214. resource :reset, only: [:create]
  215. resource :action, only: [:new, :create], controller: 'account_actions'
  216. resources :statuses, only: [:index] do
  217. collection do
  218. post :batch
  219. end
  220. end
  221. resources :relationships, only: [:index]
  222. resource :confirmation, only: [:create] do
  223. collection do
  224. post :resend
  225. end
  226. end
  227. resource :role, only: [] do
  228. member do
  229. post :promote
  230. post :demote
  231. end
  232. end
  233. end
  234. resources :users, only: [] do
  235. resource :two_factor_authentication, only: [: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, format: false 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. resource :autogestione, only: :show, controller: :autogestione
  314. resources :tag, only: :show
  315. resources :list, only: :show
  316. end
  317. get '/streaming', to: 'streaming#index'
  318. get '/streaming/(*any)', to: 'streaming#index'
  319. resources :custom_emojis, only: [:index]
  320. resources :suggestions, only: [:index, :destroy]
  321. resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
  322. resources :preferences, only: [:index]
  323. resources :announcements, only: [:index] do
  324. scope module: :announcements do
  325. resources :reactions, only: [:update, :destroy]
  326. end
  327. member do
  328. post :dismiss
  329. end
  330. end
  331. # namespace :crypto do
  332. # resources :deliveries, only: :create
  333. # namespace :keys do
  334. # resource :upload, only: [:create]
  335. # resource :query, only: [:create]
  336. # resource :claim, only: [:create]
  337. # resource :count, only: [:show]
  338. # end
  339. # resources :encrypted_messages, only: [:index] do
  340. # collection do
  341. # post :clear
  342. # end
  343. # end
  344. # end
  345. resources :conversations, only: [:index, :destroy] do
  346. member do
  347. post :read
  348. end
  349. end
  350. resources :media, only: [:create, :update, :show]
  351. resources :blocks, only: [:index]
  352. resources :mutes, only: [:index]
  353. resources :favourites, only: [:index]
  354. resources :bookmarks, only: [:index]
  355. resources :reports, only: [:create]
  356. resources :trends, only: [:index], controller: 'trends/tags'
  357. resources :filters, only: [:index, :create, :show, :update, :destroy]
  358. resources :endorsements, only: [:index]
  359. resources :markers, only: [:index, :create]
  360. namespace :apps do
  361. get :verify_credentials, to: 'credentials#show'
  362. end
  363. resources :apps, only: [:create]
  364. namespace :trends do
  365. resources :links, only: [:index]
  366. resources :tags, only: [:index]
  367. resources :statuses, only: [:index]
  368. end
  369. namespace :emails do
  370. resources :confirmations, only: [:create]
  371. end
  372. resource :instance, only: [:show] do
  373. resources :peers, only: [:index], controller: 'instances/peers'
  374. resource :activity, only: [:show], controller: 'instances/activity'
  375. resources :rules, only: [:index], controller: 'instances/rules'
  376. end
  377. resource :domain_blocks, only: [:show, :create, :destroy]
  378. resource :directory, only: [:show]
  379. resources :follow_requests, only: [:index] do
  380. member do
  381. post :authorize
  382. post :reject
  383. end
  384. end
  385. resources :notifications, only: [:index, :show] do
  386. collection do
  387. post :clear
  388. end
  389. member do
  390. post :dismiss
  391. end
  392. end
  393. namespace :accounts do
  394. get :verify_credentials, to: 'credentials#show'
  395. patch :update_credentials, to: 'credentials#update'
  396. resource :search, only: :show, controller: :search
  397. resource :lookup, only: :show, controller: :lookup
  398. resources :relationships, only: :index
  399. resources :familiar_followers, only: :index
  400. end
  401. resources :accounts, only: [:create, :show] do
  402. resources :statuses, only: :index, controller: 'accounts/statuses'
  403. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  404. resources :following, only: :index, controller: 'accounts/following_accounts'
  405. resources :lists, only: :index, controller: 'accounts/lists'
  406. resources :identity_proofs, only: :index, controller: 'accounts/identity_proofs'
  407. resources :featured_tags, only: :index, controller: 'accounts/featured_tags'
  408. member do
  409. post :follow
  410. post :unfollow
  411. post :remove_from_followers
  412. post :block
  413. post :unblock
  414. post :mute
  415. post :unmute
  416. end
  417. resource :pin, only: :create, controller: 'accounts/pins'
  418. post :unpin, to: 'accounts/pins#destroy'
  419. resource :note, only: :create, controller: 'accounts/notes'
  420. end
  421. resources :lists, only: [:index, :create, :show, :update, :destroy] do
  422. resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts'
  423. end
  424. namespace :featured_tags do
  425. get :suggestions, to: 'suggestions#index'
  426. end
  427. resources :featured_tags, only: [:index, :create, :destroy]
  428. resources :polls, only: [:create, :show] do
  429. resources :votes, only: :create, controller: 'polls/votes'
  430. end
  431. namespace :push do
  432. resource :subscription, only: [:create, :show, :update, :destroy]
  433. end
  434. namespace :admin do
  435. resources :accounts, only: [:index, :show, :destroy] do
  436. member do
  437. post :enable
  438. post :unsensitive
  439. post :unsilence
  440. post :unsuspend
  441. post :approve
  442. post :reject
  443. end
  444. resource :action, only: [:create], controller: 'account_actions'
  445. end
  446. resources :reports, only: [:index, :update, :show] do
  447. member do
  448. post :assign_to_self
  449. post :unassign
  450. post :reopen
  451. post :resolve
  452. end
  453. end
  454. namespace :trends do
  455. resources :tags, only: [:index]
  456. resources :links, only: [:index]
  457. resources :statuses, only: [:index]
  458. end
  459. post :measures, to: 'measures#create'
  460. post :dimensions, to: 'dimensions#create'
  461. post :retention, to: 'retention#create'
  462. end
  463. end
  464. namespace :v2 do
  465. resources :media, only: [:create]
  466. get '/search', to: 'search#index', as: :search
  467. resources :suggestions, only: [:index]
  468. namespace :admin do
  469. resources :accounts, only: [:index]
  470. end
  471. end
  472. namespace :web do
  473. resource :settings, only: [:update]
  474. resource :embed, only: [:create]
  475. resources :push_subscriptions, only: [:create] do
  476. member do
  477. put :update
  478. end
  479. end
  480. end
  481. end
  482. get '/web/(*any)', to: 'home#index', as: :web
  483. get '/about', to: 'about#show'
  484. get '/about/more', to: 'about#more'
  485. get '/terms', to: 'about#terms'
  486. match '/', via: [:post, :put, :patch, :delete], to: 'application#raise_not_found', format: false
  487. match '*unmatched_route', via: :all, to: 'application#raise_not_found', format: false
  488. end