From 564efd06515edc524a8a1cdf7a3d8a7d9a376c04 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 14 Feb 2022 21:27:53 +0100 Subject: Add appeals (#17364) * Add appeals * Add ability to reject appeals and ability to browse pending appeals in admin UI * Add strikes to account page in settings * Various fixes and improvements - Add separate notification setting for appeals, separate from reports - Fix style of links in report/strike header - Change approving an appeal to not restore statuses (due to federation complexities) - Change style of successfully appealed strikes on account settings page - Change account settings page to only show unappealed or recently appealed strikes * Change appealed_at to overruled_at * Fix missing method error --- app/controllers/admin/accounts_controller.rb | 4 +-- app/controllers/admin/dashboard_controller.rb | 1 + .../admin/disputes/appeals_controller.rb | 40 ++++++++++++++++++++++ app/controllers/auth/registrations_controller.rb | 11 ++++-- app/controllers/disputes/appeals_controller.rb | 25 ++++++++++++++ app/controllers/disputes/base_controller.rb | 18 ++++++++++ app/controllers/disputes/strikes_controller.rb | 17 +++++++++ 7 files changed, 112 insertions(+), 4 deletions(-) create mode 100644 app/controllers/admin/disputes/appeals_controller.rb create mode 100644 app/controllers/disputes/appeals_controller.rb create mode 100644 app/controllers/disputes/base_controller.rb create mode 100644 app/controllers/disputes/strikes_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb index e7f56e243..e0ae71b9f 100644 --- a/app/controllers/admin/accounts_controller.rb +++ b/app/controllers/admin/accounts_controller.rb @@ -28,7 +28,7 @@ module Admin @deletion_request = @account.deletion_request @account_moderation_note = current_account.account_moderation_notes.new(target_account: @account) @moderation_notes = @account.targeted_moderation_notes.latest - @warnings = @account.strikes.custom.latest + @warnings = @account.strikes.includes(:target_account, :account, :appeal).latest @domain_block = DomainBlock.rule_for(@account.domain) end @@ -146,7 +146,7 @@ module Admin end def filter_params - params.slice(*AccountFilter::KEYS).permit(*AccountFilter::KEYS) + params.slice(:page, *AccountFilter::KEYS).permit(:page, *AccountFilter::KEYS) end def form_account_batch_params diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index f0a935411..e376baab2 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -8,6 +8,7 @@ module Admin @pending_users_count = User.pending.count @pending_reports_count = Report.unresolved.count @pending_tags_count = Tag.pending_review.count + @pending_appeals_count = Appeal.pending.count end private diff --git a/app/controllers/admin/disputes/appeals_controller.rb b/app/controllers/admin/disputes/appeals_controller.rb new file mode 100644 index 000000000..32e5e2f6f --- /dev/null +++ b/app/controllers/admin/disputes/appeals_controller.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class Admin::Disputes::AppealsController < Admin::BaseController + before_action :set_appeal, except: :index + + def index + authorize :appeal, :index? + + @appeals = filtered_appeals.page(params[:page]) + end + + def approve + authorize @appeal, :approve? + log_action :approve, @appeal + ApproveAppealService.new.call(@appeal, current_account) + redirect_to disputes_strike_path(@appeal.strike) + end + + def reject + authorize @appeal, :approve? + log_action :reject, @appeal + @appeal.reject!(current_account) + UserMailer.appeal_rejected(@appeal.account.user, @appeal) + redirect_to disputes_strike_path(@appeal.strike) + end + + private + + def filtered_appeals + Admin::AppealFilter.new(filter_params.with_defaults(status: 'pending')).results.includes(strike: :account) + end + + def filter_params + params.slice(:page, *Admin::AppealFilter::KEYS).permit(:page, *Admin::AppealFilter::KEYS) + end + + def set_appeal + @appeal = Appeal.find(params[:id]) + end +end diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index f37e906fd..3b025838b 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -9,6 +9,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController before_action :check_enabled_registrations, only: [:new, :create] before_action :configure_sign_up_params, only: [:create] before_action :set_sessions, only: [:edit, :update] + before_action :set_strikes, only: [:edit, :update] before_action :set_instance_presenter, only: [:new, :create, :update] before_action :set_body_classes, only: [:new, :create, :edit, :update] before_action :require_not_suspended!, only: [:update] @@ -111,8 +112,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController end def set_invite - invite = invite_code.present? ? Invite.find_by(code: invite_code) : nil - @invite = invite&.valid_for_use? ? invite : nil + @invite = begin + invite = Invite.find_by(code: invite_code) if invite_code.present? + invite if invite&.valid_for_use? + end end def determine_layout @@ -123,6 +126,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController @sessions = current_user.session_activations end + def set_strikes + @strikes = current_account.strikes.active.latest + end + def require_not_suspended! forbidden if current_account.suspended? end diff --git a/app/controllers/disputes/appeals_controller.rb b/app/controllers/disputes/appeals_controller.rb new file mode 100644 index 000000000..15367c879 --- /dev/null +++ b/app/controllers/disputes/appeals_controller.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class Disputes::AppealsController < Disputes::BaseController + before_action :set_strike + + def create + authorize @strike, :appeal? + + @appeal = AppealService.new.call(@strike, appeal_params[:text]) + + redirect_to disputes_strike_path(@strike), notice: I18n.t('disputes.strikes.appealed_msg') + rescue ActiveRecord::RecordInvalid + render template: 'disputes/strikes/show' + end + + private + + def set_strike + @strike = current_account.strikes.find(params[:strike_id]) + end + + def appeal_params + params.require(:appeal).permit(:text) + end +end diff --git a/app/controllers/disputes/base_controller.rb b/app/controllers/disputes/base_controller.rb new file mode 100644 index 000000000..865146b5c --- /dev/null +++ b/app/controllers/disputes/base_controller.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class Disputes::BaseController < ApplicationController + include Authorization + + layout 'admin' + + skip_before_action :require_functional! + + before_action :set_body_classes + before_action :authenticate_user! + + private + + def set_body_classes + @body_classes = 'admin' + end +end diff --git a/app/controllers/disputes/strikes_controller.rb b/app/controllers/disputes/strikes_controller.rb new file mode 100644 index 000000000..d41c5c727 --- /dev/null +++ b/app/controllers/disputes/strikes_controller.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class Disputes::StrikesController < Disputes::BaseController + before_action :set_strike + + def show + authorize @strike, :show? + + @appeal = @strike.appeal || @strike.build_appeal + end + + private + + def set_strike + @strike = AccountWarning.find(params[:id]) + end +end -- cgit From ac99f586bb4138e083676579097d951434e90515 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 16 Feb 2022 22:29:48 +0100 Subject: Fix issues when attempting to appeal an old strike (#17554) * Display an error when an appeal could not be submitted * Do not offer users to appeal old strikes * Fix 500 error when trying to appeal a strike that is too old * Avoid using an extra translatable string --- app/controllers/disputes/appeals_controller.rb | 3 ++- app/models/appeal.rb | 4 +++- app/policies/account_warning_policy.rb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/disputes/appeals_controller.rb b/app/controllers/disputes/appeals_controller.rb index 15367c879..eefd92b5a 100644 --- a/app/controllers/disputes/appeals_controller.rb +++ b/app/controllers/disputes/appeals_controller.rb @@ -9,7 +9,8 @@ class Disputes::AppealsController < Disputes::BaseController @appeal = AppealService.new.call(@strike, appeal_params[:text]) redirect_to disputes_strike_path(@strike), notice: I18n.t('disputes.strikes.appealed_msg') - rescue ActiveRecord::RecordInvalid + rescue ActiveRecord::RecordInvalid => e + @appeal = e.record render template: 'disputes/strikes/show' end diff --git a/app/models/appeal.rb b/app/models/appeal.rb index 46f35ae37..1f32cfa8b 100644 --- a/app/models/appeal.rb +++ b/app/models/appeal.rb @@ -16,6 +16,8 @@ # updated_at :datetime not null # class Appeal < ApplicationRecord + MAX_STRIKE_AGE = 20.days + belongs_to :account belongs_to :strike, class_name: 'AccountWarning', foreign_key: 'account_warning_id' belongs_to :approved_by_account, class_name: 'Account', optional: true @@ -53,6 +55,6 @@ class Appeal < ApplicationRecord private def validate_time_frame - errors.add(:base, I18n.t('strikes.errors.too_late')) if Time.now.utc > (strike.created_at + 20.days) + errors.add(:base, I18n.t('strikes.errors.too_late')) if strike.created_at < MAX_STRIKE_AGE.ago end end diff --git a/app/policies/account_warning_policy.rb b/app/policies/account_warning_policy.rb index 6b92da475..65707dfa7 100644 --- a/app/policies/account_warning_policy.rb +++ b/app/policies/account_warning_policy.rb @@ -6,7 +6,7 @@ class AccountWarningPolicy < ApplicationPolicy end def appeal? - target? + target? && record.created_at >= Appeal::MAX_STRIKE_AGE.ago end private -- cgit From 41d52ee4b5d72b3f63bf05b61bfb08b4ea270042 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 14 Feb 2022 21:54:01 +0100 Subject: Fix issue with glitch-soc's theming system --- app/controllers/disputes/base_controller.rb | 5 +++++ app/views/admin/disputes/appeals/index.html.haml | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/disputes/base_controller.rb b/app/controllers/disputes/base_controller.rb index 865146b5c..7830c5524 100644 --- a/app/controllers/disputes/base_controller.rb +++ b/app/controllers/disputes/base_controller.rb @@ -9,9 +9,14 @@ class Disputes::BaseController < ApplicationController before_action :set_body_classes before_action :authenticate_user! + before_action :set_pack private + def set_pack + use_pack 'admin' + end + def set_body_classes @body_classes = 'admin' end diff --git a/app/views/admin/disputes/appeals/index.html.haml b/app/views/admin/disputes/appeals/index.html.haml index dd6a6f403..42e9c4b1d 100644 --- a/app/views/admin/disputes/appeals/index.html.haml +++ b/app/views/admin/disputes/appeals/index.html.haml @@ -1,9 +1,6 @@ - content_for :page_title do = t('admin.disputes.appeals.title') -- content_for :header_tags do - = javascript_pack_tag 'admin', async: true, crossorigin: 'anonymous' - .filters .filter-subset %strong= t('admin.tags.review') -- cgit From de448ab1b5c2aa3f6a631ca9666a1fa0e447ccdd Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 19 Feb 2022 03:12:28 +0100 Subject: Change global `locale` param to `lang` to avoid conflicts (#17592) --- app/controllers/concerns/localized.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/concerns/localized.rb b/app/controllers/concerns/localized.rb index f7b62f09c..173316800 100644 --- a/app/controllers/concerns/localized.rb +++ b/app/controllers/concerns/localized.rb @@ -14,7 +14,7 @@ module Localized private def requested_locale - requested_locale_name = available_locale_or_nil(params[:locale]) + requested_locale_name = available_locale_or_nil(params[:lang]) requested_locale_name ||= available_locale_or_nil(current_user.locale) if respond_to?(:user_signed_in?) && user_signed_in? requested_locale_name ||= http_accept_language if ENV['DEFAULT_LOCALE'].blank? requested_locale_name -- cgit From 2e89067d216d5044ada14ad7a8919b686dfa0839 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 19 Feb 2022 13:30:06 +0900 Subject: Bump pundit from 2.1.1 to 2.2.0 (#17543) * Bump pundit from 2.1.1 to 2.2.0 Bumps [pundit](https://github.com/varvet/pundit) from 2.1.1 to 2.2.0. - [Release notes](https://github.com/varvet/pundit/releases) - [Changelog](https://github.com/varvet/pundit/blob/main/CHANGELOG.md) - [Commits](https://github.com/varvet/pundit/compare/v2.1.1...v2.2.0) --- updated-dependencies: - dependency-name: pundit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * `include Pundit` is deprecated Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yamagishi Kazutoshi --- Gemfile | 2 +- Gemfile.lock | 4 ++-- app/controllers/concerns/authorization.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'app/controllers') diff --git a/Gemfile b/Gemfile index 5ade2e8c4..1a3df276e 100644 --- a/Gemfile +++ b/Gemfile @@ -65,7 +65,7 @@ gem 'oj', '~> 3.13' gem 'ox', '~> 2.14' gem 'parslet' gem 'posix-spawn' -gem 'pundit', '~> 2.1' +gem 'pundit', '~> 2.2' gem 'premailer-rails' gem 'rack-attack', '~> 6.5' gem 'rack-cors', '~> 1.1', require: 'rack/cors' diff --git a/Gemfile.lock b/Gemfile.lock index 37d101be5..2ad52feb0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -440,7 +440,7 @@ GEM public_suffix (4.0.6) puma (5.6.2) nio4r (~> 2.0) - pundit (2.1.1) + pundit (2.2.0) activesupport (>= 3.0.0) raabro (1.4.0) racc (1.6.0) @@ -757,7 +757,7 @@ DEPENDENCIES pry-byebug (~> 3.9) pry-rails (~> 0.3) puma (~> 5.6) - pundit (~> 2.1) + pundit (~> 2.2) rack (~> 2.2.3) rack-attack (~> 6.5) rack-cors (~> 1.1) diff --git a/app/controllers/concerns/authorization.rb b/app/controllers/concerns/authorization.rb index 95a37e379..05260cc8b 100644 --- a/app/controllers/concerns/authorization.rb +++ b/app/controllers/concerns/authorization.rb @@ -3,7 +3,7 @@ module Authorization extend ActiveSupport::Concern - include Pundit + include Pundit::Authorization def pundit_user current_account -- cgit From 7b816eb5aeeed61fa1e3a7c95cbb5bb7978f7fa5 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 23 Feb 2022 16:45:22 +0100 Subject: Add notifications for new sign-ups (#16953) --- .../api/web/push_subscriptions_controller.rb | 23 ++---------- app/javascript/mastodon/actions/notifications.js | 3 +- .../notifications/components/column_settings.js | 16 ++++++++- .../notifications/components/notification.js | 25 +++++++++++++ app/javascript/mastodon/reducers/settings.js | 3 ++ .../mastodon/service_worker/web_push_locales.js | 1 + app/models/notification.rb | 14 ++++---- app/services/bootstrap_timeline_service.rb | 7 ++++ app/services/notify_service.rb | 42 ++++------------------ config/i18n-tasks.yml | 1 + config/locales/en.yml | 3 ++ 11 files changed, 73 insertions(+), 65 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/api/web/push_subscriptions_controller.rb b/app/controllers/api/web/push_subscriptions_controller.rb index db2512e5f..5167928e9 100644 --- a/app/controllers/api/web/push_subscriptions_controller.rb +++ b/app/controllers/api/web/push_subscriptions_controller.rb @@ -17,17 +17,7 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController data = { policy: 'all', - - alerts: { - follow: alerts_enabled, - follow_request: alerts_enabled, - favourite: alerts_enabled, - reblog: alerts_enabled, - mention: alerts_enabled, - poll: alerts_enabled, - status: alerts_enabled, - update: alerts_enabled, - }, + alerts: Notification::TYPES.index_with { alerts_enabled }, } data.deep_merge!(data_params) if params[:data] @@ -62,15 +52,6 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController end def data_params - @data_params ||= params.require(:data).permit(:policy, alerts: [ - :follow, - :follow_request, - :favourite, - :reblog, - :mention, - :poll, - :status, - :update, - ]) + @data_params ||= params.require(:data).permit(:policy, alerts: Notification::TYPES) end end diff --git a/app/javascript/mastodon/actions/notifications.js b/app/javascript/mastodon/actions/notifications.js index 9370811e0..00e8d74d7 100644 --- a/app/javascript/mastodon/actions/notifications.js +++ b/app/javascript/mastodon/actions/notifications.js @@ -45,7 +45,7 @@ defineMessages({ }); const fetchRelatedRelationships = (dispatch, notifications) => { - const accountIds = notifications.filter(item => item.type === 'follow').map(item => item.account.id); + const accountIds = notifications.filter(item => ['follow', 'follow_request', 'admin.sign_up'].indexOf(item.type) !== -1).map(item => item.account.id); if (accountIds.length > 0) { dispatch(fetchRelationships(accountIds)); @@ -132,6 +132,7 @@ const excludeTypesFromFilter = filter => { 'poll', 'status', 'update', + 'admin.sign_up', ]); return allTypes.filterNot(item => item === filter).toJS(); diff --git a/app/javascript/mastodon/features/notifications/components/column_settings.js b/app/javascript/mastodon/features/notifications/components/column_settings.js index ada8b6e4a..84db04430 100644 --- a/app/javascript/mastodon/features/notifications/components/column_settings.js +++ b/app/javascript/mastodon/features/notifications/components/column_settings.js @@ -5,6 +5,7 @@ import { FormattedMessage } from 'react-intl'; import ClearColumnButton from './clear_column_button'; import GrantPermissionButton from './grant_permission_button'; import SettingToggle from './setting_toggle'; +import { isStaff } from 'mastodon/initial_state'; export default class ColumnSettings extends React.PureComponent { @@ -155,7 +156,7 @@ export default class ColumnSettings extends React.PureComponent {
- +
@@ -164,6 +165,19 @@ export default class ColumnSettings extends React.PureComponent {
+ + {isStaff && ( +
+ + +
+ + {showPushSettings && } + + +
+
+ )} ); } diff --git a/app/javascript/mastodon/features/notifications/components/notification.js b/app/javascript/mastodon/features/notifications/components/notification.js index cd471852b..9198e9c9d 100644 --- a/app/javascript/mastodon/features/notifications/components/notification.js +++ b/app/javascript/mastodon/features/notifications/components/notification.js @@ -20,6 +20,7 @@ const messages = defineMessages({ reblog: { id: 'notification.reblog', defaultMessage: '{name} boosted your status' }, status: { id: 'notification.status', defaultMessage: '{name} just posted' }, update: { id: 'notification.update', defaultMessage: '{name} edited a post' }, + adminSignUp: { id: 'notification.admin.sign_up', defaultMessage: '{name} signed up' }, }); const notificationForScreenReader = (intl, message, timestamp) => { @@ -344,6 +345,28 @@ class Notification extends ImmutablePureComponent { ); } + renderAdminSignUp (notification, account, link) { + const { intl, unread } = this.props; + + return ( + +
+
+
+ +
+ + + + +
+ +
+
+ ); + } + render () { const { notification } = this.props; const account = notification.get('account'); @@ -367,6 +390,8 @@ class Notification extends ImmutablePureComponent { return this.renderUpdate(notification, link); case 'poll': return this.renderPoll(notification, account); + case 'admin.sign_up': + return this.renderAdminSignUp(notification, account, link); } return null; diff --git a/app/javascript/mastodon/reducers/settings.js b/app/javascript/mastodon/reducers/settings.js index 5146abe98..39639f3dc 100644 --- a/app/javascript/mastodon/reducers/settings.js +++ b/app/javascript/mastodon/reducers/settings.js @@ -37,6 +37,7 @@ const initialState = ImmutableMap({ poll: false, status: false, update: false, + 'admin.sign_up': false, }), quickFilter: ImmutableMap({ @@ -57,6 +58,7 @@ const initialState = ImmutableMap({ poll: true, status: true, update: true, + 'admin.sign_up': true, }), sounds: ImmutableMap({ @@ -68,6 +70,7 @@ const initialState = ImmutableMap({ poll: true, status: true, update: true, + 'admin.sign_up': true, }), }), diff --git a/app/javascript/mastodon/service_worker/web_push_locales.js b/app/javascript/mastodon/service_worker/web_push_locales.js index 807a1bcb9..7d713cd37 100644 --- a/app/javascript/mastodon/service_worker/web_push_locales.js +++ b/app/javascript/mastodon/service_worker/web_push_locales.js @@ -22,6 +22,7 @@ filenames.forEach(filename => { 'notification.poll': full['notification.poll'] || '', 'notification.status': full['notification.status'] || '', 'notification.update': full['notification.update'] || '', + 'notification.admin.sign_up': full['notification.admin.sign_up'] || '', 'status.show_more': full['status.show_more'] || '', 'status.reblog': full['status.reblog'] || '', diff --git a/app/models/notification.rb b/app/models/notification.rb index c14eb8a7e..9bf296386 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -36,6 +36,7 @@ class Notification < ApplicationRecord favourite poll update + admin.sign_up ).freeze TARGET_STATUS_INCLUDES_BY_TYPE = { @@ -63,13 +64,10 @@ class Notification < ApplicationRecord scope :without_suspended, -> { joins(:from_account).merge(Account.without_suspended) } scope :browserable, ->(exclude_types = [], account_id = nil) { - types = TYPES - exclude_types.map(&:to_sym) - - if account_id.nil? - where(type: types) - else - where(type: types, from_account_id: account_id) - end + scope = all + scope = where(from_account_id: account_id) if account_id.present? + scope = scope.where(type: TYPES - exclude_types.map(&:to_sym)) unless exclude_types.empty? + scope } def type @@ -142,6 +140,8 @@ class Notification < ApplicationRecord self.from_account_id = activity&.account_id when 'Mention' self.from_account_id = activity&.status&.account_id + when 'Account' + self.from_account_id = activity&.id end end end diff --git a/app/services/bootstrap_timeline_service.rb b/app/services/bootstrap_timeline_service.rb index e1a1b98c3..70e7cc570 100644 --- a/app/services/bootstrap_timeline_service.rb +++ b/app/services/bootstrap_timeline_service.rb @@ -5,6 +5,7 @@ class BootstrapTimelineService < BaseService @source_account = source_account autofollow_inviter! + notify_staff! end private @@ -14,4 +15,10 @@ class BootstrapTimelineService < BaseService FollowService.new.call(@source_account, @source_account.user.invite.user.account) end + + def notify_staff! + User.staff.includes(:account).find_each do |user| + NotifyService.new.call(user.account, :'admin.new_user', @source_account) + end + end end diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index ab80a7e4b..b1f9fd755 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -22,34 +22,6 @@ class NotifyService < BaseService FeedManager.instance.filter?(:mentions, @notification.mention.status, @recipient) end - def blocked_status? - false - end - - def blocked_favourite? - false - end - - def blocked_follow? - false - end - - def blocked_reblog? - false - end - - def blocked_follow_request? - false - end - - def blocked_poll? - false - end - - def blocked_update? - false - end - def following_sender? return @following_sender if defined?(@following_sender) @following_sender = @recipient.following?(@notification.from_account) || @recipient.requested?(@notification.from_account) @@ -149,15 +121,15 @@ class NotifyService < BaseService return blocked if message? && from_staff? - blocked ||= domain_blocking? # Skip for domain blocked accounts - blocked ||= @recipient.blocking?(@notification.from_account) # Skip for blocked accounts + blocked ||= domain_blocking? + blocked ||= @recipient.blocking?(@notification.from_account) blocked ||= @recipient.muting_notifications?(@notification.from_account) - blocked ||= hellbanned? # Hellban - blocked ||= optional_non_follower? # Options - blocked ||= optional_non_following? # Options - blocked ||= optional_non_following_and_direct? # Options + blocked ||= hellbanned? + blocked ||= optional_non_follower? + blocked ||= optional_non_following? + blocked ||= optional_non_following_and_direct? blocked ||= conversation_muted? - blocked ||= send("blocked_#{@notification.type}?") # Type-dependent filters + blocked ||= blocked_mention? if @notification.type == :mention blocked end diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 2dc6f880b..7f879b1aa 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -61,6 +61,7 @@ ignore_unused: - 'admin.action_logs.actions.*' - 'statuses.attached.*' - 'move_handler.carry_{mutes,blocks}_over_text' + - 'notification_mailer.*' ignore_inconsistent_interpolations: - '*.one' diff --git a/config/locales/en.yml b/config/locales/en.yml index cf4c2cc37..c206c893b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1176,6 +1176,9 @@ en: carry_mutes_over_text: This user moved from %{acct}, which you had muted. copy_account_note_text: 'This user moved from %{acct}, here were your previous notes about them:' notification_mailer: + admin: + sign_up: + subject: "%{name} signed up" digest: action: View all notifications body: Here is a brief summary of the messages you missed since your last visit on %{since} -- cgit