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!
This commit is contained in:
Mikael Nordfeldth 2014-11-27 14:06:10 +01:00
parent 343291262e
commit bdb4a41696
2 changed files with 18 additions and 2 deletions

View File

@ -417,8 +417,9 @@ class Notice extends Managed_DataObject
static function saveNew($profile_id, $content, $source, array $options=null) { static function saveNew($profile_id, $content, $source, array $options=null) {
$defaults = array('uri' => null, $defaults = array('uri' => null,
'url' => null, 'url' => null,
'reply_to' => null, 'conversation' => null, // URI of conversation
'repeat_of' => null, '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, 'scope' => null,
'distribute' => true, 'distribute' => true,
'object_type' => null, 'object_type' => null,
@ -600,6 +601,17 @@ class Notice extends Managed_DataObject
// Scope set below // 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)) { if (!empty($lat) && !empty($lon)) {

View File

@ -684,6 +684,10 @@ class Ostatus_profile extends Managed_DataObject
$options['reply_to'] = $orig->id; $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; $location = $activity->context->location;
if ($location) { if ($location) {