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.
 
 
 
 

354 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. 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. get '/dashboard', to: 'dashboard#index'
  100. resources :subscriptions, only: [:index]
  101. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  102. resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
  103. resources :action_logs, only: [:index]
  104. resource :settings, only: [:edit, :update]
  105. resources :invites, only: [:index, :create, :destroy]
  106. resources :relays, only: [:index, :new, :create, :destroy] do
  107. member do
  108. post :enable
  109. post :disable
  110. end
  111. end
  112. resources :instances, only: [:index] do
  113. collection do
  114. post :resubscribe
  115. end
  116. end
  117. resources :reports, only: [:index, :show, :update] do
  118. resources :reported_statuses, only: [:create]
  119. end
  120. resources :report_notes, only: [:create, :destroy]
  121. resources :accounts, only: [:index, :show] do
  122. member do
  123. post :subscribe
  124. post :unsubscribe
  125. post :enable
  126. post :disable
  127. post :redownload
  128. post :remove_avatar
  129. post :memorialize
  130. end
  131. resource :change_email, only: [:show, :update]
  132. resource :reset, only: [:create]
  133. resource :silence, only: [:create, :destroy]
  134. resource :suspension, only: [:create, :destroy]
  135. resources :statuses, only: [:index, :create, :update, :destroy]
  136. resource :confirmation, only: [:create] do
  137. collection do
  138. post :resend
  139. end
  140. end
  141. resource :role do
  142. member do
  143. post :promote
  144. post :demote
  145. end
  146. end
  147. end
  148. resources :users, only: [] do
  149. resource :two_factor_authentication, only: [:destroy]
  150. end
  151. resources :custom_emojis, only: [:index, :new, :create, :update, :destroy] do
  152. member do
  153. post :copy
  154. post :enable
  155. post :disable
  156. end
  157. end
  158. resources :account_moderation_notes, only: [:create, :destroy]
  159. end
  160. get '/admin', to: redirect('/admin/dashboard', status: 302)
  161. namespace :api do
  162. # PubSubHubbub outgoing subscriptions
  163. resources :subscriptions, only: [:show]
  164. post '/subscriptions/:id', to: 'subscriptions#update'
  165. # PubSubHubbub incoming subscriptions
  166. post '/push', to: 'push#update', as: :push
  167. # Salmon
  168. post '/salmon/:id', to: 'salmon#update', as: :salmon
  169. # OEmbed
  170. get '/oembed', to: 'oembed#show', as: :oembed
  171. # JSON / REST API
  172. namespace :v1 do
  173. resources :statuses, only: [:create, :show, :destroy] do
  174. scope module: :statuses do
  175. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  176. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  177. resource :reblog, only: :create
  178. post :unreblog, to: 'reblogs#destroy'
  179. resource :favourite, only: :create
  180. post :unfavourite, to: 'favourites#destroy'
  181. resource :mute, only: :create
  182. post :unmute, to: 'mutes#destroy'
  183. resource :pin, only: :create
  184. post :unpin, to: 'pins#destroy'
  185. end
  186. member do
  187. get :context
  188. get :card
  189. end
  190. end
  191. namespace :timelines do
  192. resource :direct, only: :show, controller: :direct
  193. resource :home, only: :show, controller: :home
  194. resource :public, only: :show, controller: :public
  195. resources :tag, only: :show
  196. resources :list, only: :show
  197. end
  198. resources :streaming, only: [:index]
  199. resources :custom_emojis, only: [:index]
  200. resources :suggestions, only: [:index, :destroy]
  201. get '/search', to: 'search#index', as: :search
  202. resources :follows, only: [:create]
  203. resources :media, only: [:create, :update]
  204. resources :blocks, only: [:index]
  205. resources :mutes, only: [:index]
  206. resources :favourites, only: [:index]
  207. resources :reports, only: [:index, :create]
  208. resources :filters, only: [:index, :create, :show, :update, :destroy]
  209. namespace :apps do
  210. get :verify_credentials, to: 'credentials#show'
  211. end
  212. resources :apps, only: [:create]
  213. resource :instance, only: [:show] do
  214. resources :peers, only: [:index], controller: 'instances/peers'
  215. resource :activity, only: [:show], controller: 'instances/activity'
  216. end
  217. resource :domain_blocks, only: [:show, :create, :destroy]
  218. resources :follow_requests, only: [:index] do
  219. member do
  220. post :authorize
  221. post :reject
  222. end
  223. end
  224. resources :notifications, only: [:index, :show] do
  225. collection do
  226. post :clear
  227. post :dismiss
  228. end
  229. end
  230. namespace :accounts do
  231. get :verify_credentials, to: 'credentials#show'
  232. patch :update_credentials, to: 'credentials#update'
  233. resource :search, only: :show, controller: :search
  234. resources :relationships, only: :index
  235. end
  236. resources :accounts, only: [:show] do
  237. resources :statuses, only: :index, controller: 'accounts/statuses'
  238. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  239. resources :following, only: :index, controller: 'accounts/following_accounts'
  240. resources :lists, only: :index, controller: 'accounts/lists'
  241. member do
  242. post :follow
  243. post :unfollow
  244. post :block
  245. post :unblock
  246. post :mute
  247. post :unmute
  248. end
  249. resource :pin, only: :create, controller: 'accounts/pins'
  250. post :unpin, to: 'accounts/pins#destroy'
  251. end
  252. resources :lists, only: [:index, :create, :show, :update, :destroy] do
  253. resource :accounts, only: [:show, :create, :destroy], controller: 'lists/accounts'
  254. end
  255. namespace :push do
  256. resource :subscription, only: [:create, :show, :update, :destroy]
  257. end
  258. end
  259. namespace :v2 do
  260. get '/search', to: 'search#index', as: :search
  261. end
  262. namespace :web do
  263. resource :settings, only: [:update]
  264. resource :embed, only: [:create]
  265. resources :push_subscriptions, only: [:create] do
  266. member do
  267. put :update
  268. end
  269. end
  270. end
  271. end
  272. get '/web/(*any)', to: 'home#index', as: :web
  273. get '/about', to: 'about#show'
  274. get '/about/more', to: 'about#more'
  275. get '/terms', to: 'about#terms'
  276. root 'home#index'
  277. match '*unmatched_route',
  278. via: :all,
  279. to: 'application#raise_not_found',
  280. format: false
  281. end