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.

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