More item abstraction / making remote deletion work again

This commit is contained in:
Michael 2018-07-07 18:14:16 +00:00
parent d6af9515ba
commit 4d35e228c4
10 changed files with 31 additions and 21 deletions

View file

@ -2414,8 +2414,7 @@ class DFRN
$item["edited"] = $xpath->query("atom:updated/text()", $entry)->item(0)->nodeValue;
$current = dba::selectFirst('item',
['id', 'uid', 'edited', 'body'],
$current = Item::selectFirst(['id', 'uid', 'edited', 'body'],
['uri' => $item["uri"], 'uid' => $importer["importer_uid"]]
);
// Is there an existing item?
@ -2747,13 +2746,18 @@ class DFRN
return false;
}
$condition = ["`uri` = ? AND `uid` = ? AND NOT `file` LIKE '%[%'", $uri, $importer["importer_uid"]];
$item = dba::selectFirst('item', ['id', 'parent', 'contact-id'], $condition);
$condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]];
$item = Item::selectFirst(['id', 'parent', 'contact-id', 'file'], $condition);
if (!DBM::is_result($item)) {
logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", LOGGER_DEBUG);
return;
}
if (strstr($item['file'], '[')) {
logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " is filed. So it won't be deleted.", LOGGER_DEBUG);
return;
}
// When it is a starting post it has to belong to the person that wants to delete it
if (($item['id'] == $item['parent']) && ($item['contact-id'] != $importer["id"])) {
logger("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG);

View file

@ -2705,7 +2705,7 @@ class Diaspora
}
// Fetch items that are about to be deleted
$fields = ['uid', 'id', 'parent', 'parent-uri', 'author-link'];
$fields = ['uid', 'id', 'parent', 'parent-uri', 'author-link', 'file'];
// When we receive a public retraction, we delete every item that we find.
if ($importer['uid'] == 0) {
@ -2721,6 +2721,11 @@ class Diaspora
}
while ($item = Item::fetch($r)) {
if (strstr($item['file'], '[')) {
logger("Target guid " . $target_guid . " for user " . $item['uid'] . " is filed. So it won't be deleted.", LOGGER_DEBUG);
continue;
}
// Fetch the parent item
$parent = Item::selectFirst(['author-link'], ['id' => $item["parent"]]);

View file

@ -250,7 +250,7 @@ class Feed {
if (!$simulate) {
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
$previous = dba::selectFirst('item', ['id'], $condition);
$previous = Item::selectFirst(['id'], $condition);
if (DBM::is_result($previous)) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
continue;