From 67b6af0f8bdbcbc8e0c244e418305189d32f6426 Mon Sep 17 00:00:00 2001 From: noellabo Date: Sat, 17 Feb 2024 01:30:25 +0900 Subject: [PATCH] Fix style --- app/lib/activitypub/activity/create.rb | 8 ++++---- app/validators/regexp_syntax_validator.rb | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index bfb3ce7e8b..b9f78feb14 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -46,10 +46,6 @@ class ActivityPub::Activity::Create < ActivityPub::Activity ) end - def reject_pattern? - Setting.reject_pattern.present? && @object['content']&.match?(Setting.reject_pattern) - end - def create_status return reject_payload! if unsupported_object_type? || non_matching_uri_hosts?(@account.uri, object_uri) || tombstone_exists? || !related_to_local_activity? || reject_pattern? @@ -417,6 +413,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity Tombstone.exists?(uri: object_uri) end + def reject_pattern? + Setting.reject_pattern.present? && @object['content']&.match?(Setting.reject_pattern) + end + def forward_for_reply return unless @status.distributable? && @json['signature'].present? && reply_to_local? diff --git a/app/validators/regexp_syntax_validator.rb b/app/validators/regexp_syntax_validator.rb index 57ecf882c2..dd8dc80c9f 100644 --- a/app/validators/regexp_syntax_validator.rb +++ b/app/validators/regexp_syntax_validator.rb @@ -4,10 +4,8 @@ class RegexpSyntaxValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) return if value.blank? - begin - Regexp.compile(value) - rescue RegexpError => e - record.errors.add(attribute, I18n.t('applications.invalid_regexp', message: e.message)) - end + Regexp.compile(value) + rescue RegexpError => e + record.errors.add(attribute, I18n.t('applications.invalid_regexp', message: e.message)) end end