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.

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