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.

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