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;
$type = 'TentativeAccept';
} elseif ($item['verb'] == ACTIVITY_FOLLOW) {
$type = 'Follow';
+ } elseif ($item['verb'] == ACTIVITY_TAG) {
+ $type = 'Add';
} else {
$type = '';
}
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') {
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
*
} 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";
}