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['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'];

View 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']) {

View 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) {