Browse Source

Location, coord and app are now processed as well

pull/5904/head
Michael 3 years ago
parent
commit
e829e074fc
  1. 7
      src/Protocol/ActivityPub/Processor.php
  2. 26
      src/Protocol/ActivityPub/Receiver.php

7
src/Protocol/ActivityPub/Processor.php

@ -212,8 +212,13 @@ class Processor
$item['content-warning'] = HTML::toBBCode($activity['summary']);
$item['body'] = self::convertMentions(HTML::toBBCode($activity['content']));
$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['app'] = $activity['service'];
$item['app'] = $activity['generator'];
$item['plink'] = defaults($activity, 'alternate-url', $item['uri']);
$item['diaspora_signed_text'] = defaults($activity, 'diaspora:comment', '');

26
src/Protocol/ActivityPub/Receiver.php

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

Loading…
Cancel
Save