Skip to content

Commit

Permalink
Add reject blurhash to Admin setting
Browse files Browse the repository at this point in the history
  • Loading branch information
noellabo committed Jun 1, 2024
1 parent a2bd71d commit 5e4c390
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/lib/activitypub/activity/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def perform
else
create_status
end
rescue Mastodon::RejectPayload
reject_payload!
end

private
Expand Down Expand Up @@ -79,6 +81,9 @@ def process_status
@params = {}

process_status_params

raise Mastodon::RejectPayload if MediaAttachment.where(id: @params[:media_attachment_ids]).where(blurhash: Setting.reject_blurhash.split(/\r\n/).filter(&:present?).uniq).present?

Check failure on line 85 in app/lib/activitypub/activity/create.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Performance/RedundantSplitRegexpArgument: Use string as argument instead of regexp.

Check failure on line 85 in app/lib/activitypub/activity/create.rb

View workflow job for this annotation

GitHub Actions / lint

[Correctable] Style/RedundantRegexpArgument: Use string "\r\n" as argument instead of regexp /\r\n/.

process_tags
process_audience

Expand Down
1 change: 1 addition & 0 deletions app/models/form/admin_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Form::AdminSettings
app_icon
favicon
reject_pattern
reject_blurhash
).freeze

INTEGER_KEYS = %i(
Expand Down
3 changes: 3 additions & 0 deletions app/views/admin/settings/others/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
.fields-group
= f.input :reject_pattern, wrapper: :with_block_label, as: :text, label: t('admin.settings.reject_pattern.title'), hint: t('admin.settings.reject_pattern.desc_html'), input_html: { rows: 8 }

.fields-group
= f.input :reject_blurhash, wrapper: :with_block_label, as: :text, label: t('admin.settings.reject_blurhash.title'), hint: t('admin.settings.reject_blurhash.desc_html'), input_html: { rows: 8 }

.actions
= f.button :button, t('generic.save_changes'), type: :submit
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,9 @@ en:
none: Nobody can sign up
open: Anyone can sign up
warning_hint: We recommend using “Approval required for sign up” unless you are confident your moderation team can handle spam and malicious registrations in a timely fashion.
reject_blurhash:
desc_html: Set a blurhashes to inspect Create Activity media attachments, and refuse Activity if you match
title: Reject blurhash
reject_pattern:
desc_html: Set a regular expression pattern to inspect Create Activity content, and refuse Activity if you match
title: Reject Pattern
Expand Down
6 changes: 6 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,12 @@ ja:
none: 誰にも許可しない
open: 誰でも登録可
warning_hint: モデレーションチームがスパムや悪意のある登録を迅速に処理できる自信がない限り、サインアップを承認制にすることをお勧めします。
reject_blurhash:
desc_html: Create Activityの添付画像を検査するblurhashを設定し、一致する場合はActivityを拒否します
title: 拒否画像ハッシュ
reject_pattern:
desc_html: Create Activityのcontentを検査する正規表現パターンを設定し、一致する場合はActivityを拒否します
title: 拒否パターン
security:
authorized_fetch: 連合サーバーによる署名なしでの情報取得を拒否する
authorized_fetch_hint: ほかの連合サーバーから受け付けるリクエストに署名を必須にすることで、ユーザーによるブロックおよびドメインブロック両方の効果をより強力にします。ただし連合の処理コストが増えてパフォーマンス面で不利になるほか、このサーバーから送られた反応が届く範囲が狭まったり、連合における互換性の問題を招く可能性もあります。また、この機能は公開投稿やプロフィールへのアクセスをブロックした相手から完全に遮断できるものではありません。
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ defaults: &defaults
backups_retention_period: 7
captcha_enabled: false
reject_pattern: ''
reject_blurhash: ''

development:
<<: *defaults
Expand Down
1 change: 1 addition & 0 deletions lib/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class HostValidationError < ValidationError; end
class LengthValidationError < ValidationError; end
class DimensionsValidationError < ValidationError; end
class StreamValidationError < ValidationError; end
class RejectPayload < ValidationError; end
class RaceConditionError < Error; end
class RateLimitExceededError < Error; end
class SyntaxError < Error; end
Expand Down

0 comments on commit 5e4c390

Please sign in to comment.