refactor Receiver::processObject() method

pull/14529/head
Art4 2024-11-14 07:32:25 +00:00
parent ee2cdc7763
commit 2ef9982f63
1 changed files with 16 additions and 18 deletions

View File

@ -1880,31 +1880,29 @@ class Receiver
$object_data = self::getObjectDataFromActivity($object);
$object_data['receiver_urls'] = self::getReceiverURL($object);
$object_data['receiver'] = [];
$object_data['reception_type'] = [];
$object_data['unlisted'] = false;
$receiverdata = self::getReceivers($object, $actor ?: $object_data['actor'] ?? '', $object_data['tags'], true, false);
$receivers = $reception_types = [];
foreach ($receiverdata as $key => $data) {
$receivers[$key] = $data['uid'];
$reception_types[$data['uid']] = $data['type'] ?? 0;
if ($data['uid'] !== -1) {
$object_data['reception_type'][$data['uid']] = $data['type'] ?? 0;
}
$object_data['receiver_urls'] = self::getReceiverURL($object);
$object_data['receiver'] = $receivers;
$object_data['reception_type'] = $reception_types;
$object_data['unlisted'] = false;
if ($key !== -1) {
$object_data['receiver'][$key] = $data['uid'];
} else {
$object_data['unlisted'] = true;
}
}
if (!empty($object['pixelfed:capabilities'])) {
$object_data['capabilities'] = self::getCapabilities($object);
}
if (in_array(-1, $object_data['receiver'])) {
$object_data['unlisted'] = true;
unset($object_data['receiver'][-1]);
if (array_key_exists(-1, $object_data['reception_type'])) {
unset($object_data['reception_type'][-1]);
}
}
return $object_data;
}