* Fix: #162 フォローしていないアカウントへのメンションのNGワードが編集で有効にならない問題 * Fix: 他のサーバーから来た編集についても適用
This commit is contained in:
parent
5497e2ae5d
commit
4f37ede886
6 changed files with 315 additions and 9 deletions
|
@ -5,6 +5,8 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||
include Redisable
|
||||
include Lockable
|
||||
|
||||
class AbortError < ::StandardError; end
|
||||
|
||||
def call(status, activity_json, object_json, request_id: nil)
|
||||
raise ArgumentError, 'Status has unsaved changes' if status.changed?
|
||||
|
||||
|
@ -30,6 +32,9 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||
handle_implicit_update!
|
||||
end
|
||||
|
||||
@status
|
||||
rescue AbortError
|
||||
@status.reload
|
||||
@status
|
||||
end
|
||||
|
||||
|
@ -46,6 +51,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||
update_poll!
|
||||
update_immediate_attributes!
|
||||
update_metadata!
|
||||
validate_status_mentions!
|
||||
create_edits!
|
||||
end
|
||||
|
||||
|
@ -160,6 +166,15 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||
!Admin::NgWord.reject?("#{@status_parser.spoiler_text}\n#{@status_parser.text}") && !Admin::NgWord.hashtag_reject?(@raw_tags.size)
|
||||
end
|
||||
|
||||
def validate_status_mentions!
|
||||
raise AbortError if mention_to_stranger? && Admin::NgWord.stranger_mention_reject?("#{@status.spoiler_text}\n#{@status.text}")
|
||||
end
|
||||
|
||||
def mention_to_stranger?
|
||||
@status.mentions.map(&:account).to_a.any? { |mentioned_account| mentioned_account.id != @status.account.id && !mentioned_account.following?(@status.account) } ||
|
||||
(@status.thread.present? && @status.thread.account.id != @status.account.id && !@status.thread.account.following?(@status.account))
|
||||
end
|
||||
|
||||
def update_immediate_attributes!
|
||||
@status.text = @status_parser.text || ''
|
||||
@status.spoiler_text = @status_parser.spoiler_text || ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue