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.
 
 
 
 

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