Skip to content

Commit

Permalink
mention OP when quoting
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakers-the-rat committed Jul 28, 2024
1 parent 9c6e0d4 commit d8fcac6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/services/process_mentions_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def call(status, save_records: true)

Status.transaction do
scan_text!
identify_quote!
assign_mentions!
end
end
Expand Down Expand Up @@ -65,6 +66,25 @@ def scan_text!
@status.save! if @save_records
end

def identify_quote!
if @status.quote_id?
# There's got to be a better way to get an account from a status id...
quoted_status = Status.find(@status.quote_id)
mentioned_account = Account.find(quoted_status.account_id)

# mimic the tail of scan_text since we're not sure what is relevant there
return if mention_undeliverable?(mentioned_account) || mentioned_account&.unavailable?

mention = @previous_mentions.find { |x| x.account_id == mentioned_account.id }
mention ||= @current_mentions.find { |x| x.account_id == mentioned_account.id }
mention ||= @status.mentions.new(account: mentioned_account)

@current_mentions << mention

"@#{mentioned_account.acct}"
end
end

def assign_mentions!
# Make sure we never mention blocked accounts
unless @current_mentions.empty?
Expand Down

0 comments on commit d8fcac6

Please sign in to comment.