From: Mikael Nordfeldth Date: Thu, 27 Nov 2014 13:06:10 +0000 (+0100) Subject: Use remote conversation URI info to stitch convos together X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bdb4a4169677b326fc20fd63777c91bdacb48a01;p=quix0rs-gnu-social.git Use remote conversation URI info to stitch convos together 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! --- diff --git a/classes/Notice.php b/classes/Notice.php index fd3a98f1f7..0074a37bdf 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -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)) { diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index 7ddf1f4d8a..f7d4513a87 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -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) {