routes.rb 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. # frozen_string_literal: true
  2. require 'sidekiq/web'
  3. Rails.application.routes.draw do
  4. mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
  5. authenticate :user, lambda { |u| u.admin? } do
  6. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  7. mount PgHero::Engine, at: 'pghero', as: :pghero
  8. end
  9. use_doorkeeper do
  10. controllers authorizations: 'oauth/authorizations', authorized_applications: 'oauth/authorized_applications'
  11. end
  12. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  13. get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
  14. devise_for :users, path: 'auth', controllers: {
  15. sessions: 'auth/sessions',
  16. registrations: 'auth/registrations',
  17. passwords: 'auth/passwords',
  18. confirmations: 'auth/confirmations',
  19. }
  20. get '/users/:username', to: redirect('/@%{username}'), constraints: { format: :html }
  21. resources :accounts, path: 'users', only: [:show], param: :username do
  22. resources :stream_entries, path: 'updates', only: [:show] do
  23. member do
  24. get :embed
  25. end
  26. end
  27. get :remote_follow, to: 'remote_follow#new'
  28. post :remote_follow, to: 'remote_follow#create'
  29. resources :followers, only: [:index], controller: :follower_accounts
  30. resources :following, only: [:index], controller: :following_accounts
  31. resource :follow, only: [:create], controller: :account_follow
  32. resource :unfollow, only: [:create], controller: :account_unfollow
  33. end
  34. get '/@:username', to: 'accounts#show', as: :short_account
  35. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  36. namespace :settings do
  37. resource :profile, only: [:show, :update]
  38. resource :preferences, only: [:show, :update]
  39. resource :import, only: [:show, :create]
  40. resource :export, only: [:show]
  41. namespace :exports, constraints: { format: :csv } do
  42. resources :follows, only: :index, controller: :following_accounts
  43. resources :blocks, only: :index, controller: :blocked_accounts
  44. resources :mutes, only: :index, controller: :muted_accounts
  45. end
  46. resource :two_factor_authentication, only: [:show, :create, :destroy]
  47. namespace :two_factor_authentication do
  48. resources :recovery_codes, only: [:create]
  49. resource :confirmation, only: [:new, :create]
  50. end
  51. resource :follower_domains, only: [:show, :update]
  52. end
  53. resources :media, only: [:show]
  54. resources :tags, only: [:show]
  55. # Remote follow
  56. resource :authorize_follow, only: [:show, :create]
  57. namespace :admin do
  58. resources :pubsubhubbub, only: [:index]
  59. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  60. resource :settings, only: [:edit, :update]
  61. resources :instances, only: [:index]
  62. resources :reports, only: [:index, :show, :update] do
  63. resources :reported_statuses, only: :destroy
  64. end
  65. resources :accounts, only: [:index, :show] do
  66. resource :reset, only: [:create]
  67. resource :silence, only: [:create, :destroy]
  68. resource :suspension, only: [:create, :destroy]
  69. resource :confirmation, only: [:create]
  70. end
  71. resources :users, only: [] do
  72. resource :two_factor_authentication, only: [:destroy]
  73. end
  74. end
  75. get '/admin', to: redirect('/admin/settings', status: 302)
  76. namespace :api do
  77. # PubSubHubbub outgoing subscriptions
  78. resources :subscriptions, only: [:show]
  79. post '/subscriptions/:id', to: 'subscriptions#update'
  80. # PubSubHubbub incoming subscriptions
  81. post '/push', to: 'push#update', as: :push
  82. # Salmon
  83. post '/salmon/:id', to: 'salmon#update', as: :salmon
  84. # OEmbed
  85. get '/oembed', to: 'oembed#show', as: :oembed
  86. # ActivityPub
  87. namespace :activitypub do
  88. get '/users/:id/outbox', to: 'outbox#show', as: :outbox
  89. get '/statuses/:id', to: 'activities#show_status', as: :status
  90. resources :notes, only: [:show]
  91. end
  92. # JSON / REST API
  93. namespace :v1 do
  94. resources :statuses, only: [:create, :show, :destroy] do
  95. member do
  96. get :context
  97. get :card
  98. get :reblogged_by
  99. get :favourited_by
  100. post :reblog
  101. post :unreblog
  102. post :favourite
  103. post :unfavourite
  104. end
  105. end
  106. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  107. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  108. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  109. get '/search', to: 'search#index', as: :search
  110. resources :follows, only: [:create]
  111. resources :media, only: [:create]
  112. resources :apps, only: [:create]
  113. resources :blocks, only: [:index]
  114. resources :mutes, only: [:index]
  115. resources :favourites, only: [:index]
  116. resources :reports, only: [:index, :create]
  117. resource :instance, only: [:show]
  118. resources :follow_requests, only: [:index] do
  119. member do
  120. post :authorize
  121. post :reject
  122. end
  123. end
  124. resources :notifications, only: [:index, :show] do
  125. collection do
  126. post :clear
  127. post :dismiss
  128. end
  129. end
  130. resources :accounts, only: [:show] do
  131. collection do
  132. get :relationships
  133. get :verify_credentials
  134. patch :update_credentials
  135. get :search
  136. end
  137. member do
  138. get :statuses
  139. get :followers
  140. get :following
  141. post :follow
  142. post :unfollow
  143. post :block
  144. post :unblock
  145. post :mute
  146. post :unmute
  147. end
  148. end
  149. end
  150. namespace :web do
  151. resource :settings, only: [:update]
  152. end
  153. end
  154. get '/web/(*any)', to: 'home#index', as: :web
  155. get '/about', to: 'about#show'
  156. get '/about/more', to: 'about#more'
  157. get '/terms', to: 'about#terms'
  158. root 'home#index'
  159. match '*unmatched_route',
  160. via: :all,
  161. to: 'application#raise_not_found',
  162. format: false
  163. end