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.
 
 
 
 

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