routes.rb 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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_scope :user do
  19. get '/invite/:invite_code', to: 'auth/registrations#new', as: :public_invite
  20. match '/auth/finish_signup' => 'auth/confirmations#finish_signup', via: [:get, :patch], as: :finish_signup
  21. end
  22. devise_for :users, path: 'auth', controllers: {
  23. omniauth_callbacks: 'auth/omniauth_callbacks',
  24. sessions: 'auth/sessions',
  25. registrations: 'auth/registrations',
  26. passwords: 'auth/passwords',
  27. confirmations: 'auth/confirmations',
  28. }
  29. get '/users/:username', to: redirect('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  30. resources :accounts, path: 'users', only: [:show], param: :username do
  31. resources :stream_entries, path: 'updates', only: [:show] do
  32. member do
  33. get :embed
  34. end
  35. end
  36. get :remote_follow, to: 'remote_follow#new'
  37. post :remote_follow, to: 'remote_follow#create'
  38. resources :statuses, only: [:show] do
  39. member do
  40. get :activity
  41. get :embed
  42. end
  43. end
  44. resources :followers, only: [:index], controller: :follower_accounts
  45. resources :following, only: [:index], controller: :following_accounts
  46. resource :follow, only: [:create], controller: :account_follow
  47. resource :unfollow, only: [:create], controller: :account_unfollow
  48. resource :outbox, only: [:show], module: :activitypub
  49. resource :inbox, only: [:create], module: :activitypub
  50. resources :collections, only: [:show], module: :activitypub
  51. end
  52. resource :inbox, only: [:create], module: :activitypub
  53. get '/@:username', to: 'accounts#show', as: :short_account
  54. get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
  55. get '/@:username/media', to: 'accounts#show', as: :short_account_media
  56. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  57. get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
  58. namespace :settings do
  59. resource :profile, only: [:show, :update]
  60. resource :preferences, only: [:show, :update]
  61. resource :notifications, only: [:show, :update]
  62. resource :import, only: [:show, :create]
  63. resource :export, only: [:show, :create]
  64. namespace :exports, constraints: { format: :csv } do
  65. resources :follows, only: :index, controller: :following_accounts
  66. resources :blocks, only: :index, controller: :blocked_accounts
  67. resources :mutes, only: :index, controller: :muted_accounts
  68. end
  69. resource :two_factor_authentication, only: [:show, :create, :destroy]
  70. namespace :two_factor_authentication do
  71. resources :recovery_codes, only: [:create]
  72. resource :confirmation, only: [:new, :create]
  73. end
  74. resource :follower_domains, only: [:show, :update]
  75. resources :applications, except: [:edit] do
  76. member do
  77. post :regenerate
  78. end
  79. end
  80. resource :delete, only: [:show, :destroy]
  81. resource :migration, only: [:show, :update]
  82. resources :sessions, only: [:destroy]
  83. end
  84. resources :media, only: [:show] do
  85. get :player
  86. end
  87. resources :tags, only: [:show]
  88. resources :emojis, only: [:show]
  89. resources :invites, only: [:index, :create, :destroy]
  90. get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy
  91. # Remote follow
  92. resource :authorize_follow, only: [:show, :create]
  93. resource :share, only: [:show, :create]
  94. namespace :admin do
  95. resources :subscriptions, only: [:index]
  96. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  97. resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
  98. resources :action_logs, only: [:index]
  99. resource :settings, only: [:edit, :update]
  100. resources :invites, only: [:index, :create, :destroy]
  101. resources :instances, only: [:index] do
  102. collection do
  103. post :resubscribe
  104. end
  105. end
  106. resources :reports, only: [:index, :show, :update] do
  107. resources :reported_statuses, only: [:create, :update, :destroy]
  108. end
  109. resources :report_notes, only: [:create, :destroy]
  110. resources :accounts, only: [:index, :show] do
  111. member do
  112. post :subscribe
  113. post :unsubscribe
  114. post :enable
  115. post :disable
  116. post :redownload
  117. post :remove_avatar
  118. post :memorialize
  119. end
  120. resource :reset, only: [:create]
  121. resource :silence, only: [:create, :destroy]
  122. resource :suspension, only: [:create, :destroy]
  123. resource :confirmation, only: [:create]
  124. resources :statuses, only: [:index, :create, :update, :destroy]
  125. resource :role do
  126. member do
  127. post :promote
  128. post :demote
  129. end
  130. end
  131. end
  132. resources :users, only: [] do
  133. resource :two_factor_authentication, only: [:destroy]
  134. end
  135. resources :custom_emojis, only: [:index, :new, :create, :update, :destroy] do
  136. member do
  137. post :copy
  138. post :enable
  139. post :disable
  140. end
  141. end
  142. resources :account_moderation_notes, only: [:create, :destroy]
  143. end
  144. authenticate :user, lambda { |u| u.admin? } do
  145. get '/admin', to: redirect('/admin/settings/edit', status: 302)
  146. end
  147. authenticate :user, lambda { |u| u.moderator? } do
  148. get '/admin', to: redirect('/admin/reports', status: 302)
  149. end
  150. namespace :api do
  151. # PubSubHubbub outgoing subscriptions
  152. resources :subscriptions, only: [:show]
  153. post '/subscriptions/:id', to: 'subscriptions#update'
  154. # PubSubHubbub incoming subscriptions
  155. post '/push', to: 'push#update', as: :push
  156. # Salmon
  157. post '/salmon/:id', to: 'salmon#update', as: :salmon
  158. # OEmbed
  159. get '/oembed', to: 'oembed#show', as: :oembed
  160. # JSON / REST API
  161. namespace :v1 do
  162. resources :statuses, only: [:create, :show, :destroy] do
  163. scope module: :statuses do
  164. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  165. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  166. resource :reblog, only: :create
  167. post :unreblog, to: 'reblogs#destroy'
  168. resource :favourite, only: :create
  169. post :unfavourite, to: 'favourites#destroy'
  170. resource :mute, only: :create
  171. post :unmute, to: 'mutes#destroy'
  172. resource :pin, only: :create
  173. post :unpin, to: 'pins#destroy'
  174. end
  175. member do
  176. get :context
  177. get :card
  178. end
  179. end
  180. namespace :timelines do
  181. resource :home, only: :show, controller: :home
  182. resource :public, only: :show, controller: :public
  183. resources :tag, only: :show
  184. resources :list, only: :show
  185. end
  186. resources :streaming, only: [:index]
  187. resources :custom_emojis, only: [:index]
  188. get '/search', to: 'search#index', as: :search
  189. resources :follows, only: [:create]
  190. resources :media, only: [:create, :update]
  191. resources :blocks, only: [:index]
  192. resources :mutes, only: [:index]
  193. resources :favourites, only: [:index]
  194. resources :reports, only: [:index, :create]
  195. namespace :apps do
  196. get :verify_credentials, to: 'credentials#show'
  197. end
  198. resources :apps, only: [:create]
  199. resource :instance, only: [:show] do
  200. resources :peers, only: [:index], controller: 'instances/peers'
  201. resource :activity, only: [:show], controller: 'instances/activity'
  202. end
  203. resource :domain_blocks, only: [:show, :create, :destroy]
  204. resources :follow_requests, only: [:index] do
  205. member do
  206. post :authorize
  207. post :reject
  208. end
  209. end
  210. resources :notifications, only: [:index, :show] do
  211. collection do
  212. post :clear
  213. post :dismiss
  214. end
  215. end
  216. namespace :accounts do
  217. get :verify_credentials, to: 'credentials#show'
  218. patch :update_credentials, to: 'credentials#update'
  219. resource :search, only: :show, controller: :search
  220. resources :relationships, only: :index
  221. end
  222. resources :accounts, only: [:show] do
  223. resources :statuses, only: :index, controller: 'accounts/statuses'
  224. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  225. resources :following, only: :index, controller: 'accounts/following_accounts'
  226. resources :lists, only: :index, controller: 'accounts/lists'
  227. member do
  228. post :follow
  229. post :unfollow
  230. post :block
  231. post :unblock
  232. post :mute
  233. post :unmute
  234. end
  235. end
  236. resources :lists, only: [:index, :create, :show, :update, :destroy] do
  237. resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts'
  238. end
  239. end
  240. namespace :web do
  241. resource :settings, only: [:update]
  242. resource :embed, only: [:create]
  243. resources :push_subscriptions, only: [:create] do
  244. member do
  245. put :update
  246. end
  247. end
  248. end
  249. end
  250. get '/web/(*any)', to: 'home#index', as: :web
  251. get '/about', to: 'about#show'
  252. get '/about/more', to: 'about#more'
  253. get '/terms', to: 'about#terms'
  254. root 'home#index'
  255. match '*unmatched_route',
  256. via: :all,
  257. to: 'application#raise_not_found',
  258. format: false
  259. end