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.
 
 
 
 

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