]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Delivery.php
Update does work now
[friendica.git] / src / Worker / Delivery.php
index e5a86e03e33e1457a57a865b85d5b9097c63a4b9..e505f4bd705f2da1d84c1f701303f8ae7b6ac289 100644 (file)
@@ -28,6 +28,7 @@ class Delivery extends BaseObject
        const DELETION =   'drop';
        const POST =       'wall-new';
        const COMMENT =    'comment-new';
+       const REMOVAL =    'removeme';
 
        public static function execute($cmd, $item_id, $contact_id)
        {
@@ -39,13 +40,13 @@ class Delivery extends BaseObject
 
                if ($cmd == self::MAIL) {
                        $target_item = dba::selectFirst('mail', [], ['id' => $item_id]);
-                       if (!DBM::is_result($message)) {
+                       if (!DBM::is_result($target_item)) {
                                return;
                        }
                        $uid = $target_item['uid'];
                } elseif ($cmd == self::SUGGESTION) {
                        $target_item = dba::selectFirst('fsuggest', [], ['id' => $item_id]);
-                       if (!DBM::is_result($message)) {
+                       if (!DBM::is_result($target_item)) {
                                return;
                        }
                        $uid = $target_item['uid'];
@@ -58,16 +59,12 @@ class Delivery extends BaseObject
                        }
                        $parent_id = intval($item['parent']);
 
-                       $itemdata = dba::p("SELECT `item`.*, `contact`.`uid` AS `cuid`,
-                                                       `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
-                                               FROM `item`
-                                               INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
-                                               LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
-                                               WHERE `item`.`id` IN (?, ?) AND `visible` AND NOT `moderated`
-                                               ORDER BY `item`.`id`",
-                                       $item_id, $parent_id);
+                       $condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false];
+                       $params = ['order' => ['id']];
+                       $itemdata = Item::select([], $condition, $params);
+
                        $items = [];
-                       while ($item = dba::fetch($itemdata)) {
+                       while ($item = Item::fetch($itemdata)) {
                                if ($item['id'] == $parent_id) {
                                        $parent = $item;
                                }
@@ -78,7 +75,7 @@ class Delivery extends BaseObject
                        }
                        dba::close($itemdata);
 
-                       $uid = $target_item['cuid'];
+                       $uid = $target_item['contact-uid'];
 
                        // avoid race condition with deleting entries
                        if ($items[0]['deleted']) {
@@ -199,7 +196,7 @@ class Delivery extends BaseObject
         */
        private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
        {
-               logger('Deliver ' . $target_item["guid"] . ' via DFRN to ' . empty($contact['addr']) ? $contact['url'] : $contact['addr']);
+               logger('Deliver ' . $target_item["guid"] . ' via DFRN to ' . (empty($contact['addr']) ? $contact['url'] : $contact['addr']));
 
                if ($cmd == self::MAIL) {
                        $item = $target_item;
@@ -270,7 +267,7 @@ class Delivery extends BaseObject
 
                // We don't have a relationship with contacts on a public post.
                // Se we transmit with the new method and via Diaspora as a fallback
-               if ($items[0]['uid'] == 0) {
+               if (($items[0]['uid'] == 0) || ($contact['uid'] == 0)) {
                        // Transmit in public if it's a relay post
                        $public_dfrn = ($contact['contact-type'] == ACCOUNT_TYPE_RELAY);