]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Use remote conversation URI info to stitch convos together
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 27 Nov 2014 13:06:10 +0000 (14:06 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 27 Nov 2014 13:06:10 +0000 (14:06 +0100)
If we know the URI sent from the remote party, and we don't know the
notice it is replying to, we might still be able to put it in the same
conversation thread!

classes/Notice.php
plugins/OStatus/classes/Ostatus_profile.php

index fd3a98f1f790f031d9188128a568114b9f617d19..0074a37bdf4c338546c4a04be7569666c92a0390 100644 (file)
@@ -417,8 +417,9 @@ class Notice extends Managed_DataObject
     static function saveNew($profile_id, $content, $source, array $options=null) {
         $defaults = array('uri' => null,
                           'url' => null,
-                          'reply_to' => null,
-                          'repeat_of' => null,
+                          'conversation' => null,   // URI of conversation
+                          'reply_to' => null,       // This will override convo URI if the parent is known
+                          'repeat_of' => null,      // This will override convo URI if the repeated notice is known
                           'scope' => null,
                           'distribute' => true,
                           'object_type' => null,
@@ -600,6 +601,17 @@ class Notice extends Managed_DataObject
 
                 // Scope set below
             }
+
+            // If we don't know the reply, we might know the conversation!
+            // This will happen if a known remote user replies to an
+            // unknown remote user - within a known conversation.
+            if (empty($notice->conversation) and !empty($options['conversation'])) {
+                $conv = Conversation::getKV('uri', $options['conversation']);
+                if ($conv instanceof Conversation and $activity->time > $conv->created) {
+                    common_debug('Conversation stitched together from (probably) reply to unknown remote user. Activity creation time ('.$activity->time.') is greater than conversation creation time ('.$conv->created.').');
+                    $notice->conversation = $conv->id;
+                }
+            }
         }
 
         if (!empty($lat) && !empty($lon)) {
index 7ddf1f4d8a8646abd4d5b908c677d5753b333e95..f7d4513a870cbfffb3df01e30d3137e1d2d9a2df 100644 (file)
@@ -684,6 +684,10 @@ class Ostatus_profile extends Managed_DataObject
                     $options['reply_to'] = $orig->id;
                 }
             }
+            if (!empty($activity->context->conversation)) {
+                // we store the URI here, Notice class can look it up later
+                $options['conversation'] = $activity->context->conversation;
+            }
 
             $location = $activity->context->location;
             if ($location) {