Allow users to mute all notifications from accounts < 1 day old

master
Crom 2017-11-14 01:33:31 +00:00 committed by Noiob
parent 931ca7d508
commit 31d1bb4c7c
7 changed files with 14 additions and 2 deletions

View File

@ -22,7 +22,7 @@ class Settings::NotificationsController < Settings::BaseController
def user_settings_params
params.require(:user).permit(
notification_emails: %i(follow follow_request reblog favourite mention digest),
interactions: %i(must_be_follower must_be_following must_be_following_dm)
interactions: %i(must_be_follower must_be_following must_be_following_dm must_be_one_day_old)
)
end
end

View File

@ -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 must_be_following_dm)
interactions: %i(must_be_follower must_be_following must_be_following_dm must_be_one_day_old)
)
end
end

View File

@ -74,6 +74,13 @@ class NotifyService < BaseService
!response_to_recipient?
end
def optional_non_following_and_too_young?
@recipient.user.settings.interactions['must_be_one_day_old'] &&
Time.now - @notification.from_account.created_at < 1.days &&
!following_sender? &&
!response_to_recipient?
end
def hellbanned?
@notification.from_account.silenced? && !following_sender?
end
@ -96,6 +103,7 @@ class NotifyService < BaseService
blocked ||= optional_non_follower? # Options
blocked ||= optional_non_following? # Options
blocked ||= optional_non_following_and_direct? # Options
blocked ||= optional_non_following_and_too_young? # Options
blocked ||= conversation_muted?
blocked ||= send("blocked_#{@notification.type}?") # Type-dependent filters
blocked

View File

@ -21,6 +21,7 @@
= ff.input :must_be_follower, as: :boolean, wrapper: :with_label
= ff.input :must_be_following, as: :boolean, wrapper: :with_label
= ff.input :must_be_following_dm, as: :boolean, wrapper: :with_label
= ff.input :must_be_one_day_old, as: :boolean, wrapper: :with_label
.actions
= f.button :button, t('generic.save_changes'), type: :submit

View File

@ -45,6 +45,7 @@ awoo:
must_be_follower: Block notifications from non-followers
must_be_following: Block notifications from people you don't follow
must_be_following_dm: Block only Direct Messages from people you don't follow
must_be_one_day_old: Block all notifications from people less than one day old
notification_emails:
digest: Send digest e-mails
favourite: Send e-mail when someone favourites your status

View File

@ -86,6 +86,7 @@ en:
must_be_follower: Block notifications from non-followers
must_be_following: Block notifications from people you don't follow
must_be_following_dm: Block direct messages from people you don't follow
must_be_one_day_old: Block all notifications from people less than one day old
notification_emails:
digest: Send digest e-mails
favourite: Send e-mail when someone favourites your status

View File

@ -45,6 +45,7 @@ defaults: &defaults
must_be_follower: false
must_be_following: false
must_be_following_dm: false
must_be_one_day_old: false
reserved_usernames:
- admin
- support