mirror of
https://github.com/friendica/friendica
synced 2025-04-26 06:30:11 +00:00
Store conversation data directly from the AP receiver
This commit is contained in:
parent
339e76b314
commit
1bf7521af8
2 changed files with 40 additions and 19 deletions
|
@ -14,6 +14,8 @@ use Friendica\Model\User;
|
|||
use Friendica\Util\JsonLD;
|
||||
use Friendica\Util\LDSignature;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Model\Conversation;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
/**
|
||||
* @brief ActivityPub Receiver Protocol class
|
||||
|
@ -229,6 +231,32 @@ class Receiver
|
|||
return $object_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the unprocessed data into the conversation table
|
||||
* This has to be done outside the regular function,
|
||||
* since we store everything - not only item posts.
|
||||
*
|
||||
* @param array $activity Array with activity data
|
||||
* @param string $body The raw message
|
||||
*/
|
||||
private static function storeConversation($activity, $body)
|
||||
{
|
||||
if (empty($body) || empty($activity['id'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$conversation = [
|
||||
'protocol' => Conversation::PARCEL_ACTIVITYPUB,
|
||||
'item-uri' => $activity['id'],
|
||||
'reply-to-uri' => defaults($activity, 'reply-to-id', ''),
|
||||
'conversation-href' => defaults($activity, 'context', ''),
|
||||
'conversation-uri' => defaults($activity, 'conversation', ''),
|
||||
'source' => $body,
|
||||
'received' => DateTimeFormat::utcNow()];
|
||||
|
||||
DBA::insert('conversation', $conversation, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the activity object
|
||||
*
|
||||
|
@ -268,6 +296,8 @@ class Receiver
|
|||
return;
|
||||
}
|
||||
|
||||
self::storeConversation($object_data, $body);
|
||||
|
||||
// Internal flag for thread completion. See Processor.php
|
||||
if (!empty($activity['thread-completion'])) {
|
||||
$object_data['thread-completion'] = $activity['thread-completion'];
|
||||
|
@ -276,15 +306,15 @@ class Receiver
|
|||
switch ($type) {
|
||||
case 'as:Create':
|
||||
case 'as:Announce':
|
||||
ActivityPub\Processor::createItem($object_data, $body);
|
||||
ActivityPub\Processor::createItem($object_data);
|
||||
break;
|
||||
|
||||
case 'as:Like':
|
||||
ActivityPub\Processor::likeItem($object_data, $body);
|
||||
ActivityPub\Processor::likeItem($object_data);
|
||||
break;
|
||||
|
||||
case 'as:Dislike':
|
||||
ActivityPub\Processor::dislikeItem($object_data, $body);
|
||||
ActivityPub\Processor::dislikeItem($object_data);
|
||||
break;
|
||||
|
||||
case 'as:Update':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue