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.
 
 
 
 

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