Feature conversations muting (#3017)
* 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
This commit is contained in:
parent
a588358f41
commit
d0dd9eb5b5
52 changed files with 422 additions and 27 deletions
|
@ -183,6 +183,39 @@ RSpec.describe Api::V1::StatusesController, type: :controller do
|
|||
expect(user.account.favourited?(status)).to be false
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #mute' do
|
||||
let(:status) { Fabricate(:status, account: user.account) }
|
||||
|
||||
before do
|
||||
post :mute, params: { id: status.id }
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'creates a conversation mute' do
|
||||
expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #unmute' do
|
||||
let(:status) { Fabricate(:status, account: user.account) }
|
||||
|
||||
before do
|
||||
post :mute, params: { id: status.id }
|
||||
post :unmute, params: { id: status.id }
|
||||
end
|
||||
|
||||
it 'returns http success' do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'destroys the conversation mute' do
|
||||
expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'without an oauth token' do
|
||||
|
|
2
spec/fabricators/conversation_mute_fabricator.rb
Normal file
2
spec/fabricators/conversation_mute_fabricator.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
Fabricator(:conversation_mute) do
|
||||
end
|
5
spec/models/conversation_mute_spec.rb
Normal file
5
spec/models/conversation_mute_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ConversationMute, type: :model do
|
||||
|
||||
end
|
|
@ -196,6 +196,54 @@ RSpec.describe Status, type: :model do
|
|||
pending
|
||||
end
|
||||
|
||||
describe '.mutes_map' do
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
subject { Status.mutes_map([status.conversation.id], account) }
|
||||
|
||||
it 'returns a hash' do
|
||||
expect(subject).to be_a Hash
|
||||
end
|
||||
|
||||
it 'contains true value' do
|
||||
account.mute_conversation!(status.conversation)
|
||||
expect(subject[status.conversation.id]).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe '.favourites_map' do
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
subject { Status.favourites_map([status], account) }
|
||||
|
||||
it 'returns a hash' do
|
||||
expect(subject).to be_a Hash
|
||||
end
|
||||
|
||||
it 'contains true value' do
|
||||
Fabricate(:favourite, status: status, account: account)
|
||||
expect(subject[status.id]).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe '.reblogs_map' do
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:account) { Fabricate(:account) }
|
||||
|
||||
subject { Status.reblogs_map([status], account) }
|
||||
|
||||
it 'returns a hash' do
|
||||
expect(subject).to be_a Hash
|
||||
end
|
||||
|
||||
it 'contains true value' do
|
||||
Fabricate(:status, account: account, reblog: status)
|
||||
expect(subject[status.id]).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe '.local_only' do
|
||||
it 'returns only statuses from local accounts' do
|
||||
local_account = Fabricate(:account, domain: nil)
|
||||
|
|
|
@ -7,10 +7,50 @@ RSpec.describe NotifyService do
|
|||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:recipient) { user.account }
|
||||
let(:activity) { Fabricate(:follow, target_account: recipient) }
|
||||
let(:sender) { Fabricate(:account) }
|
||||
let(:activity) { Fabricate(:follow, account: sender, target_account: recipient) }
|
||||
|
||||
it { is_expected.to change(Notification, :count).by(1) }
|
||||
|
||||
it 'does not notify when sender is blocked' do
|
||||
recipient.block!(sender)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does not notify when sender is silenced and not followed' do
|
||||
sender.update(silenced: true)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does not notify when recipient is suspended' do
|
||||
recipient.update(suspended: true)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
context do
|
||||
let(:asshole) { Fabricate(:account, username: 'asshole') }
|
||||
let(:reply_to) { Fabricate(:status, account: asshole) }
|
||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, thread: reply_to)) }
|
||||
|
||||
it 'does not notify when conversation is muted' do
|
||||
recipient.mute_conversation!(activity.status.conversation)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
end
|
||||
|
||||
it 'does not notify when it is a reply to a blocked user' do
|
||||
recipient.block!(asshole)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
end
|
||||
end
|
||||
|
||||
context do
|
||||
let(:sender) { recipient }
|
||||
|
||||
it 'does not notify when recipient is the sender' do
|
||||
is_expected.to_not change(Notification, :count)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'email' do
|
||||
before do
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue