The code powering m.abunchtell.com https://m.abunchtell.com
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

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