From: Michael Date: Sat, 25 May 2019 19:33:58 +0000 (+0000) Subject: AP: We now transmit "add tag" activity / On Diaspora this is now supressed X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=32b1f75ecea252977e783974eb41672de653e579;p=friendica.git AP: We now transmit "add tag" activity / On Diaspora this is now supressed --- diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 7fc5e2df06..1a2c135330 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -21,6 +21,7 @@ use Friendica\Model\User; use Friendica\Util\DateTimeFormat; use Friendica\Content\Text\BBCode; use Friendica\Content\Text\Plaintext; +use Friendica\Util\XML; use Friendica\Util\JsonLD; use Friendica\Util\LDSignature; use Friendica\Model\Profile; @@ -772,6 +773,8 @@ class Transmitter $type = 'TentativeAccept'; } elseif ($item['verb'] == ACTIVITY_FOLLOW) { $type = 'Follow'; + } elseif ($item['verb'] == ACTIVITY_TAG) { + $type = 'Add'; } else { $type = ''; } @@ -875,6 +878,8 @@ class Transmitter if (in_array($data['type'], ['Create', 'Update', 'Delete'])) { $data['object'] = self::createNote($item); + } elseif ($data['type'] == 'Add') { + $data = self::createAddTag($item, $data); } elseif ($data['type'] == 'Announce') { $data = self::createAnnounce($item, $data); } elseif ($data['type'] == 'Follow') { @@ -1251,6 +1256,30 @@ class Transmitter return $data; } + /** + * Creates an an "add tag" entry + * + * @param array $item + * @param array $data activity data + * + * @return array with activity data for adding tags + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * @throws \ImagickException + */ + private static function createAddTag($item, $data) + { + $object = XML::parseString($item['object'], false); + $target = XML::parseString($item["target"], false); + + $data['diaspora:guid'] = $item['guid']; + $data['actor'] = $item['author-link']; + $data['target'] = (string)$target->id; + $data['summary'] = BBCode::toPlaintext($item['body']); + $data['object'] = ['id' => (string)$object->id, 'type' => 'tag', 'name' => (string)$object->title, 'content' => (string)$object->content]; + + return $data; + } + /** * Creates an announce object entry * diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 41ed7e7d9f..7bf0acbc49 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -3834,7 +3834,7 @@ class Diaspora } elseif (in_array($item["verb"], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) { $message = self::constructLike($item, $owner); $type = "like"; - } elseif (!in_array($item["verb"], [ACTIVITY_FOLLOW])) { + } elseif (!in_array($item["verb"], [ACTIVITY_FOLLOW, ACTIVITY_TAG])) { $message = self::constructComment($item, $owner); $type = "comment"; }