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.
 
 
 
 

429 line
13 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 '.well-known/change-password', to: redirect('/auth/edit')
  19. get '.well-known/keybase-proof-config', to: 'well_known/keybase_proof_config#show'
  20. get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
  21. get 'intent', to: 'intents#show'
  22. get 'custom.css', to: 'custom_css#show', as: :custom_css
  23. devise_scope :user do
  24. get '/invite/:invite_code', to: 'auth/registrations#new', as: :public_invite
  25. match '/auth/finish_signup' => 'auth/confirmations#finish_signup', via: [:get, :patch], as: :finish_signup
  26. end
  27. devise_for :users, path: 'auth', controllers: {
  28. omniauth_callbacks: 'auth/omniauth_callbacks',
  29. sessions: 'auth/sessions',
  30. registrations: 'auth/registrations',
  31. passwords: 'auth/passwords',
  32. confirmations: 'auth/confirmations',
  33. }
  34. get '/users/:username', to: redirect('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  35. get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
  36. resources :accounts, path: 'users', only: [:show], param: :username do
  37. resources :stream_entries, path: 'updates', only: [:show] do
  38. member do
  39. get :embed
  40. end
  41. end
  42. get :remote_follow, to: 'remote_follow#new'
  43. post :remote_follow, to: 'remote_follow#create'
  44. resources :statuses, only: [:show] do
  45. member do
  46. get :activity
  47. get :embed
  48. get :replies
  49. end
  50. end
  51. resources :followers, only: [:index], controller: :follower_accounts
  52. resources :following, only: [:index], controller: :following_accounts
  53. resource :follow, only: [:create], controller: :account_follow
  54. resource :unfollow, only: [:create], controller: :account_unfollow
  55. resource :outbox, only: [:show], module: :activitypub
  56. resource :inbox, only: [:create], module: :activitypub
  57. resources :collections, only: [:show], module: :activitypub
  58. end
  59. resource :inbox, only: [:create], module: :activitypub
  60. get '/@:username', to: 'accounts#show', as: :short_account
  61. get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
  62. get '/@:username/media', to: 'accounts#show', as: :short_account_media
  63. get '/@:username/tagged/:tag', to: 'accounts#show', as: :short_account_tag
  64. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  65. get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
  66. get '/interact/:id', to: 'remote_interaction#new', as: :remote_interaction
  67. post '/interact/:id', to: 'remote_interaction#create'
  68. get '/explore', to: 'directories#index', as: :explore
  69. get '/explore/:id', to: 'directories#show', as: :explore_hashtag
  70. get '/settings', to: redirect('/settings/preferences')
  71. namespace :settings do
  72. resource :profile, only: [:show, :update]
  73. resource :preferences, only: [:show, :update]
  74. namespace :preferences do
  75. resource :appearance, only: [:show, :update], controller: :appearance
  76. resource :notifications, only: [:show, :update]
  77. end
  78. resource :import, only: [:show, :create]
  79. resource :export, only: [:show, :create]
  80. namespace :exports, constraints: { format: :csv } do
  81. resources :follows, only: :index, controller: :following_accounts
  82. resources :blocks, only: :index, controller: :blocked_accounts
  83. resources :mutes, only: :index, controller: :muted_accounts
  84. resources :lists, only: :index, controller: :lists
  85. resources :domain_blocks, only: :index, controller: :blocked_domains
  86. end
  87. resource :two_factor_authentication, only: [:show, :create, :destroy]
  88. namespace :two_factor_authentication do
  89. resources :recovery_codes, only: [:create]
  90. resource :confirmation, only: [:new, :create]
  91. end
  92. resources :identity_proofs, only: [:index, :show, :new, :create, :update]
  93. resources :applications, except: [:edit] do
  94. member do
  95. post :regenerate
  96. end
  97. end
  98. resource :delete, only: [:show, :destroy]
  99. resource :migration, only: [:show, :update]
  100. resources :sessions, only: [:destroy]
  101. resources :featured_tags, only: [:index, :create, :destroy]
  102. end
  103. resources :media, only: [:show] do
  104. get :player
  105. end
  106. resources :tags, only: [:show]
  107. resources :emojis, only: [:show]
  108. resources :invites, only: [:index, :create, :destroy]
  109. resources :filters, except: [:show]
  110. resource :relationships, only: [:show, :update]
  111. get '/public', to: 'public_timelines#show', as: :public_timeline
  112. get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy
  113. # Remote follow
  114. resource :remote_unfollow, only: [:create]
  115. resource :authorize_interaction, only: [:show, :create]
  116. resource :share, only: [:show, :create]
  117. namespace :admin do
  118. get '/dashboard', to: 'dashboard#index'
  119. resources :subscriptions, only: [:index]
  120. resources :domain_blocks, only: [:new, :create, :show, :destroy]
  121. resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
  122. resources :action_logs, only: [:index]
  123. resources :warning_presets, except: [:new]
  124. resource :settings, only: [:edit, :update]
  125. resources :invites, only: [:index, :create, :destroy] do
  126. collection do
  127. post :deactivate_all
  128. end
  129. end
  130. resources :relays, only: [:index, :new, :create, :destroy] do
  131. member do
  132. post :enable
  133. post :disable
  134. end
  135. end
  136. resources :instances, only: [:index, :show], constraints: { id: /[^\/]+/ }
  137. resources :reports, only: [:index, :show] do
  138. member do
  139. post :assign_to_self
  140. post :unassign
  141. post :reopen
  142. post :resolve
  143. end
  144. resources :reported_statuses, only: [:create]
  145. end
  146. resources :report_notes, only: [:create, :destroy]
  147. resources :accounts, only: [:index, :show] do
  148. member do
  149. post :subscribe
  150. post :unsubscribe
  151. post :enable
  152. post :unsilence
  153. post :unsuspend
  154. post :redownload
  155. post :remove_avatar
  156. post :remove_header
  157. post :memorialize
  158. post :approve
  159. post :reject
  160. end
  161. resource :change_email, only: [:show, :update]
  162. resource :reset, only: [:create]
  163. resource :action, only: [:new, :create], controller: 'account_actions'
  164. resources :statuses, only: [:index, :show, :create, :update, :destroy]
  165. resources :followers, only: [:index]
  166. resource :confirmation, only: [:create] do
  167. collection do
  168. post :resend
  169. end
  170. end
  171. resource :role do
  172. member do
  173. post :promote
  174. post :demote
  175. end
  176. end
  177. end
  178. resources :pending_accounts, only: [:index] do
  179. collection do
  180. post :approve_all
  181. post :reject_all
  182. post :batch
  183. end
  184. end
  185. resources :users, only: [] do
  186. resource :two_factor_authentication, only: [:destroy]
  187. end
  188. resources :custom_emojis, only: [:index, :new, :create, :update, :destroy] do
  189. member do
  190. post :copy
  191. post :enable
  192. post :disable
  193. end
  194. end
  195. resources :account_moderation_notes, only: [:create, :destroy]
  196. resources :tags, only: [:index] do
  197. member do
  198. post :hide
  199. post :unhide
  200. end
  201. end
  202. end
  203. get '/admin', to: redirect('/admin/dashboard', status: 302)
  204. namespace :api do
  205. # PubSubHubbub outgoing subscriptions
  206. resources :subscriptions, only: [:show]
  207. post '/subscriptions/:id', to: 'subscriptions#update'
  208. # PubSubHubbub incoming subscriptions
  209. post '/push', to: 'push#update', as: :push
  210. # Salmon
  211. post '/salmon/:id', to: 'salmon#update', as: :salmon
  212. # OEmbed
  213. get '/oembed', to: 'oembed#show', as: :oembed
  214. # Identity proofs
  215. get :proofs, to: 'proofs#index'
  216. # JSON / REST API
  217. namespace :v1 do
  218. resources :statuses, only: [:create, :show, :destroy] do
  219. scope module: :statuses do
  220. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  221. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  222. resource :reblog, only: :create
  223. post :unreblog, to: 'reblogs#destroy'
  224. resource :favourite, only: :create
  225. post :unfavourite, to: 'favourites#destroy'
  226. resource :mute, only: :create
  227. post :unmute, to: 'mutes#destroy'
  228. resource :pin, only: :create
  229. post :unpin, to: 'pins#destroy'
  230. end
  231. member do
  232. get :context
  233. get :card
  234. end
  235. end
  236. namespace :timelines do
  237. resource :direct, only: :show, controller: :direct
  238. resource :home, only: :show, controller: :home
  239. resource :public, only: :show, controller: :public
  240. resources :tag, only: :show
  241. resources :list, only: :show
  242. end
  243. resources :streaming, only: [:index]
  244. resources :custom_emojis, only: [:index]
  245. resources :suggestions, only: [:index, :destroy]
  246. resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
  247. resources :preferences, only: [:index]
  248. resources :conversations, only: [:index, :destroy] do
  249. member do
  250. post :read
  251. end
  252. end
  253. get '/search', to: 'search#index', as: :search
  254. resources :follows, only: [:create]
  255. resources :media, only: [:create, :update]
  256. resources :blocks, only: [:index]
  257. resources :mutes, only: [:index]
  258. resources :favourites, only: [:index]
  259. resources :reports, only: [:create]
  260. resources :filters, only: [:index, :create, :show, :update, :destroy]
  261. resources :endorsements, only: [:index]
  262. namespace :apps do
  263. get :verify_credentials, to: 'credentials#show'
  264. end
  265. resources :apps, only: [:create]
  266. resource :instance, only: [:show] do
  267. resources :peers, only: [:index], controller: 'instances/peers'
  268. resource :activity, only: [:show], controller: 'instances/activity'
  269. end
  270. resource :domain_blocks, only: [:show, :create, :destroy]
  271. resources :follow_requests, only: [:index] do
  272. member do
  273. post :authorize
  274. post :reject
  275. end
  276. end
  277. resources :notifications, only: [:index, :show] do
  278. collection do
  279. post :clear
  280. post :dismiss # Deprecated
  281. end
  282. member do
  283. post :dismiss
  284. end
  285. end
  286. namespace :accounts do
  287. get :verify_credentials, to: 'credentials#show'
  288. patch :update_credentials, to: 'credentials#update'
  289. resource :search, only: :show, controller: :search
  290. resources :relationships, only: :index
  291. end
  292. resources :accounts, only: [:create, :show] do
  293. resources :statuses, only: :index, controller: 'accounts/statuses'
  294. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  295. resources :following, only: :index, controller: 'accounts/following_accounts'
  296. resources :lists, only: :index, controller: 'accounts/lists'
  297. resources :identity_proofs, only: :index, controller: 'accounts/identity_proofs'
  298. member do
  299. post :follow
  300. post :unfollow
  301. post :block
  302. post :unblock
  303. post :mute
  304. post :unmute
  305. end
  306. resource :pin, only: :create, controller: 'accounts/pins'
  307. post :unpin, to: 'accounts/pins#destroy'
  308. end
  309. resources :lists, only: [:index, :create, :show, :update, :destroy] do
  310. resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts'
  311. end
  312. resources :polls, only: [:create, :show] do
  313. resources :votes, only: :create, controller: 'polls/votes'
  314. end
  315. namespace :push do
  316. resource :subscription, only: [:create, :show, :update, :destroy]
  317. end
  318. end
  319. namespace :v2 do
  320. get '/search', to: 'search#index', as: :search
  321. end
  322. namespace :web do
  323. resource :settings, only: [:update]
  324. resource :embed, only: [:create]
  325. resources :push_subscriptions, only: [:create] do
  326. member do
  327. put :update
  328. end
  329. end
  330. end
  331. end
  332. get '/web/(*any)', to: 'home#index', as: :web
  333. get '/about', to: 'about#show'
  334. get '/about/more', to: 'about#more'
  335. get '/terms', to: 'about#terms'
  336. root 'home#index'
  337. match '*unmatched_route',
  338. via: :all,
  339. to: 'application#raise_not_found',
  340. format: false
  341. end