闭社主体 forked from https://github.com/tootsuite/mastodon
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.

223 lines
6.9 KiB

8 years ago
7 years ago
8 years ago
Account domain blocks (#2381) * Add <ostatus:conversation /> tag to Atom input/output Only uses ref attribute (not href) because href would be the alternate link that's always included also. Creates new conversation for every non-reply status. Carries over conversation for every reply. Keeps remote URIs verbatim, generates local URIs on the fly like the rest of them. * Conversation muting - prevents notifications that reference a conversation (including replies, favourites, reblogs) from being created. API endpoints /api/v1/statuses/:id/mute and /api/v1/statuses/:id/unmute Currently no way to tell when a status/conversation is muted, so the web UI only has a "disable notifications" button, doesn't work as a toggle * Display "Dismiss notifications" on all statuses in notifications column, not just own * Add "muted" as a boolean attribute on statuses JSON For now always false on contained reblogs, since it's only relevant for statuses returned from the notifications endpoint, which are not nested Remove "Disable notifications" from detailed status view, since it's only relevant in the notifications column * Up max class length * Remove pending test for conversation mute * Add tests, clean up * Rename to "mute conversation" and "unmute conversation" * Raise validation error when trying to mute/unmute status without conversation * Adding account domain blocks that filter notifications and public timelines * Add tests for domain blocks in notifications, public timelines Filter reblogs of blocked domains from home * Add API for listing and creating account domain blocks * API for creating/deleting domain blocks, tests for Status#ancestors and Status#descendants, filter domain blocks from them * Filter domains in streaming API * Update account_domain_block_spec.rb
7 years ago
8 years ago
  1. # frozen_string_literal: true
  2. require 'sidekiq/web'
  3. require 'sidekiq-scheduler/web'
  4. Rails.application.routes.draw do
  5. mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
  6. authenticate :user, lambda { |u| u.admin? } do
  7. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  8. mount PgHero::Engine, at: 'pghero', as: :pghero
  9. end
  10. use_doorkeeper do
  11. controllers authorizations: 'oauth/authorizations', authorized_applications: 'oauth/authorized_applications'
  12. end
  13. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  14. get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
  15. get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
  16. devise_for :users, path: 'auth', controllers: {
  17. sessions: 'auth/sessions',
  18. registrations: 'auth/registrations',
  19. passwords: 'auth/passwords',
  20. confirmations: 'auth/confirmations',
  21. }
  22. get '/users/:username', to: redirect('/@%{username}'), constraints: { format: :html }
  23. resources :accounts, path: 'users', only: [:show], param: :username do
  24. resources :stream_entries, path: 'updates', only: [:show] do
  25. member do
  26. get :embed
  27. end
  28. end
  29. get :remote_follow, to: 'remote_follow#new'
  30. post :remote_follow, to: 'remote_follow#create'
  31. resources :followers, only: [:index], controller: :follower_accounts
  32. resources :following, only: [:index], controller: :following_accounts
  33. resource :follow, only: [:create], controller: :account_follow
  34. resource :unfollow, only: [:create], controller: :account_unfollow
  35. end
  36. get '/@:username', to: 'accounts#show', as: :short_account
  37. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  38. namespace :settings do
  39. resource :profile, only: [:show, :update]
  40. resource :preferences, only: [:show, :update]
  41. resource :import, only: [:show, :create]
  42. resource :export, only: [:show]
  43. namespace :exports, constraints: { format: :csv } do
  44. resources :follows, only: :index, controller: :following_accounts
  45. resources :blocks, only: :index, controller: :blocked_accounts
  46. resources :mutes, only: :index, controller: :muted_accounts
  47. end
  48. resource :two_factor_authentication, only: [:show, :create, :destroy]
  49. namespace :two_factor_authentication do
  50. resources :recovery_codes, only: [:create]
  51. resource :confirmation, only: [:new, :create]
  52. end
  53. resource :follower_domains, only: [:show, :update]
  54. end
  55. resources :media, only: [:show]
  56. resources :tags, only: [:show]
  57. # Remote follow
  58. resource :authorize_follow, only: [:show, :create]
  59. namespace :admin do
  60. resources :subscriptions, only: [:index]
  61. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  62. resource :settings, only: [:edit, :update]
  63. resources :instances, only: [:index]
  64. resources :reports, only: [:index, :show, :update] do
  65. resources :reported_statuses, only: [:update, :destroy]
  66. end
  67. resources :accounts, only: [:index, :show] do
  68. member do
  69. post :subscribe
  70. post :unsubscribe
  71. post :redownload
  72. end
  73. resource :reset, only: [:create]
  74. resource :silence, only: [:create, :destroy]
  75. resource :suspension, only: [:create, :destroy]
  76. resource :confirmation, only: [:create]
  77. end
  78. resources :users, only: [] do
  79. resource :two_factor_authentication, only: [:destroy]
  80. end
  81. end
  82. get '/admin', to: redirect('/admin/settings/edit', status: 302)
  83. namespace :api do
  84. # PubSubHubbub outgoing subscriptions
  85. resources :subscriptions, only: [:show]
  86. post '/subscriptions/:id', to: 'subscriptions#update'
  87. # PubSubHubbub incoming subscriptions
  88. post '/push', to: 'push#update', as: :push
  89. # Salmon
  90. post '/salmon/:id', to: 'salmon#update', as: :salmon
  91. # OEmbed
  92. get '/oembed', to: 'oembed#show', as: :oembed
  93. # ActivityPub
  94. namespace :activitypub do
  95. get '/users/:id/outbox', to: 'outbox#show', as: :outbox
  96. get '/statuses/:id', to: 'activities#show_status', as: :status
  97. resources :notes, only: [:show]
  98. end
  99. # JSON / REST API
  100. namespace :v1 do
  101. resources :statuses, only: [:create, :show, :destroy] do
  102. scope module: :statuses do
  103. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  104. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  105. resource :reblog, only: :create
  106. post :unreblog, to: 'reblogs#destroy'
  107. resource :favourite, only: :create
  108. post :unfavourite, to: 'favourites#destroy'
  109. resource :mute, only: :create
  110. post :unmute, to: 'mutes#destroy'
  111. end
  112. member do
  113. get :context
  114. get :card
  115. end
  116. end
  117. namespace :timelines do
  118. resource :home, only: :show, controller: :home
  119. resource :public, only: :show, controller: :public
  120. resources :tag, only: :show
  121. end
  122. resources :streaming, only: [:index]
  123. get '/search', to: 'search#index', as: :search
  124. resources :follows, only: [:create]
  125. resources :media, only: [:create]
  126. resources :apps, only: [:create]
  127. resources :blocks, only: [:index]
  128. resources :mutes, only: [:index]
  129. resources :favourites, only: [:index]
  130. resources :reports, only: [:index, :create]
  131. resource :instance, only: [:show]
  132. resource :domain_blocks, only: [:show, :create, :destroy]
  133. resources :follow_requests, only: [:index] do
  134. member do
  135. post :authorize
  136. post :reject
  137. end
  138. end
  139. resources :notifications, only: [:index, :show] do
  140. collection do
  141. post :clear
  142. post :dismiss
  143. end
  144. end
  145. namespace :accounts do
  146. get :verify_credentials, to: 'credentials#show'
  147. patch :update_credentials, to: 'credentials#update'
  148. resource :search, only: :show, controller: :search
  149. resources :relationships, only: :index
  150. end
  151. resources :accounts, only: [:show] do
  152. resources :statuses, only: :index, controller: 'accounts/statuses'
  153. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  154. resources :following, only: :index, controller: 'accounts/following_accounts'
  155. member do
  156. post :follow
  157. post :unfollow
  158. post :block
  159. post :unblock
  160. post :mute
  161. post :unmute
  162. end
  163. end
  164. end
  165. namespace :web do
  166. resource :settings, only: [:update]
  167. end
  168. end
  169. get '/web/(*any)', to: 'home#index', as: :web
  170. get '/about', to: 'about#show'
  171. get '/about/more', to: 'about#more'
  172. get '/terms', to: 'about#terms'
  173. root 'home#index'
  174. match '*unmatched_route',
  175. via: :all,
  176. to: 'application#raise_not_found',
  177. format: false
  178. end