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.

311 lines
9.2 KiB

8 years ago
7 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
Web Push Notifications (#3243) * feat: Register push subscription * feat: Notify when mentioned * feat: Boost, favourite, reply, follow, follow request * feat: Notification interaction * feat: Handle change of public key * feat: Unsubscribe if things go wrong * feat: Do not send normal notifications if push is enabled * feat: Focus client if open * refactor: Move push logic to WebPushSubscription * feat: Better title and body * feat: Localize messages * chore: Fix lint errors * feat: Settings * refactor: Lazy load * fix: Check if push settings exist * feat: Device-based preferences * refactor: Simplify logic * refactor: Pull request feedback * refactor: Pull request feedback * refactor: Create /api/web/push_subscriptions endpoint * feat: Spec PushSubscriptionController * refactor: WebPushSubscription => Web::PushSubscription * feat: Spec Web::PushSubscription * feat: Display first media attachment * feat: Support direction * fix: Stuff broken while rebasing * refactor: Integration with session activations * refactor: Cleanup * refactor: Simplify implementation * feat: Set VAPID keys via environment * chore: Comments * fix: Crash when no alerts * fix: Set VAPID keys in testing environment * fix: Follow link * feat: Notification actions * fix: Delete previous subscription * chore: Temporary logs * refactor: Move migration to a later date * fix: Fetch the correct session activation and misc bugs * refactor: Move migration to a later date * fix: Remove follow request (no notifications) * feat: Send administrator contact to push service * feat: Set time-to-live * fix: Do not show sensitive images * fix: Reducer crash in error handling * feat: Add badge * chore: Fix lint error * fix: Checkbox label overlap * fix: Check for payload support * fix: Rename action "type" (crash in latest Chrome) * feat: Action to expand notification * fix: Lint errors * fix: Unescape notification body * fix: Do not allow boosting if the status is hidden * feat: Add VAPID keys to the production sample environment * fix: Strip HTML tags from status * refactor: Better error messages * refactor: Handle browser not implementing the VAPID protocol (Samsung Internet) * fix: Error when target_status is nil * fix: Handle lack of image * fix: Delete reference to invalid subscriptions * feat: Better error handling * fix: Unescape HTML characters after tags are striped * refactor: Simpify code * fix: Modify to work with #4091 * Sort strings alphabetically * i18n: Updated Polish translation it annoys me that it's not fully localized :P * refactor: Use current_session in PushSubscriptionController * fix: Rebase mistake * fix: Set cacheName to mastodon * refactor: Pull request feedback * refactor: Remove logging statements * chore(yarn): Fix conflicts with master * chore(yarn): Copy latest from master * chore(yarn): Readd offline-plugin * refactor: Use save! and update! * refactor: Send notifications async * fix: Allow retry when push fails * fix: Save track for failed pushes * fix: Minify sw.js * fix: Remove account_id from fabricator
7 years ago
8 years ago
  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. resources :keyword_mutes do
  55. collection do
  56. delete :destroy_all
  57. end
  58. end
  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. resources :sessions, only: [:destroy]
  81. end
  82. resources :media, only: [:show]
  83. resources :tags, only: [:show]
  84. resources :emojis, only: [:show]
  85. get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy
  86. # Remote follow
  87. resource :authorize_follow, only: [:show, :create]
  88. resource :share, only: [:show, :create]
  89. namespace :admin do
  90. resources :subscriptions, only: [:index]
  91. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  92. resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
  93. resource :settings, only: [:edit, :update]
  94. resources :instances, only: [:index] do
  95. collection do
  96. post :resubscribe
  97. end
  98. end
  99. resources :reports, only: [:index, :show, :update] do
  100. resources :reported_statuses, only: [:create, :update, :destroy]
  101. end
  102. resources :accounts, only: [:index, :show] do
  103. member do
  104. post :subscribe
  105. post :unsubscribe
  106. post :enable
  107. post :disable
  108. post :redownload
  109. post :memorialize
  110. end
  111. resource :reset, only: [:create]
  112. resource :silence, only: [:create, :destroy]
  113. resource :suspension, only: [:create, :destroy]
  114. resource :confirmation, only: [:create]
  115. resources :statuses, only: [:index, :create, :update, :destroy]
  116. resource :role do
  117. member do
  118. post :promote
  119. post :demote
  120. end
  121. end
  122. end
  123. resources :users, only: [] do
  124. resource :two_factor_authentication, only: [:destroy]
  125. end
  126. resources :custom_emojis, only: [:index, :new, :create, :update, :destroy] do
  127. member do
  128. post :copy
  129. post :enable
  130. post :disable
  131. end
  132. end
  133. resources :account_moderation_notes, only: [:create, :destroy]
  134. end
  135. authenticate :user, lambda { |u| u.admin? } do
  136. get '/admin', to: redirect('/admin/settings/edit', status: 302)
  137. end
  138. authenticate :user, lambda { |u| u.moderator? } do
  139. get '/admin', to: redirect('/admin/reports', status: 302)
  140. end
  141. namespace :api do
  142. # PubSubHubbub outgoing subscriptions
  143. resources :subscriptions, only: [:show]
  144. post '/subscriptions/:id', to: 'subscriptions#update'
  145. # PubSubHubbub incoming subscriptions
  146. post '/push', to: 'push#update', as: :push
  147. # Salmon
  148. post '/salmon/:id', to: 'salmon#update', as: :salmon
  149. # OEmbed
  150. get '/oembed', to: 'oembed#show', as: :oembed
  151. # JSON / REST API
  152. namespace :v1 do
  153. resources :statuses, only: [:create, :show, :destroy] do
  154. scope module: :statuses do
  155. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  156. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  157. resource :reblog, only: :create
  158. post :unreblog, to: 'reblogs#destroy'
  159. resource :favourite, only: :create
  160. post :unfavourite, to: 'favourites#destroy'
  161. resource :mute, only: :create
  162. post :unmute, to: 'mutes#destroy'
  163. resource :pin, only: :create
  164. post :unpin, to: 'pins#destroy'
  165. end
  166. member do
  167. get :context
  168. get :card
  169. end
  170. end
  171. namespace :timelines do
  172. resource :direct, only: :show, controller: :direct
  173. resource :home, only: :show, controller: :home
  174. resource :public, only: :show, controller: :public
  175. resources :tag, only: :show
  176. end
  177. resources :streaming, only: [:index]
  178. resources :custom_emojis, only: [:index]
  179. get '/search', to: 'search#index', as: :search
  180. resources :follows, only: [:create]
  181. resources :media, only: [:create, :update]
  182. resources :blocks, only: [:index]
  183. resources :mutes, only: [:index] do
  184. collection do
  185. get 'details'
  186. end
  187. end
  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]
  195. resource :domain_blocks, only: [:show, :create, :destroy]
  196. resources :follow_requests, only: [:index] do
  197. member do
  198. post :authorize
  199. post :reject
  200. end
  201. end
  202. resources :notifications, only: [:index, :show, :destroy] do
  203. collection do
  204. post :clear
  205. post :dismiss
  206. delete :destroy_multiple
  207. end
  208. end
  209. namespace :accounts do
  210. get :verify_credentials, to: 'credentials#show'
  211. patch :update_credentials, to: 'credentials#update'
  212. resource :search, only: :show, controller: :search
  213. resources :relationships, only: :index
  214. end
  215. resources :accounts, only: [:show] do
  216. resources :statuses, only: :index, controller: 'accounts/statuses'
  217. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  218. resources :following, only: :index, controller: 'accounts/following_accounts'
  219. member do
  220. post :follow
  221. post :unfollow
  222. post :block
  223. post :unblock
  224. post :mute
  225. post :unmute
  226. end
  227. end
  228. end
  229. namespace :web do
  230. resource :settings, only: [:update]
  231. resource :embed, only: [:create]
  232. resources :push_subscriptions, only: [:create] do
  233. member do
  234. put :update
  235. end
  236. end
  237. end
  238. end
  239. get '/web/(*any)', to: 'home#index', as: :web
  240. get '/about', to: 'about#show'
  241. get '/about/more', to: 'about#more'
  242. get '/terms', to: 'about#terms'
  243. root 'home#index'
  244. match '*unmatched_route',
  245. via: :all,
  246. to: 'application#raise_not_found',
  247. format: false
  248. end