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.

165 lines
5.2 KiB

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
Optional notification muting (#5087) * Add a hide_notifications column to mutes * Add muting_notifications? and a notifications argument to mute! * block notifications in notify_service from hard muted accounts * Add specs for how mute! interacts with muting_notifications? * specs testing that hide_notifications in mutes actually hides notifications * Add support for muting notifications in MuteService * API support for muting notifications (and specs) * Less gross passing of notifications flag * Break out a separate mute modal with a hide-notifications checkbox. * Convert profile header mute to use mute modal * Satisfy eslint. * specs for MuteService notifications params * add trailing newlines to files for Pork :) * Put the label for the hide notifications checkbox in a label element. * Add a /api/v1/mutes/details route that just returns the array of mutes. * Define a serializer for /api/v1/mutes/details * Add more specs for the /api/v1/mutes/details endpoint * Expose whether a mute hides notifications in the api/v1/relationships endpoint * Show whether muted users' notifications are muted in account lists * Allow modifying the hide_notifications of a mute with the /api/v1/accounts/:id/mute endpoint * make the hide/unhide notifications buttons work * satisfy eslint * In probably dead code, replace a dispatch of muteAccount that was skipping the modal with launching the mute modal. * fix a missing import * add an explanatory comment to AccountInteractions * Refactor handling of default params for muting to make code cleaner * minor code style fixes oops * Fixed a typo that was breaking the account mute API endpoint * Apply white-space: nowrap to account relationships icons * Fix code style issues * Remove superfluous blank line * Rename /api/v1/mutes/details -> /api/v2/mutes * Don't serialize "account" in MuteSerializer Doing so is somewhat unnecessary since it's always the current user's account. * Fix wrong variable name in api/v2/mutes * Use Toggle in place of checkbox in the mute modal. * Make the Toggle in the mute modal look better * Code style changes in specs and removed an extra space * Code review suggestions from akihikodaki Also fixed a syntax error in tests for AccountInteractions. * Make AddHideNotificationsToMute Concurrent It's not clear how much this will benefit instances in practice, as the number of mutes tends to be pretty small, but this should prevent any blocking migrations nonetheless. * Fix up migration things * Remove /api/v2/mutes
6 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
Allow hiding of reblogs from followed users (#5762) * Allow hiding of reblogs from followed users This adds a new entry to the account menu to allow users to hide future reblogs from a user (and then if they've done that, to show future reblogs instead). This does not remove or add historical reblogs from/to the user's timeline; it only affects new statuses. The API for this operates by sending a "reblogs" key to the follow endpoint. If this is sent when starting a new follow, it will be respected from the beginning of the follow relationship (even if the follow request must be approved by the followee). If this is sent when a follow relationship already exists, it will simply update the existing follow relationship. As with the notification muting, this will now return an object ({reblogs: [true|false]}) or false for each follow relationship when requesting relationship information for an account. This should cause few issues due to an object being truthy in many languages, but some modifications may need to be made in pickier languages. Database changes: adds a show_reblogs column (default true, non-nullable) to the follows and follow_requests tables. Because these are non-nullable, we use the existing MigrationHelpers to perform this change without locking those tables, although the tables are likely to be small anyway. Tests included. See also <https://github.com/glitch-soc/mastodon/pull/212>. * Rubocop fixes * Code review changes * Test fixes This patchset closes #648 and resolves #3271. * Rubocop fix * Revert reblogs defaulting in argument, fix tests It turns out we needed this for the same reason we needed it in muting: if nil gets passed in somehow (most usually by an API client not passing any value), we need to detect and handle it. We could specify a default in the parameter and then also catch nil, but there's no great reason to duplicate the default value.
6 years ago
Allow hiding of reblogs from followed users (#5762) * Allow hiding of reblogs from followed users This adds a new entry to the account menu to allow users to hide future reblogs from a user (and then if they've done that, to show future reblogs instead). This does not remove or add historical reblogs from/to the user's timeline; it only affects new statuses. The API for this operates by sending a "reblogs" key to the follow endpoint. If this is sent when starting a new follow, it will be respected from the beginning of the follow relationship (even if the follow request must be approved by the followee). If this is sent when a follow relationship already exists, it will simply update the existing follow relationship. As with the notification muting, this will now return an object ({reblogs: [true|false]}) or false for each follow relationship when requesting relationship information for an account. This should cause few issues due to an object being truthy in many languages, but some modifications may need to be made in pickier languages. Database changes: adds a show_reblogs column (default true, non-nullable) to the follows and follow_requests tables. Because these are non-nullable, we use the existing MigrationHelpers to perform this change without locking those tables, although the tables are likely to be small anyway. Tests included. See also <https://github.com/glitch-soc/mastodon/pull/212>. * Rubocop fixes * Code review changes * Test fixes This patchset closes #648 and resolves #3271. * Rubocop fix * Revert reblogs defaulting in argument, fix tests It turns out we needed this for the same reason we needed it in muting: if nil gets passed in somehow (most usually by an API client not passing any value), we need to detect and handle it. We could specify a default in the parameter and then also catch nil, but there's no great reason to duplicate the default value.
6 years ago
Allow hiding of reblogs from followed users (#5762) * Allow hiding of reblogs from followed users This adds a new entry to the account menu to allow users to hide future reblogs from a user (and then if they've done that, to show future reblogs instead). This does not remove or add historical reblogs from/to the user's timeline; it only affects new statuses. The API for this operates by sending a "reblogs" key to the follow endpoint. If this is sent when starting a new follow, it will be respected from the beginning of the follow relationship (even if the follow request must be approved by the followee). If this is sent when a follow relationship already exists, it will simply update the existing follow relationship. As with the notification muting, this will now return an object ({reblogs: [true|false]}) or false for each follow relationship when requesting relationship information for an account. This should cause few issues due to an object being truthy in many languages, but some modifications may need to be made in pickier languages. Database changes: adds a show_reblogs column (default true, non-nullable) to the follows and follow_requests tables. Because these are non-nullable, we use the existing MigrationHelpers to perform this change without locking those tables, although the tables are likely to be small anyway. Tests included. See also <https://github.com/glitch-soc/mastodon/pull/212>. * Rubocop fixes * Code review changes * Test fixes This patchset closes #648 and resolves #3271. * Rubocop fix * Revert reblogs defaulting in argument, fix tests It turns out we needed this for the same reason we needed it in muting: if nil gets passed in somehow (most usually by an API client not passing any value), we need to detect and handle it. We could specify a default in the parameter and then also catch nil, but there's no great reason to duplicate the default value.
6 years ago
  1. require 'rails_helper'
  2. RSpec.describe NotifyService, type: :service do
  3. subject do
  4. -> { described_class.new.call(recipient, type, activity) }
  5. end
  6. let(:user) { Fabricate(:user) }
  7. let(:recipient) { user.account }
  8. let(:sender) { Fabricate(:account, domain: 'example.com') }
  9. let(:activity) { Fabricate(:follow, account: sender, target_account: recipient) }
  10. let(:type) { :follow }
  11. it { is_expected.to change(Notification, :count).by(1) }
  12. it 'does not notify when sender is blocked' do
  13. recipient.block!(sender)
  14. is_expected.to_not change(Notification, :count)
  15. end
  16. it 'does not notify when sender is muted with hide_notifications' do
  17. recipient.mute!(sender, notifications: true)
  18. is_expected.to_not change(Notification, :count)
  19. end
  20. it 'does notify when sender is muted without hide_notifications' do
  21. recipient.mute!(sender, notifications: false)
  22. is_expected.to change(Notification, :count)
  23. end
  24. it 'does not notify when sender\'s domain is blocked' do
  25. recipient.block_domain!(sender.domain)
  26. is_expected.to_not change(Notification, :count)
  27. end
  28. it 'does still notify when sender\'s domain is blocked but sender is followed' do
  29. recipient.block_domain!(sender.domain)
  30. recipient.follow!(sender)
  31. is_expected.to change(Notification, :count)
  32. end
  33. it 'does not notify when sender is silenced and not followed' do
  34. sender.silence!
  35. is_expected.to_not change(Notification, :count)
  36. end
  37. it 'does not notify when recipient is suspended' do
  38. recipient.suspend!
  39. is_expected.to_not change(Notification, :count)
  40. end
  41. context 'for direct messages' do
  42. let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct)) }
  43. let(:type) { :mention }
  44. before do
  45. user.settings.interactions = user.settings.interactions.merge('must_be_following_dm' => enabled)
  46. end
  47. context 'if recipient is supposed to be following sender' do
  48. let(:enabled) { true }
  49. it 'does not notify' do
  50. is_expected.to_not change(Notification, :count)
  51. end
  52. context 'if the message chain initiated by recipient, but is not direct message' do
  53. let(:reply_to) { Fabricate(:status, account: recipient) }
  54. let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
  55. it 'does not notify' do
  56. is_expected.to_not change(Notification, :count)
  57. end
  58. end
  59. context 'if the message chain initiated by recipient and is direct message' do
  60. let(:reply_to) { Fabricate(:status, account: recipient, visibility: :direct) }
  61. let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct, thread: reply_to)) }
  62. it 'does notify' do
  63. is_expected.to change(Notification, :count)
  64. end
  65. end
  66. end
  67. context 'if recipient is NOT supposed to be following sender' do
  68. let(:enabled) { false }
  69. it 'does notify' do
  70. is_expected.to change(Notification, :count)
  71. end
  72. end
  73. end
  74. describe 'reblogs' do
  75. let(:status) { Fabricate(:status, account: Fabricate(:account)) }
  76. let(:activity) { Fabricate(:status, account: sender, reblog: status) }
  77. let(:type) { :reblog }
  78. it 'shows reblogs by default' do
  79. recipient.follow!(sender)
  80. is_expected.to change(Notification, :count)
  81. end
  82. it 'shows reblogs when explicitly enabled' do
  83. recipient.follow!(sender, reblogs: true)
  84. is_expected.to change(Notification, :count)
  85. end
  86. it 'shows reblogs when disabled' do
  87. recipient.follow!(sender, reblogs: false)
  88. is_expected.to change(Notification, :count)
  89. end
  90. end
  91. context do
  92. let(:asshole) { Fabricate(:account, username: 'asshole') }
  93. let(:reply_to) { Fabricate(:status, account: asshole) }
  94. let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, thread: reply_to)) }
  95. let(:type) { :mention }
  96. it 'does not notify when conversation is muted' do
  97. recipient.mute_conversation!(activity.status.conversation)
  98. is_expected.to_not change(Notification, :count)
  99. end
  100. it 'does not notify when it is a reply to a blocked user' do
  101. recipient.block!(asshole)
  102. is_expected.to_not change(Notification, :count)
  103. end
  104. end
  105. context do
  106. let(:sender) { recipient }
  107. it 'does not notify when recipient is the sender' do
  108. is_expected.to_not change(Notification, :count)
  109. end
  110. end
  111. describe 'email' do
  112. before do
  113. ActionMailer::Base.deliveries.clear
  114. notification_emails = user.settings.notification_emails
  115. user.settings.notification_emails = notification_emails.merge('follow' => enabled)
  116. end
  117. context 'when email notification is enabled' do
  118. let(:enabled) { true }
  119. it 'sends email' do
  120. is_expected.to change(ActionMailer::Base.deliveries, :count).by(1)
  121. end
  122. end
  123. context 'when email notification is disabled' do
  124. let(:enabled) { false }
  125. it "doesn't send email" do
  126. is_expected.to_not change(ActionMailer::Base.deliveries, :count).from(0)
  127. end
  128. end
  129. end
  130. end