1
0
Fork 0

Fix notices because of unknown Hubzilla activity type

This commit is contained in:
Michael 2021-07-09 19:30:41 +00:00
parent d6c1e1fd1c
commit 90897f36ca
2 changed files with 8 additions and 11 deletions

View file

@ -192,10 +192,6 @@ class Processor
*/ */
public static function createItem($activity) public static function createItem($activity)
{ {
if (empty($activity['reply-to-id'])) {
$activity['reply-to-id'] = $activity['id'];
}
$item = []; $item = [];
$item['verb'] = Activity::POST; $item['verb'] = Activity::POST;
$item['thr-parent'] = $activity['reply-to-id']; $item['thr-parent'] = $activity['reply-to-id'];

View file

@ -333,7 +333,8 @@ class Receiver
$object_type = self::fetchObjectType($activity, $object_id, $uid); $object_type = self::fetchObjectType($activity, $object_id, $uid);
// Fetch the content only on activities where this matters // Fetch the content only on activities where this matters
if (in_array($type, ['as:Create', 'as:Update', 'as:Announce'])) { // We can receive "#emojiReaction" when fetching content from Hubzilla systems
if (in_array($type, ['as:Create', 'as:Update', 'as:Announce']) || strpos($type, '#emojiReaction')) {
// Always fetch on "Announce" // Always fetch on "Announce"
$object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source && ($type != 'as:Announce'), $uid); $object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source && ($type != 'as:Announce'), $uid);
if (empty($object_data)) { if (empty($object_data)) {
@ -501,7 +502,7 @@ class Receiver
if (!empty($activity['from-relay'])) { if (!empty($activity['from-relay'])) {
$object_data['from-relay'] = $activity['from-relay']; $object_data['from-relay'] = $activity['from-relay'];
} }
switch ($type) { switch ($type) {
case 'as:Create': case 'as:Create':
if (in_array($object_data['object_type'], self::CONTENT_TYPES)) { if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
@ -627,7 +628,7 @@ class Receiver
* @param array $activity * @param array $activity
* @param string $actor * @param string $actor
* @param array $tags * @param array $tags
* @param boolean $fetch_unlisted * @param boolean $fetch_unlisted
* *
* @return array with receivers (user id) * @return array with receivers (user id)
* @throws \Exception * @throws \Exception
@ -687,7 +688,7 @@ class Receiver
$receivers[0] = ['uid' => 0, 'type' => self::TARGET_GLOBAL]; $receivers[0] = ['uid' => 0, 'type' => self::TARGET_GLOBAL];
} }
// Add receiver "-1" for unlisted posts // Add receiver "-1" for unlisted posts
if ($fetch_unlisted && ($receiver == self::PUBLIC_COLLECTION) && ($element == 'as:cc')) { if ($fetch_unlisted && ($receiver == self::PUBLIC_COLLECTION) && ($element == 'as:cc')) {
$receivers[-1] = ['uid' => -1, 'type' => self::TARGET_GLOBAL]; $receivers[-1] = ['uid' => -1, 'type' => self::TARGET_GLOBAL];
} }
@ -950,7 +951,7 @@ class Receiver
Logger::info('Empty id'); Logger::info('Empty id');
return false; return false;
} }
if ($id != $object_id) { if ($id != $object_id) {
Logger::info('Fetched id differs from provided id', ['provided' => $object_id, 'fetched' => $id]); Logger::info('Fetched id differs from provided id', ['provided' => $object_id, 'fetched' => $id]);
return false; return false;
@ -1232,7 +1233,7 @@ class Receiver
if (empty($object['as:url'])) { if (empty($object['as:url'])) {
return $object_data; return $object_data;
} }
$urls = $object['as:url']; $urls = $object['as:url'];
$keys = array_keys($urls); $keys = array_keys($urls);
if (!is_numeric(array_pop($keys))) { if (!is_numeric(array_pop($keys))) {
@ -1299,7 +1300,7 @@ class Receiver
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
private static function processObject($object) public static function processObject($object)
{ {
if (!JsonLD::fetchElement($object, '@id')) { if (!JsonLD::fetchElement($object, '@id')) {
return false; return false;