Standards

This commit is contained in:
Michael 2020-12-11 20:20:27 +00:00
parent a43059df27
commit 61b3003f64

View File

@ -475,7 +475,8 @@ class Transmitter
* @param integer $item_id * @param integer $item_id
* @return boolean "true" if the post is from ActivityPub * @return boolean "true" if the post is from ActivityPub
*/ */
private static function isAPPost(int $item_id) { private static function isAPPost(int $item_id)
{
if (empty($item_id)) { if (empty($item_id)) {
return false; return false;
} }
@ -1048,33 +1049,31 @@ class Transmitter
return false; return false;
} }
if (empty($type)) { $condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
$condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB]; $conversation = DBA::selectFirst('conversation', ['source'], $condition);
$conversation = DBA::selectFirst('conversation', ['source'], $condition); if (!$item['origin'] && DBA::isResult($conversation)) {
if (DBA::isResult($conversation)) { $data = json_decode($conversation['source'], true);
$data = json_decode($conversation['source'], true); if (!empty($data['type'])) {
if (!empty($data['type'])) { if (in_array($data['type'], ['Create', 'Update'])) {
if (in_array($data['type'], ['Create', 'Update'])) { if ($object_mode) {
if ($object_mode) { unset($data['@context']);
unset($data['@context']); unset($data['signature']);
unset($data['signature']);
}
Logger::info('Return stored conversation', ['item' => $item_id]);
return $data;
} elseif (in_array('as:' . $data['type'], Receiver::CONTENT_TYPES)) {
if (!empty($data['@context'])) {
$context = $data['@context'];
unset($data['@context']);
}
unset($data['actor']);
$object = $data;
} }
Logger::info('Return stored conversation', ['item' => $item_id]);
return $data;
} elseif (in_array('as:' . $data['type'], Receiver::CONTENT_TYPES)) {
if (!empty($data['@context'])) {
$context = $data['@context'];
unset($data['@context']);
}
unset($data['actor']);
$object = $data;
} }
} }
$type = self::getTypeOfItem($item);
} }
$type = self::getTypeOfItem($item);
if (!$object_mode) { if (!$object_mode) {
$data = ['@context' => $context ?? ActivityPub::CONTEXT]; $data = ['@context' => $context ?? ActivityPub::CONTEXT];