Skip to content
Extraits de code Groupes Projets
Valider cea98e0c rédigé par ThibG's avatar ThibG Validation de Eugen Rochko
Parcourir les fichiers

Reduce the number of synchronous resolves when posting toots (#6075)

parent 6eb60260
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -11,18 +11,20 @@ class ProcessMentionsService < BaseService ...@@ -11,18 +11,20 @@ class ProcessMentionsService < BaseService
return unless status.local? return unless status.local?
status.text = status.text.gsub(Account::MENTION_RE) do |match| status.text = status.text.gsub(Account::MENTION_RE) do |match|
begin username, domain = $1.split('@')
mentioned_account = resolve_remote_account_service.call($1) mentioned_account = Account.find_remote(username, domain)
rescue Goldfinger::Error, HTTP::Error
mentioned_account = nil
end
if mentioned_account.nil? if mention_undeliverable?(status, mentioned_account)
username, domain = $1.split('@') begin
mentioned_account = Account.find_remote(username, domain) mentioned_account = resolve_remote_account_service.call($1)
rescue Goldfinger::Error, HTTP::Error
mentioned_account = nil
end
end end
next match if mentioned_account.nil? || (!mentioned_account.local? && mentioned_account.ostatus? && status.stream_entry.hidden?) mentioned_account ||= Account.find_remote(username, domain)
next match if mention_undeliverable?(status, mentioned_account)
mentioned_account.mentions.where(status: status).first_or_create(status: status) mentioned_account.mentions.where(status: status).first_or_create(status: status)
"@#{mentioned_account.acct}" "@#{mentioned_account.acct}"
...@@ -37,6 +39,10 @@ class ProcessMentionsService < BaseService ...@@ -37,6 +39,10 @@ class ProcessMentionsService < BaseService
private private
def mention_undeliverable?(status, mentioned_account)
mentioned_account.nil? || (!mentioned_account.local? && mentioned_account.ostatus? && status.stream_entry.hidden?)
end
def create_notification(status, mention) def create_notification(status, mention)
mentioned_account = mention.account mentioned_account = mention.account
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter