diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-12 19:09:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-12 19:09:21 +0200 |
commit | 5abdc77c8060a62ecf2259a1e9d63e862b9f7be7 (patch) | |
tree | 95b0a69d8943d6171ad19257af1655cd733fc245 /app/services | |
parent | b5a9c6b3d292abc7e47d8a6f830f6b5589c04862 (diff) |
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
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/process_feed_service.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index 1558f8790..afd44aafe 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -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') |