Add conversation model, <ostatus:conversation /> (#3016)
* Add <ostatus:conversation /> tag to Atom input/output Only uses ref attribute (not href) because href would be the alternate link that's always included also. Creates new conversation for every non-reply status. Carries over conversation for every reply. Keeps remote URIs verbatim, generates local URIs on the fly like the rest of them. * Fix conversation migration * More spec coverage for status before_create * Prevent n+1 query when generating Atom with the new conversations * Improve code style * Remove redundant local variable
This commit is contained in:
parent
b5a9c6b3d2
commit
5abdc77c80
11 changed files with 144 additions and 10 deletions
|
@ -141,7 +141,8 @@ class ProcessFeedService < BaseService
|
|||
created_at: published(entry),
|
||||
reply: thread?(entry),
|
||||
language: content_language(entry),
|
||||
visibility: visibility_scope(entry)
|
||||
visibility: visibility_scope(entry),
|
||||
conversation: find_or_create_conversation(entry)
|
||||
)
|
||||
|
||||
if thread?(entry)
|
||||
|
@ -164,6 +165,18 @@ class ProcessFeedService < BaseService
|
|||
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?
|
||||
|
||||
if TagManager.instance.local_id?(uri)
|
||||
local_id = TagManager.instance.unique_tag_to_local_id(uri, 'Conversation')
|
||||
return Conversation.find_by(id: local_id)
|
||||
end
|
||||
|
||||
Conversation.find_by(uri: uri)
|
||||
end
|
||||
|
||||
def find_status(uri)
|
||||
if TagManager.instance.local_id?(uri)
|
||||
local_id = TagManager.instance.unique_tag_to_local_id(uri, 'Status')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue