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.

376 lines
12 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',
  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 'manifest', to: 'manifests#show', defaults: { format: 'json' }
  19. get 'intent', to: 'intents#show'
  20. get 'custom.css', to: 'custom_css#show', as: :custom_css
  21. devise_scope :user do
  22. get '/invite/:invite_code', to: 'auth/registrations#new', as: :public_invite
  23. match '/auth/finish_signup' => 'auth/confirmations#finish_signup', via: [:get, :patch], as: :finish_signup
  24. end
  25. devise_for :users, path: 'auth', controllers: {
  26. omniauth_callbacks: 'auth/omniauth_callbacks',
  27. sessions: 'auth/sessions',
  28. registrations: 'auth/registrations',
  29. passwords: 'auth/passwords',
  30. confirmations: 'auth/confirmations',
  31. }
  32. get '/users/:username', to: redirect('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  33. get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" }
  34. resources :accounts, path: 'users', only: [:show], param: :username do
  35. resources :stream_entries, path: 'updates', only: [:show] do
  36. member do
  37. get :embed
  38. end
  39. end
  40. get :remote_follow, to: 'remote_follow#new'
  41. post :remote_follow, to: 'remote_follow#create'
  42. resources :statuses, only: [:show] do
  43. member do
  44. get :activity
  45. get :embed
  46. end
  47. end
  48. resources :followers, only: [:index], controller: :follower_accounts
  49. resources :following, only: [:index], controller: :following_accounts
  50. resource :follow, only: [:create], controller: :account_follow
  51. resource :unfollow, only: [:create], controller: :account_unfollow
  52. resource :outbox, only: [:show], module: :activitypub
  53. resource :inbox, only: [:create], module: :activitypub
  54. resources :collections, only: [:show], module: :activitypub
  55. end
  56. resource :inbox, only: [:create], module: :activitypub
  57. get '/@:username', to: 'accounts#show', as: :short_account
  58. get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
  59. get '/@:username/media', to: 'accounts#show', as: :short_account_media
  60. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  61. get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
  62. get '/interact/:id', to: 'remote_interaction#new', as: :remote_interaction
  63. post '/interact/:id', to: 'remote_interaction#create'
  64. namespace :settings do
  65. resource :profile, only: [:show, :update]
  66. resource :preferences, only: [:show, :update]
  67. resource :notifications, only: [:show, :update]
  68. resource :import, only: [:show, :create]
  69. resource :export, only: [:show, :create]
  70. namespace :exports, constraints: { format: :csv } do
  71. resources :follows, only: :index, controller: :following_accounts
  72. resources :blocks, only: :index, controller: :blocked_accounts
  73. resources :mutes, only: :index, controller: :muted_accounts
  74. end
  75. resource :two_factor_authentication, only: [:show, :create, :destroy]
  76. namespace :two_factor_authentication do
  77. resources :recovery_codes, only: [:create]
  78. resource :confirmation, only: [:new, :create]
  79. end
  80. resource :follower_domains, only: [:show, :update]
  81. resources :applications, except: [:edit] do
  82. member do
  83. post :regenerate
  84. end
  85. end
  86. resources :flavours, only: [:index, :show, :update], param: :flavour
  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, :show, :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 :bookmark, only: :create
  191. post :unbookmark, to: 'bookmarks#destroy'
  192. resource :mute, only: :create
  193. post :unmute, to: 'mutes#destroy'
  194. resource :pin, only: :create
  195. post :unpin, to: 'pins#destroy'
  196. end
  197. member do
  198. get :context
  199. get :card
  200. end
  201. end
  202. namespace :timelines do
  203. resource :direct, only: :show, controller: :direct
  204. resource :home, only: :show, controller: :home
  205. resource :public, only: :show, controller: :public
  206. resources :tag, only: :show
  207. resources :list, only: :show
  208. end
  209. resources :streaming, only: [:index]
  210. resources :custom_emojis, only: [:index]
  211. resources :suggestions, only: [:index, :destroy]
  212. get '/search', to: 'search#index', as: :search
  213. resources :follows, only: [:create]
  214. resources :media, only: [:create, :update]
  215. resources :blocks, only: [:index]
  216. resources :mutes, only: [:index] do
  217. collection do
  218. get 'details'
  219. end
  220. end
  221. resources :favourites, only: [:index]
  222. resources :bookmarks, only: [:index]
  223. resources :reports, only: [:index, :create]
  224. resources :filters, only: [:index, :create, :show, :update, :destroy]
  225. resources :endorsements, only: [:index]
  226. namespace :apps do
  227. get :verify_credentials, to: 'credentials#show'
  228. end
  229. resources :apps, only: [:create]
  230. resource :instance, only: [:show] do
  231. resources :peers, only: [:index], controller: 'instances/peers'
  232. resource :activity, only: [:show], controller: 'instances/activity'
  233. end
  234. resource :domain_blocks, only: [:show, :create, :destroy]
  235. resources :follow_requests, only: [:index] do
  236. member do
  237. post :authorize
  238. post :reject
  239. end
  240. end
  241. resources :notifications, only: [:index, :show, :destroy] do
  242. collection do
  243. post :clear
  244. post :dismiss
  245. delete :destroy_multiple
  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