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.
 
 
 
 

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