Location, coord and app are now processed as well

This commit is contained in:
Michael 2018-10-13 21:37:39 +00:00
parent aab4fa0c31
commit e829e074fc
2 changed files with 14 additions and 19 deletions

View file

@ -212,8 +212,13 @@ class Processor
$item['content-warning'] = HTML::toBBCode($activity['summary']); $item['content-warning'] = HTML::toBBCode($activity['summary']);
$item['body'] = self::convertMentions(HTML::toBBCode($activity['content'])); $item['body'] = self::convertMentions(HTML::toBBCode($activity['content']));
$item['location'] = $activity['location']; $item['location'] = $activity['location'];
if (!empty($item['latitude']) && !empty($item['longitude'])) {
$item['coord'] = $item['latitude'] . ' ' . $item['longitude'];
}
$item['tag'] = self::constructTagList($activity['tags'], $activity['sensitive']); $item['tag'] = self::constructTagList($activity['tags'], $activity['sensitive']);
$item['app'] = $activity['service']; $item['app'] = $activity['generator'];
$item['plink'] = defaults($activity, 'alternate-url', $item['uri']); $item['plink'] = defaults($activity, 'alternate-url', $item['uri']);
$item['diaspora_signed_text'] = defaults($activity, 'diaspora:comment', ''); $item['diaspora_signed_text'] = defaults($activity, 'diaspora:comment', '');

View file

@ -25,10 +25,6 @@ use Friendica\Util\DateTimeFormat;
* - Event * - Event
* - Undo Announce * - Undo Announce
* *
* Missing object fields:
* - Location
* - Generator
*
* Check what this is meant to do: * Check what this is meant to do:
* - Add * - Add
* - Block * - Block
@ -517,24 +513,15 @@ class Receiver
private static function addActivityFields($object_data, $activity) private static function addActivityFields($object_data, $activity)
{ {
if (!empty($activity['published']) && empty($object_data['published'])) { if (!empty($activity['published']) && empty($object_data['published'])) {
$object_data['published'] = JsonLD::fetchElement($activity, 'published', '@value'); $object_data['published'] = JsonLD::fetchElement($activity, 'as:published', '@value');
}
if (!empty($activity['updated']) && empty($object_data['updated'])) {
$object_data['updated'] = JsonLD::fetchElement($activity, 'updated', '@value');
} }
if (!empty($activity['diaspora:guid']) && empty($object_data['diaspora:guid'])) { if (!empty($activity['diaspora:guid']) && empty($object_data['diaspora:guid'])) {
$object_data['diaspora:guid'] = JsonLD::fetchElement($activity, 'diaspora:guid'); $object_data['diaspora:guid'] = JsonLD::fetchElement($activity, 'diaspora:guid');
} }
if (!empty($activity['inReplyTo']) && empty($object_data['parent-uri'])) { $object_data['service'] = JsonLD::fetchElement($activity, 'as:instrument', 'as:name', '@type', 'as:Service');
$object_data['parent-uri'] = JsonLD::fetchElement($activity, 'inReplyTo');
}
if (!empty($activity['instrument'])) {
$object_data['service'] = JsonLD::fetchElement($activity, 'instrument', 'name', 'type', 'Service');
}
return $object_data; return $object_data;
} }
@ -700,10 +687,13 @@ class Receiver
$object_data['content'] = JsonLD::fetchElement($object, 'as:content'); $object_data['content'] = JsonLD::fetchElement($object, 'as:content');
$object_data['source'] = JsonLD::fetchElement($object, 'as:source', 'as:content', 'as:mediaType', 'text/bbcode'); $object_data['source'] = JsonLD::fetchElement($object, 'as:source', 'as:content', 'as:mediaType', 'text/bbcode');
$object_data['location'] = JsonLD::fetchElement($object, 'as:location', 'as:name', '@type', 'as:Place'); $object_data['location'] = JsonLD::fetchElement($object, 'as:location', 'as:name', '@type', 'as:Place');
$object_data['latitude'] = JsonLD::fetchElement($object, 'as:location', 'as:latitude', '@type', 'as:Place');
$object_data['latitude'] = JsonLD::fetchElement($object_data, 'latitude', '@value');
$object_data['longitude'] = JsonLD::fetchElement($object, 'as:location', 'as:longitude', '@type', 'as:Place');
$object_data['longitude'] = JsonLD::fetchElement($object_data, 'longitude', '@value');
$object_data['attachments'] = self::processAttachments(JsonLD::fetchElementArray($object, 'as:attachment')); $object_data['attachments'] = self::processAttachments(JsonLD::fetchElementArray($object, 'as:attachment'));
$object_data['tags'] = self::processTags(JsonLD::fetchElementArray($object, 'as:tag')); $object_data['tags'] = self::processTags(JsonLD::fetchElementArray($object, 'as:tag'));
// $object_data['service'] = JsonLD::fetchElement($object, 'instrument', 'name', 'type', 'Service'); // todo $object_data['generator'] = JsonLD::fetchElement($object, 'as:generator', 'as:name', '@type', 'as:Application');
$object_data['service'] = null;
$object_data['alternate-url'] = JsonLD::fetchElement($object, 'as:url'); $object_data['alternate-url'] = JsonLD::fetchElement($object, 'as:url');
// Special treatment for Hubzilla links // Special treatment for Hubzilla links
@ -723,7 +713,7 @@ class Receiver
// @context, type, actor, signature, mediaType, duration, replies, icon // @context, type, actor, signature, mediaType, duration, replies, icon
// Also missing: (Defined in the standard, but currently unused) // Also missing: (Defined in the standard, but currently unused)
// audience, preview, endTime, startTime, generator, image // audience, preview, endTime, startTime, image
// Data in Notes: // Data in Notes: