Merge pull request #8345 from annando/store-raw
Store the raw data in a different way
This commit is contained in:
commit
b2198c7510
|
@ -29,6 +29,7 @@ use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\APContact;
|
use Friendica\Model\APContact;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Model\Conversation;
|
||||||
use Friendica\Model\Event;
|
use Friendica\Model\Event;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Mail;
|
use Friendica\Model\Mail;
|
||||||
|
@ -448,6 +449,13 @@ class Processor
|
||||||
$item['owner-link'] = $activity['actor'];
|
$item['owner-link'] = $activity['actor'];
|
||||||
$item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true);
|
$item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true);
|
||||||
|
|
||||||
|
if (!empty($activity['raw'])) {
|
||||||
|
$item['source'] = $activity['raw'];
|
||||||
|
$item['protocol'] = Conversation::PARCEL_ACTIVITYPUB;
|
||||||
|
$item['conversation-href'] = $activity['context'] ?? '';
|
||||||
|
$item['conversation-uri'] = $activity['conversation'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
$isForum = false;
|
$isForum = false;
|
||||||
|
|
||||||
if (!empty($activity['thread-completion'])) {
|
if (!empty($activity['thread-completion'])) {
|
||||||
|
|
|
@ -28,7 +28,6 @@ use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Protocol;
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\APContact;
|
use Friendica\Model\APContact;
|
||||||
use Friendica\Model\Conversation;
|
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
use Friendica\Protocol\Activity;
|
use Friendica\Protocol\Activity;
|
||||||
|
@ -303,33 +302,6 @@ class Receiver
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
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' => $activity['reply-to-id'] ?? '',
|
|
||||||
'conversation-href' => $activity['context'] ?? '',
|
|
||||||
'conversation-uri' => $activity['conversation'] ?? '',
|
|
||||||
'source' => $body,
|
|
||||||
'received' => DateTimeFormat::utcNow()];
|
|
||||||
|
|
||||||
DBA::insert('conversation', $conversation, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the activity object
|
* Processes the activity object
|
||||||
*
|
*
|
||||||
|
@ -380,9 +352,8 @@ class Receiver
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only store content related stuff - and no announces, since they possibly overwrite the original content
|
if (!empty($body)) {
|
||||||
if (in_array($object_data['object_type'], self::CONTENT_TYPES) && ($type != 'as:Announce')) {
|
$object_data['raw'] = $body;
|
||||||
self::storeConversation($object_data, $body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal flag for thread completion. See Processor.php
|
// Internal flag for thread completion. See Processor.php
|
||||||
|
|
Loading…
Reference in a new issue