mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
Try fixing ThreadResolveWorker calls (#3599)
* Try fixing ThreadResolveWorker calls From my understanding of ActiveRecord, a transaction is commited as soon as the exit of the outmost ActiveRecord.transaction block. However, inner transaction blocks will exit without the transaction being commited. In this case, ThreadResolveWorker were fired *within* a transaction block, so moving the call out of it should do the trick. However, this is somewhat fragile, as this whole codepath could be called within yet another transaction. * Set status thread within the transaction block if it is immediately available from database
This commit is contained in:
parent
e859d6f259
commit
7adac1bc51
@ -69,9 +69,16 @@ class ProcessFeedService < BaseService
|
||||
end
|
||||
end
|
||||
|
||||
status.thread = find_status(thread(@xml).first) if thread?(@xml)
|
||||
|
||||
status.save!
|
||||
end
|
||||
|
||||
if thread?(@xml) && status.thread.nil?
|
||||
Rails.logger.debug "Trying to attach #{status.id} (#{id(@xml)}) to #{thread(@xml).first}"
|
||||
ThreadResolveWorker.perform_async(status.id, thread(@xml).second)
|
||||
end
|
||||
|
||||
notify_about_mentions!(status) unless status.reblog?
|
||||
notify_about_reblog!(status) if status.reblog? && status.reblog.account.local?
|
||||
|
||||
@ -154,11 +161,6 @@ class ProcessFeedService < BaseService
|
||||
conversation: find_or_create_conversation(entry)
|
||||
)
|
||||
|
||||
if thread?(entry)
|
||||
Rails.logger.debug "Trying to attach #{status.id} (#{id(entry)}) to #{thread(entry).first}"
|
||||
status.thread = find_or_resolve_status(status, *thread(entry))
|
||||
end
|
||||
|
||||
mentions_from_xml(status, entry)
|
||||
hashtags_from_xml(status, entry)
|
||||
media_from_xml(status, entry)
|
||||
@ -166,14 +168,6 @@ class ProcessFeedService < BaseService
|
||||
[status, true]
|
||||
end
|
||||
|
||||
def find_or_resolve_status(parent, uri, url)
|
||||
status = find_status(uri)
|
||||
|
||||
ThreadResolveWorker.perform_async(parent.id, url) if status.nil?
|
||||
|
||||
status
|
||||
end
|
||||
|
||||
def find_or_create_conversation(xml)
|
||||
uri = xml.at_xpath('./ostatus:conversation', ostatus: TagManager::OS_XMLNS)&.attribute('ref')&.content
|
||||
return if uri.nil?
|
||||
|
Loading…
Reference in New Issue
Block a user