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.
 
 
 
 

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