Allow users to restrict incoming DMs to follows only
parent
8a49ff584a
commit
accb9314b3
|
@ -43,7 +43,7 @@ class Settings::PreferencesController < Settings::BaseController
|
|||
:setting_noindex,
|
||||
:setting_hide_network,
|
||||
notification_emails: %i(follow follow_request reblog favourite mention digest),
|
||||
interactions: %i(must_be_follower must_be_following)
|
||||
interactions: %i(must_be_follower must_be_following must_be_following_dm)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,15 @@ class NotifyService < BaseService
|
|||
|
||||
private
|
||||
|
||||
def visibility
|
||||
return @visibility if defined?(@visibility)
|
||||
unless @activity.is_a?(Follow) || @activity.is_a?(FollowRequest)
|
||||
status = @activity.is_a?(Status) ? @activity : @activity.status
|
||||
@visibility = status.visibility
|
||||
end
|
||||
@visibility
|
||||
end
|
||||
|
||||
def blocked_mention?
|
||||
FeedManager.instance.filter?(:mentions, @notification.mention.status, @recipient.id)
|
||||
end
|
||||
|
|
|
@ -178,4 +178,15 @@ RSpec.describe NotifyService, type: :service do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context do
|
||||
let(:asshole) { Fabricate(:account, username: 'asshole') }
|
||||
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct)) }
|
||||
|
||||
it 'does not notify when direct messages from non-followed user are muted' do
|
||||
interactions = user.settings.interactions
|
||||
user.settings.interactions = interactions.merge('must_be_following_dm' => true)
|
||||
is_expected.to_not change(Notification, :count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue