The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

347 lines
10 KiB

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