]> git.mxchange.org Git - friendica.git/commitdiff
New item functions are now used in the delivery process as well
authorMichael <heluecht@pirati.ca>
Sun, 17 Jun 2018 21:35:33 +0000 (21:35 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 17 Jun 2018 21:35:33 +0000 (21:35 +0000)
src/Model/Item.php
src/Worker/Delivery.php
src/Worker/Notifier.php

index 0dede482ad063d962c264f505e4d16409bea7f5e..dcf944cc46a6c16453ad790c76686fb011863958 100644 (file)
@@ -241,16 +241,16 @@ class Item extends BaseObject
        {
                $fields = [];
 
-               $fields['item'] = ['author-id', 'owner-id', 'contact-id', 'uid', 'id', 'parent',
-                       'uri', 'thr-parent', 'parent-uri', 'content-warning',
-                       'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
-                       'guid', 'wall', 'private', 'starred', 'origin', 'title', 'body', 'file', 'event-id',
-                       'location', 'coord', 'app', 'attach', 'rendered-hash', 'rendered-html', 'object',
-                       'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
-                       'id' => 'item_id', 'network' => 'item_network',
-                       'type', 'extid', 'changed', 'moderated', 'target-type', 'target',
-                       'resource-id', 'tag', 'inform', 'pubmail', 'visible', 'bookmark', 'unseen', 'deleted',
-                       'forum_mode', 'mention', 'global', 'shadow'];
+               $fields['item'] = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent', 'guid',
+                       'contact-id', 'owner-id', 'author-id', 'type', 'wall', 'gravity', 'extid',
+                       'created', 'edited', 'commented', 'received', 'changed',
+                       'title', 'body', 'app', 'verb', 'object-type', 'object', 'target-type', 'target',
+                       'postopts', 'plink', 'resource-id', 'event-id', 'tag', 'attach', 'inform',
+                       'file', 'location', 'coord', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
+                       'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
+                       'unseen', 'deleted', 'origin', 'forum_mode', 'mention',
+                       'rendered-hash', 'rendered-html', 'global', 'shadow', 'content-warning',
+                       'id' => 'item_id', 'network' => 'item_network'];
 
                $fields['author'] = ['url' => 'author-link', 'name' => 'author-name', 'thumb' => 'author-avatar'];
 
index f91d0c19834c30a9e805ed548679c186c13c1674..15273762ab3808ec7f446be413998cad84ee05bd 100644 (file)
@@ -59,14 +59,10 @@ 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)) {
                                if ($item['id'] == $parent_id) {
@@ -79,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']) {
index 6ad6827f7c8d980ecd469a9eb9fd071cb56e8cae..61b296a26543a2b3c7d40c41f33255a3db876505 100644 (file)
@@ -10,6 +10,7 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\Group;
+use Friendica\Model\Item;
 use Friendica\Model\User;
 use Friendica\Model\PushSubscriber;
 use Friendica\Network\Probe;
@@ -104,27 +105,27 @@ class Notifier {
                                                intval($uid), NETWORK_DFRN, NETWORK_DIASPORA);
                } else {
                        // find ancestors
-                       $target_item = dba::fetch_first("SELECT `item`.*, `contact`.`uid` AS `cuid` FROM `item`
-                                               INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
-                                               WHERE `item`.`id` = ? AND `visible` AND NOT `moderated`", $item_id);
+                       $condition = ['id' => $item_id, 'visible' => true, 'moderated' => false];
+                       $target_item = Item::selectFirst([], $condition);
 
                        if (!DBM::is_result($target_item) || !intval($target_item['parent'])) {
                                return;
                        }
 
                        $parent_id = intval($target_item['parent']);
-                       $uid = $target_item['cuid'];
+                       $uid = $target_item['contact-uid'];
                        $updated = $target_item['edited'];
 
-                       $items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
-                               FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d AND visible AND NOT moderated ORDER BY `id` ASC",
-                               intval($parent_id)
-                       );
+                       $condition = ['parent' => $parent_id, 'visible' => true, 'moderated' => false];
+                       $params = ['order' => ['id']];
+                       $ret = Item::select([], $condition, $params);
 
-                       if (!count($items)) {
+                       if (!DBM::is_result($ret)) {
                                return;
                        }
 
+                       $items = dba::inArray($ret);
+
                        // avoid race condition with deleting entries
                        if ($items[0]['deleted']) {
                                foreach ($items as $item) {