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.

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