From: Michael Date: Thu, 27 Feb 2020 05:01:43 +0000 (+0000) Subject: Push/Pull indicator X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=acd99b901067f1c61cd98e36965c443c647389d1;p=friendica.git Push/Pull indicator --- diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 089d41729f..65f1017469 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -474,6 +474,15 @@ class Processor return; } + if (isset($activity['push'])) { + $push_app = $activity['push'] ? '📨' : '🚜'; + if (!empty($item['app'])) { + $item['app'] .= ' (' . $push_app . ')'; + } else { + $item['app'] .= $push_app; + } + } + $item['plink'] = $activity['alternate-url'] ?? $item['uri']; $item = self::constructAttachList($activity, $item); diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 7d25d94f17..96e1588d49 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -127,7 +127,7 @@ class Receiver $trust_source = false; } - self::processActivity($ldactivity, $body, $uid, $trust_source); + self::processActivity($ldactivity, $body, $uid, $trust_source, true); } /** @@ -183,7 +183,7 @@ class Receiver * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException */ - private static function prepareObjectData($activity, $uid, &$trust_source) + private static function prepareObjectData($activity, $uid, $push, &$trust_source) { $actor = JsonLD::fetchElement($activity, 'as:actor', '@id'); if (empty($actor)) { @@ -225,13 +225,16 @@ class Receiver if (in_array($type, ['as:Create', 'as:Update', 'as:Announce'])) { if ($type == 'as:Announce') { $trust_source = false; + $push = false; } $object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source, $uid); if (empty($object_data)) { Logger::log("Object data couldn't be processed", Logger::DEBUG); return []; } + $object_data['object_id'] = $object_id; + $object_data['push'] = $push; // Test if it is an answer to a mail if (DBA::exists('mail', ['uri' => $object_data['reply-to-id']])) { @@ -339,7 +342,7 @@ class Receiver * @param boolean $trust_source Do we trust the source? * @throws \Exception */ - public static function processActivity($activity, $body = '', $uid = null, $trust_source = false) + public static function processActivity($activity, $body = '', $uid = null, $trust_source = false, $push = false) { $type = JsonLD::fetchElement($activity, '@type'); if (!$type) { @@ -369,7 +372,7 @@ class Receiver } // $trust_source is called by reference and is set to true if the content was retrieved successfully - $object_data = self::prepareObjectData($activity, $uid, $trust_source); + $object_data = self::prepareObjectData($activity, $uid, $push, $trust_source); if (empty($object_data)) { Logger::log('No object data found', Logger::DEBUG); return;