New item functions are now used in the delivery process as well

This commit is contained in:
Michael 2018-06-17 21:35:33 +00:00
parent e42b934807
commit 23aa9dffa0
3 changed files with 25 additions and 28 deletions

View file

@ -241,16 +241,16 @@ class Item extends BaseObject
{ {
$fields = []; $fields = [];
$fields['item'] = ['author-id', 'owner-id', 'contact-id', 'uid', 'id', 'parent', $fields['item'] = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent', 'guid',
'uri', 'thr-parent', 'parent-uri', 'content-warning', 'contact-id', 'owner-id', 'author-id', 'type', 'wall', 'gravity', 'extid',
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink', 'created', 'edited', 'commented', 'received', 'changed',
'guid', 'wall', 'private', 'starred', 'origin', 'title', 'body', 'file', 'event-id', 'title', 'body', 'app', 'verb', 'object-type', 'object', 'target-type', 'target',
'location', 'coord', 'app', 'attach', 'rendered-hash', 'rendered-html', 'object', 'postopts', 'plink', 'resource-id', 'event-id', 'tag', 'attach', 'inform',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'file', 'location', 'coord', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'id' => 'item_id', 'network' => 'item_network', 'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
'type', 'extid', 'changed', 'moderated', 'target-type', 'target', 'unseen', 'deleted', 'origin', 'forum_mode', 'mention',
'resource-id', 'tag', 'inform', 'pubmail', 'visible', 'bookmark', 'unseen', 'deleted', 'rendered-hash', 'rendered-html', 'global', 'shadow', 'content-warning',
'forum_mode', 'mention', 'global', 'shadow']; 'id' => 'item_id', 'network' => 'item_network'];
$fields['author'] = ['url' => 'author-link', 'name' => 'author-name', 'thumb' => 'author-avatar']; $fields['author'] = ['url' => 'author-link', 'name' => 'author-name', 'thumb' => 'author-avatar'];

View file

@ -59,14 +59,10 @@ class Delivery extends BaseObject
} }
$parent_id = intval($item['parent']); $parent_id = intval($item['parent']);
$itemdata = dba::p("SELECT `item`.*, `contact`.`uid` AS `cuid`, $condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false];
`sign`.`signed_text`,`sign`.`signature`,`sign`.`signer` $params = ['order' => ['id']];
FROM `item` $itemdata = Item::select([], $condition, $params);
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);
$items = []; $items = [];
while ($item = dba::fetch($itemdata)) { while ($item = dba::fetch($itemdata)) {
if ($item['id'] == $parent_id) { if ($item['id'] == $parent_id) {
@ -79,7 +75,7 @@ class Delivery extends BaseObject
} }
dba::close($itemdata); dba::close($itemdata);
$uid = $target_item['cuid']; $uid = $target_item['contact-uid'];
// avoid race condition with deleting entries // avoid race condition with deleting entries
if ($items[0]['deleted']) { if ($items[0]['deleted']) {

View file

@ -10,6 +10,7 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM; use Friendica\Database\DBM;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Group; use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Model\PushSubscriber; use Friendica\Model\PushSubscriber;
use Friendica\Network\Probe; use Friendica\Network\Probe;
@ -104,27 +105,27 @@ class Notifier {
intval($uid), NETWORK_DFRN, NETWORK_DIASPORA); intval($uid), NETWORK_DFRN, NETWORK_DIASPORA);
} else { } else {
// find ancestors // find ancestors
$target_item = dba::fetch_first("SELECT `item`.*, `contact`.`uid` AS `cuid` FROM `item` $condition = ['id' => $item_id, 'visible' => true, 'moderated' => false];
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` $target_item = Item::selectFirst([], $condition);
WHERE `item`.`id` = ? AND `visible` AND NOT `moderated`", $item_id);
if (!DBM::is_result($target_item) || !intval($target_item['parent'])) { if (!DBM::is_result($target_item) || !intval($target_item['parent'])) {
return; return;
} }
$parent_id = intval($target_item['parent']); $parent_id = intval($target_item['parent']);
$uid = $target_item['cuid']; $uid = $target_item['contact-uid'];
$updated = $target_item['edited']; $updated = $target_item['edited'];
$items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer` $condition = ['parent' => $parent_id, 'visible' => true, 'moderated' => false];
FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d AND visible AND NOT moderated ORDER BY `id` ASC", $params = ['order' => ['id']];
intval($parent_id) $ret = Item::select([], $condition, $params);
);
if (!count($items)) { if (!DBM::is_result($ret)) {
return; return;
} }
$items = dba::inArray($ret);
// avoid race condition with deleting entries // avoid race condition with deleting entries
if ($items[0]['deleted']) { if ($items[0]['deleted']) {
foreach ($items as $item) { foreach ($items as $item) {