routes.rb 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. # frozen_string_literal: true
  2. require 'sidekiq/web'
  3. require 'sidekiq-scheduler/web'
  4. Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]
  5. Rails.application.routes.draw do
  6. mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
  7. authenticate :user, lambda { |u| u.admin? } do
  8. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  9. mount PgHero::Engine, at: 'pghero', as: :pghero
  10. end
  11. use_doorkeeper do
  12. controllers authorizations: 'oauth/authorizations', authorized_applications: 'oauth/authorized_applications'
  13. end
  14. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  15. get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
  16. get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
  17. get 'intent', to: 'intents#show'
  18. devise_for :users, path: 'auth', controllers: {
  19. sessions: 'auth/sessions',
  20. registrations: 'auth/registrations',
  21. passwords: 'auth/passwords',
  22. confirmations: 'auth/confirmations',
  23. }
  24. get '/users/:username', to: redirect('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  25. resources :accounts, path: 'users', only: [:show], param: :username do
  26. resources :stream_entries, path: 'updates', only: [:show] do
  27. member do
  28. get :embed
  29. end
  30. end
  31. get :remote_follow, to: 'remote_follow#new'
  32. post :remote_follow, to: 'remote_follow#create'
  33. resources :statuses, only: [:show] do
  34. member do
  35. get :activity
  36. get :embed
  37. end
  38. end
  39. resources :followers, only: [:index], controller: :follower_accounts
  40. resources :following, only: [:index], controller: :following_accounts
  41. resource :follow, only: [:create], controller: :account_follow
  42. resource :unfollow, only: [:create], controller: :account_unfollow
  43. resource :outbox, only: [:show], module: :activitypub
  44. resource :inbox, only: [:create], module: :activitypub
  45. end
  46. resource :inbox, only: [:create], module: :activitypub
  47. get '/@:username', to: 'accounts#show', as: :short_account
  48. get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
  49. get '/@:username/media', to: 'accounts#show', as: :short_account_media
  50. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  51. get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
  52. namespace :settings do
  53. resource :profile, only: [:show, :update]
  54. resource :preferences, only: [:show, :update]
  55. resource :notifications, only: [:show, :update]
  56. resource :import, only: [:show, :create]
  57. resource :export, only: [:show]
  58. namespace :exports, constraints: { format: :csv } do
  59. resources :follows, only: :index, controller: :following_accounts
  60. resources :blocks, only: :index, controller: :blocked_accounts
  61. resources :mutes, only: :index, controller: :muted_accounts
  62. end
  63. resource :two_factor_authentication, only: [:show, :create, :destroy]
  64. namespace :two_factor_authentication do
  65. resources :recovery_codes, only: [:create]
  66. resource :confirmation, only: [:new, :create]
  67. end
  68. resource :follower_domains, only: [:show, :update]
  69. resources :applications, except: [:edit] do
  70. member do
  71. post :regenerate
  72. end
  73. end
  74. resource :delete, only: [:show, :destroy]
  75. resources :sessions, only: [:destroy]
  76. end
  77. resources :media, only: [:show]
  78. resources :tags, only: [:show]
  79. resources :emojis, only: [:show]
  80. get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy
  81. # Remote follow
  82. resource :authorize_follow, only: [:show, :create]
  83. resource :share, only: [:show, :create]
  84. namespace :admin do
  85. resources :subscriptions, only: [:index]
  86. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  87. resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
  88. resource :settings, only: [:edit, :update]
  89. resources :instances, only: [:index] do
  90. collection do
  91. post :resubscribe
  92. end
  93. end
  94. resources :reports, only: [:index, :show, :update] do
  95. resources :reported_statuses, only: [:create, :update, :destroy]
  96. end
  97. resources :accounts, only: [:index, :show] do
  98. member do
  99. post :subscribe
  100. post :unsubscribe
  101. post :redownload
  102. end
  103. resource :reset, only: [:create]
  104. resource :silence, only: [:create, :destroy]
  105. resource :suspension, only: [:create, :destroy]
  106. resource :confirmation, only: [:create]
  107. resources :statuses, only: [:index, :create, :update, :destroy]
  108. end
  109. resources :users, only: [] do
  110. resource :two_factor_authentication, only: [:destroy]
  111. end
  112. resources :custom_emojis, only: [:index, :new, :create, :destroy] do
  113. member do
  114. post :copy
  115. post :enable
  116. post :disable
  117. end
  118. end
  119. resources :account_moderation_notes, only: [:create, :destroy]
  120. end
  121. get '/admin', to: redirect('/admin/settings/edit', status: 302)
  122. namespace :api do
  123. # PubSubHubbub outgoing subscriptions
  124. resources :subscriptions, only: [:show]
  125. post '/subscriptions/:id', to: 'subscriptions#update'
  126. # PubSubHubbub incoming subscriptions
  127. post '/push', to: 'push#update', as: :push
  128. # Salmon
  129. post '/salmon/:id', to: 'salmon#update', as: :salmon
  130. # OEmbed
  131. get '/oembed', to: 'oembed#show', as: :oembed
  132. # JSON / REST API
  133. namespace :v1 do
  134. resources :statuses, only: [:create, :show, :destroy] do
  135. scope module: :statuses do
  136. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  137. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  138. resource :reblog, only: :create
  139. post :unreblog, to: 'reblogs#destroy'
  140. resource :favourite, only: :create
  141. post :unfavourite, to: 'favourites#destroy'
  142. resource :mute, only: :create
  143. post :unmute, to: 'mutes#destroy'
  144. resource :pin, only: :create
  145. post :unpin, to: 'pins#destroy'
  146. end
  147. member do
  148. get :context
  149. get :card
  150. end
  151. end
  152. namespace :timelines do
  153. resource :home, only: :show, controller: :home
  154. resource :public, only: :show, controller: :public
  155. resources :tag, only: :show
  156. end
  157. resources :streaming, only: [:index]
  158. resources :custom_emojis, only: [:index]
  159. get '/search', to: 'search#index', as: :search
  160. resources :follows, only: [:create]
  161. resources :media, only: [:create, :update]
  162. resources :blocks, only: [:index]
  163. resources :mutes, only: [:index]
  164. resources :favourites, only: [:index]
  165. resources :reports, only: [:index, :create]
  166. namespace :apps do
  167. get :verify_credentials, to: 'credentials#show'
  168. end
  169. resources :apps, only: [:create]
  170. resource :instance, only: [:show]
  171. resource :domain_blocks, only: [:show, :create, :destroy]
  172. resources :follow_requests, only: [:index] do
  173. member do
  174. post :authorize
  175. post :reject
  176. end
  177. end
  178. resources :notifications, only: [:index, :show] do
  179. collection do
  180. post :clear
  181. post :dismiss
  182. end
  183. end
  184. namespace :accounts do
  185. get :verify_credentials, to: 'credentials#show'
  186. patch :update_credentials, to: 'credentials#update'
  187. resource :search, only: :show, controller: :search
  188. resources :relationships, only: :index
  189. end
  190. resources :accounts, only: [:show] do
  191. resources :statuses, only: :index, controller: 'accounts/statuses'
  192. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  193. resources :following, only: :index, controller: 'accounts/following_accounts'
  194. member do
  195. post :follow
  196. post :unfollow
  197. post :block
  198. post :unblock
  199. post :mute
  200. post :unmute
  201. end
  202. end
  203. end
  204. namespace :web do
  205. resource :settings, only: [:update]
  206. resource :embed, only: [:create]
  207. resources :push_subscriptions, only: [:create] do
  208. member do
  209. put :update
  210. end
  211. end
  212. end
  213. end
  214. get '/web/(*any)', to: 'home#index', as: :web
  215. get '/about', to: 'about#show'
  216. get '/about/more', to: 'about#more'
  217. get '/terms', to: 'about#terms'
  218. root 'home#index'
  219. match '*unmatched_route',
  220. via: :all,
  221. to: 'application#raise_not_found',
  222. format: false
  223. end