X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FDelivery.php;h=32bcdfcc40c137b8cea6d42fa32d11fc5d73c256;hb=eaf81e5e66db1f722192005ff75bb5831c1912eb;hp=022faa2d7ac26a07e5d0a14be27b8f49baa6a47c;hpb=69af69d1a0c4deb855c6598b681893e905937144;p=friendica.git diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php index 022faa2d7a..32bcdfcc40 100644 --- a/src/Worker/Delivery.php +++ b/src/Worker/Delivery.php @@ -59,7 +59,7 @@ class Delivery extends BaseObject } $parent_id = intval($item['parent']); - $condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false]; + $condition = ['id' => [$item_id, $parent_id], 'moderated' => false]; $params = ['order' => ['id']]; $itemdata = Item::select([], $condition, $params); @@ -75,6 +75,16 @@ class Delivery extends BaseObject } DBA::close($itemdata); + if (empty($target_item)) { + logger('Item ' . $item_id . "wasn't found. Quitting here."); + return; + } + + if (empty($parent)) { + logger('Parent ' . $parent_id . ' for item ' . $item_id . "wasn't found. Quitting here."); + return; + } + $uid = $target_item['contact-uid']; // avoid race condition with deleting entries @@ -265,6 +275,12 @@ class Delivery extends BaseObject $user = DBA::selectFirst('user', [], ['uid' => $target_uid]); + // This should also never fail + if (!DBA::isResult($user)) { + logger('No user found for uid ' . $target_uid); + return; + } + $target_importer = array_merge($target_importer, $user); // Set the user id. This is important if this is a public contact @@ -277,7 +293,7 @@ class Delivery extends BaseObject // Se we transmit with the new method and via Diaspora as a fallback if (!empty($items) && (($items[0]['uid'] == 0) || ($contact['uid'] == 0))) { // Transmit in public if it's a relay post - $public_dfrn = ($contact['contact-type'] == ACCOUNT_TYPE_RELAY); + $public_dfrn = ($contact['contact-type'] == Contact::ACCOUNT_TYPE_RELAY); $deliver_status = DFRN::transmit($owner, $contact, $atom, $public_dfrn); @@ -331,7 +347,7 @@ class Delivery extends BaseObject private static function deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup) { // We don't treat Forum posts as "wall-to-wall" to be able to post them via Diaspora - $walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != ACCOUNT_TYPE_COMMUNITY); + $walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != Contact::ACCOUNT_TYPE_COMMUNITY); if ($public_message) { $loc = 'public batch ' . $contact['batch']; @@ -424,7 +440,7 @@ class Delivery extends BaseObject // only expose our real email address to true friends - if (($contact['rel'] == CONTACT_IS_FRIEND) && !$contact['blocked']) { + if (($contact['rel'] == Contact::FRIEND) && !$contact['blocked']) { if ($reply_to) { $headers = 'From: ' . Email::encodeHeader($local_user['username'],'UTF-8') . ' <' . $reply_to.'>' . "\n"; $headers .= 'Sender: ' . $local_user['email'] . "\n";