diff --git a/app/controllers/settings/notifications_controller.rb b/app/controllers/settings/notifications_controller.rb index 6286e3ebf..d272288f4 100644 --- a/app/controllers/settings/notifications_controller.rb +++ b/app/controllers/settings/notifications_controller.rb @@ -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 diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 006d6e0b7..8c0174124 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -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 diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index f410bc5b6..76d6d0de7 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -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 diff --git a/app/views/settings/notifications/show.html.haml b/app/views/settings/notifications/show.html.haml index b718b62df..d18052a51 100644 --- a/app/views/settings/notifications/show.html.haml +++ b/app/views/settings/notifications/show.html.haml @@ -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 diff --git a/config/locales/simple_form.awoo.yml b/config/locales/simple_form.awoo.yml index 17aaf2577..e98299aab 100644 --- a/config/locales/simple_form.awoo.yml +++ b/config/locales/simple_form.awoo.yml @@ -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 diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 2f0e40f66..75ddbafa1 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -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 diff --git a/config/settings.yml b/config/settings.yml index 0546f90d2..c53a2e6b2 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -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