Some more clean up

This commit is contained in:
Michael 2018-09-26 07:42:40 +00:00
parent e91a1dfa8e
commit 67d2f8594c

View File

@ -68,7 +68,6 @@ use Friendica\Core\Config;
* General: * General:
* - Queueing unsucessful deliveries * - Queueing unsucessful deliveries
* - Polling the outboxes for missing content? * - Polling the outboxes for missing content?
* - Checking signature fails
* - Possibly using the LD-JSON parser * - Possibly using the LD-JSON parser
*/ */
class ActivityPub class ActivityPub
@ -849,6 +848,7 @@ class ActivityPub
$apcontact['baseurl'] = Network::unparseURL($parts); $apcontact['baseurl'] = Network::unparseURL($parts);
} else { } else {
$apcontact['addr'] = null; $apcontact['addr'] = null;
$apcontact['baseurl'] = null;
} }
if ($apcontact['url'] == $apcontact['alias']) { if ($apcontact['url'] == $apcontact['alias']) {
@ -872,6 +872,8 @@ class ActivityPub
// Update the gcontact table // Update the gcontact table
DBA::update('gcontact', $contact_fields, ['nurl' => normalise_link($url)]); DBA::update('gcontact', $contact_fields, ['nurl' => normalise_link($url)]);
logger('Updated profile for ' . $url, LOGGER_DEBUG);
return $apcontact; return $apcontact;
} }
@ -1030,6 +1032,7 @@ class ActivityPub
$object_data['name'] = $activity['type']; $object_data['name'] = $activity['type'];
$object_data['author'] = $activity['actor']; $object_data['author'] = $activity['actor'];
$object_data['object'] = $object_id; $object_data['object'] = $object_id;
$object_data['object_type'] = ''; // Since we don't fetch the object, we don't know the type
} else { } else {
$object_data = []; $object_data = [];
$object_data['id'] = $activity['id']; $object_data['id'] = $activity['id'];
@ -1323,9 +1326,9 @@ class ActivityPub
$object_data['id'] = $object['id']; $object_data['id'] = $object['id'];
if (!empty($object['inReplyTo'])) { if (!empty($object['inReplyTo'])) {
$object_data['reply-to-uri'] = JsonLD::fetchElement($object, 'inReplyTo', 'id'); $object_data['reply-to-id'] = JsonLD::fetchElement($object, 'inReplyTo', 'id');
} else { } else {
$object_data['reply-to-uri'] = $object_data['id']; $object_data['reply-to-id'] = $object_data['id'];
} }
$object_data['published'] = defaults($object, 'published', null); $object_data['published'] = defaults($object, 'published', null);
@ -1447,9 +1450,9 @@ class ActivityPub
{ {
$item = []; $item = [];
$item['verb'] = ACTIVITY_POST; $item['verb'] = ACTIVITY_POST;
$item['parent-uri'] = $activity['reply-to-uri']; $item['parent-uri'] = $activity['reply-to-id'];
if ($activity['reply-to-uri'] == $activity['id']) { if ($activity['reply-to-id'] == $activity['id']) {
$item['gravity'] = GRAVITY_PARENT; $item['gravity'] = GRAVITY_PARENT;
$item['object-type'] = ACTIVITY_OBJ_NOTE; $item['object-type'] = ACTIVITY_OBJ_NOTE;
} else { } else {
@ -1457,9 +1460,9 @@ class ActivityPub
$item['object-type'] = ACTIVITY_OBJ_COMMENT; $item['object-type'] = ACTIVITY_OBJ_COMMENT;
} }
if (($activity['id'] != $activity['reply-to-uri']) && !Item::exists(['uri' => $activity['reply-to-uri']])) { if (($activity['id'] != $activity['reply-to-id']) && !Item::exists(['uri' => $activity['reply-to-id']])) {
logger('Parent ' . $activity['reply-to-uri'] . ' not found. Try to refetch it.'); logger('Parent ' . $activity['reply-to-id'] . ' not found. Try to refetch it.');
self::fetchMissingActivity($activity['reply-to-uri'], $activity); self::fetchMissingActivity($activity['reply-to-id'], $activity);
} }
self::postItem($activity, $item, $body); self::postItem($activity, $item, $body);
@ -1490,11 +1493,11 @@ class ActivityPub
private static function postItem($activity, $item, $body) private static function postItem($activity, $item, $body)
{ {
/// @todo What to do with $activity['context']? /// @todo What to do with $activity['context']?
if (empty($activity['author']))
logger('Empty author');
if (empty($activity['owner'])) if (($item['gravity'] != GRAVITY_PARENT) && !Item::exists(['uri' => $item['parent-uri']])) {
logger('Empty owner'); logger('Parent ' . $item['parent-uri'] . ' not found, message will be discarded.', LOGGER_DEBUG);
return;
}
$item['network'] = Protocol::ACTIVITYPUB; $item['network'] = Protocol::ACTIVITYPUB;
$item['private'] = !in_array(0, $activity['receiver']); $item['private'] = !in_array(0, $activity['receiver']);
@ -1614,6 +1617,7 @@ class ActivityPub
return; return;
} }
logger('Updating profile for ' . $activity['object']['id'], LOGGER_DEBUG);
self::fetchprofile($activity['object']['id'], true); self::fetchprofile($activity['object']['id'], true);
} }