闭社主体 forked from https://github.com/tootsuite/mastodon
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.

134 lines
5.5 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
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
  1. require 'rails_helper'
  2. RSpec.describe FeedManager do
  3. describe '#key' do
  4. subject { FeedManager.instance.key(:home, 1) }
  5. it 'returns a string' do
  6. expect(subject).to be_a String
  7. end
  8. end
  9. describe '#filter?' do
  10. let(:alice) { Fabricate(:account, username: 'alice') }
  11. let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
  12. let(:jeff) { Fabricate(:account, username: 'jeff') }
  13. context 'for home feed' do
  14. it 'returns false for followee\'s status' do
  15. status = Fabricate(:status, text: 'Hello world', account: alice)
  16. bob.follow!(alice)
  17. expect(FeedManager.instance.filter?(:home, status, bob.id)).to be false
  18. end
  19. it 'returns false for reblog by followee' do
  20. status = Fabricate(:status, text: 'Hello world', account: jeff)
  21. reblog = Fabricate(:status, reblog: status, account: alice)
  22. bob.follow!(alice)
  23. expect(FeedManager.instance.filter?(:home, reblog, bob.id)).to be false
  24. end
  25. it 'returns true for reblog by followee of blocked account' do
  26. status = Fabricate(:status, text: 'Hello world', account: jeff)
  27. reblog = Fabricate(:status, reblog: status, account: alice)
  28. bob.follow!(alice)
  29. bob.block!(jeff)
  30. expect(FeedManager.instance.filter?(:home, reblog, bob.id)).to be true
  31. end
  32. it 'returns true for reblog by followee of muted account' do
  33. status = Fabricate(:status, text: 'Hello world', account: jeff)
  34. reblog = Fabricate(:status, reblog: status, account: alice)
  35. bob.follow!(alice)
  36. bob.mute!(jeff)
  37. expect(FeedManager.instance.filter?(:home, reblog, bob.id)).to be true
  38. end
  39. it 'returns true for reblog by followee of someone who is blocking recipient' do
  40. status = Fabricate(:status, text: 'Hello world', account: jeff)
  41. reblog = Fabricate(:status, reblog: status, account: alice)
  42. bob.follow!(alice)
  43. jeff.block!(bob)
  44. expect(FeedManager.instance.filter?(:home, reblog, bob.id)).to be true
  45. end
  46. it 'returns false for reply by followee to another followee' do
  47. status = Fabricate(:status, text: 'Hello world', account: jeff)
  48. reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
  49. bob.follow!(alice)
  50. bob.follow!(jeff)
  51. expect(FeedManager.instance.filter?(:home, reply, bob.id)).to be false
  52. end
  53. it 'returns false for reply by followee to recipient' do
  54. status = Fabricate(:status, text: 'Hello world', account: bob)
  55. reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
  56. bob.follow!(alice)
  57. expect(FeedManager.instance.filter?(:home, reply, bob.id)).to be false
  58. end
  59. it 'returns false for reply by followee to self' do
  60. status = Fabricate(:status, text: 'Hello world', account: alice)
  61. reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
  62. bob.follow!(alice)
  63. expect(FeedManager.instance.filter?(:home, reply, bob.id)).to be false
  64. end
  65. it 'returns true for reply by followee to non-followed account' do
  66. status = Fabricate(:status, text: 'Hello world', account: jeff)
  67. reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
  68. bob.follow!(alice)
  69. expect(FeedManager.instance.filter?(:home, reply, bob.id)).to be true
  70. end
  71. it 'returns false for status by followee mentioning another account' do
  72. bob.follow!(alice)
  73. status = PostStatusService.new.call(alice, 'Hey @jeff')
  74. expect(FeedManager.instance.filter?(:home, status, bob.id)).to be false
  75. end
  76. it 'returns true for status by followee mentioning blocked account' do
  77. bob.block!(jeff)
  78. bob.follow!(alice)
  79. status = PostStatusService.new.call(alice, 'Hey @jeff')
  80. expect(FeedManager.instance.filter?(:home, status, bob.id)).to be true
  81. end
  82. it 'returns true for reblog of a personally blocked domain' do
  83. alice.block_domain!('example.com')
  84. alice.follow!(jeff)
  85. status = Fabricate(:status, text: 'Hello world', account: bob)
  86. reblog = Fabricate(:status, reblog: status, account: jeff)
  87. expect(FeedManager.instance.filter?(:home, reblog, alice.id)).to be true
  88. end
  89. end
  90. context 'for mentions feed' do
  91. it 'returns true for status that mentions blocked account' do
  92. bob.block!(jeff)
  93. status = PostStatusService.new.call(alice, 'Hey @jeff')
  94. expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be true
  95. end
  96. it 'returns true for status that replies to a blocked account' do
  97. status = Fabricate(:status, text: 'Hello world', account: jeff)
  98. reply = Fabricate(:status, text: 'Nay', thread: status, account: alice)
  99. bob.block!(jeff)
  100. expect(FeedManager.instance.filter?(:mentions, reply, bob.id)).to be true
  101. end
  102. it 'returns true for status by silenced account who recipient is not following' do
  103. status = Fabricate(:status, text: 'Hello world', account: alice)
  104. alice.update(silenced: true)
  105. expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be true
  106. end
  107. it 'returns false for status by followed silenced account' do
  108. status = Fabricate(:status, text: 'Hello world', account: alice)
  109. alice.update(silenced: true)
  110. bob.follow!(alice)
  111. expect(FeedManager.instance.filter?(:mentions, status, bob.id)).to be false
  112. end
  113. end
  114. end
  115. end