More item abstraction / making remote deletion work again
This commit is contained in:
parent
d6af9515ba
commit
4d35e228c4
10 changed files with 31 additions and 21 deletions
|
@ -1272,7 +1272,7 @@ function api_status_show($type)
|
||||||
// get last public wall message
|
// get last public wall message
|
||||||
$condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
|
$condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
|
||||||
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
|
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
|
||||||
$lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]);
|
$lastwall = Item::selectFirst(Item::ITEM_FIELDLIST, $condition, ['order' => ['id' => true]]);
|
||||||
|
|
||||||
if (DBM::is_result($lastwall)) {
|
if (DBM::is_result($lastwall)) {
|
||||||
$in_reply_to = api_in_reply_to($lastwall);
|
$in_reply_to = api_in_reply_to($lastwall);
|
||||||
|
@ -1357,7 +1357,7 @@ function api_users_show($type)
|
||||||
|
|
||||||
$condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
|
$condition = ['owner-id' => $user_info['pid'], 'uid' => api_user(),
|
||||||
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'private' => false];
|
'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT], 'private' => false];
|
||||||
$lastwall = dba::selectFirst('item', [], $condition, ['order' => ['id' => true]]);
|
$lastwall = Item::selectFirst(Item::ITEM_FIELDLIST, $condition, ['order' => ['id' => true]]);
|
||||||
|
|
||||||
if (DBM::is_result($lastwall)) {
|
if (DBM::is_result($lastwall)) {
|
||||||
$in_reply_to = api_in_reply_to($lastwall);
|
$in_reply_to = api_in_reply_to($lastwall);
|
||||||
|
@ -1817,12 +1817,12 @@ function api_statuses_show($type)
|
||||||
$conversation = (x($_REQUEST, 'conversation') ? 1 : 0);
|
$conversation = (x($_REQUEST, 'conversation') ? 1 : 0);
|
||||||
|
|
||||||
// try to fetch the item for the local user - or the public item, if there is no local one
|
// try to fetch the item for the local user - or the public item, if there is no local one
|
||||||
$uri_item = dba::selectFirst('item', ['uri'], ['id' => $id]);
|
$uri_item = Item::selectFirst(['uri'], ['id' => $id]);
|
||||||
if (!DBM::is_result($uri_item)) {
|
if (!DBM::is_result($uri_item)) {
|
||||||
throw new BadRequestException("There is no status with this id.");
|
throw new BadRequestException("There is no status with this id.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = dba::selectFirst('item', ['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
$item = Item::selectFirst(['id'], ['uri' => $uri_item['uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||||
if (!DBM::is_result($item)) {
|
if (!DBM::is_result($item)) {
|
||||||
throw new BadRequestException("There is no status with this id.");
|
throw new BadRequestException("There is no status with this id.");
|
||||||
}
|
}
|
||||||
|
@ -1897,12 +1897,12 @@ function api_conversation_show($type)
|
||||||
logger('API: api_conversation_show: '.$id);
|
logger('API: api_conversation_show: '.$id);
|
||||||
|
|
||||||
// try to fetch the item for the local user - or the public item, if there is no local one
|
// try to fetch the item for the local user - or the public item, if there is no local one
|
||||||
$item = dba::selectFirst('item', ['parent-uri'], ['id' => $id]);
|
$item = Item::selectFirst(['parent-uri'], ['id' => $id]);
|
||||||
if (!DBM::is_result($item)) {
|
if (!DBM::is_result($item)) {
|
||||||
throw new BadRequestException("There is no status with this id.");
|
throw new BadRequestException("There is no status with this id.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = dba::selectFirst('item', ['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
$parent = Item::selectFirst(['id'], ['uri' => $item['parent-uri'], 'uid' => [0, api_user()]], ['order' => ['uid' => true]]);
|
||||||
if (!DBM::is_result($parent)) {
|
if (!DBM::is_result($parent)) {
|
||||||
throw new BadRequestException("There is no status with this id.");
|
throw new BadRequestException("There is no status with this id.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ function acl_content(App $a)
|
||||||
|
|
||||||
if ($conv_id) {
|
if ($conv_id) {
|
||||||
// In multi threaded posts the conv_id is not the parent of the whole thread
|
// In multi threaded posts the conv_id is not the parent of the whole thread
|
||||||
$parent_item = dba::selectFirst('item', ['parent'], ['id' => $conv_id]);
|
$parent_item = Item::selectFirst(['parent'], ['id' => $conv_id]);
|
||||||
if (DBM::is_result($parent_item)) {
|
if (DBM::is_result($parent_item)) {
|
||||||
$conv_id = $parent_item['parent'];
|
$conv_id = $parent_item['parent'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
||||||
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
$item_id = $_REQUEST['item_id'];
|
$item_id = $_REQUEST['item_id'];
|
||||||
$item = dba::selectFirst('item', ['uid', 'parent', 'parent-uri'], ['id' => $item_id]);
|
$item = Item::selectFirst(['uid', 'parent', 'parent-uri'], ['id' => $item_id]);
|
||||||
if ($item['uid'] != 0) {
|
if ($item['uid'] != 0) {
|
||||||
$a->profile = ['uid' => intval($item['uid']), 'profile_uid' => intval($item['uid'])];
|
$a->profile = ['uid' => intval($item['uid']), 'profile_uid' => intval($item['uid'])];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -106,7 +106,7 @@ function item_post(App $a) {
|
||||||
$thr_parent_contact = Contact::getDetailsByURL($parent_item["author-link"]);
|
$thr_parent_contact = Contact::getDetailsByURL($parent_item["author-link"]);
|
||||||
|
|
||||||
if ($parent_item['id'] != $parent_item['parent']) {
|
if ($parent_item['id'] != $parent_item['parent']) {
|
||||||
$parent_item = dba::selectFirst('item', [], ['id' => $parent_item['parent']]);
|
$parent_item = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $parent_item['parent']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ function item_post(App $a) {
|
||||||
$orig_post = null;
|
$orig_post = null;
|
||||||
|
|
||||||
if ($post_id) {
|
if ($post_id) {
|
||||||
$orig_post = dba::selectFirst('item', [], ['id' => $post_id]);
|
$orig_post = Item::selectFirst(Item::ITEM_FIELDLIST, ['id' => $post_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = dba::selectFirst('user', [], ['uid' => $profile_uid]);
|
$user = dba::selectFirst('user', [], ['uid' => $profile_uid]);
|
||||||
|
|
|
@ -13,6 +13,7 @@ use Friendica\Core\L10n;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Model\Item;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
use dba;
|
use dba;
|
||||||
|
@ -178,7 +179,7 @@ class Post extends BaseObject
|
||||||
if (!$origin) {
|
if (!$origin) {
|
||||||
/// @todo This shouldn't be done as query here, but better during the data creation.
|
/// @todo This shouldn't be done as query here, but better during the data creation.
|
||||||
// it is now done here, since during the RC phase we shouldn't make to intense changes.
|
// it is now done here, since during the RC phase we shouldn't make to intense changes.
|
||||||
$parent = dba::selectFirst('item', ['origin'], ['id' => $item['parent']]);
|
$parent = Item::selectFirst(['origin'], ['id' => $item['parent']]);
|
||||||
if (DBM::is_result($parent)) {
|
if (DBM::is_result($parent)) {
|
||||||
$origin = $parent['origin'];
|
$origin = $parent['origin'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2414,8 +2414,7 @@ class DFRN
|
||||||
|
|
||||||
$item["edited"] = $xpath->query("atom:updated/text()", $entry)->item(0)->nodeValue;
|
$item["edited"] = $xpath->query("atom:updated/text()", $entry)->item(0)->nodeValue;
|
||||||
|
|
||||||
$current = dba::selectFirst('item',
|
$current = Item::selectFirst(['id', 'uid', 'edited', 'body'],
|
||||||
['id', 'uid', 'edited', 'body'],
|
|
||||||
['uri' => $item["uri"], 'uid' => $importer["importer_uid"]]
|
['uri' => $item["uri"], 'uid' => $importer["importer_uid"]]
|
||||||
);
|
);
|
||||||
// Is there an existing item?
|
// Is there an existing item?
|
||||||
|
@ -2747,13 +2746,18 @@ class DFRN
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = ["`uri` = ? AND `uid` = ? AND NOT `file` LIKE '%[%'", $uri, $importer["importer_uid"]];
|
$condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]];
|
||||||
$item = dba::selectFirst('item', ['id', 'parent', 'contact-id'], $condition);
|
$item = Item::selectFirst(['id', 'parent', 'contact-id', 'file'], $condition);
|
||||||
if (!DBM::is_result($item)) {
|
if (!DBM::is_result($item)) {
|
||||||
logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", LOGGER_DEBUG);
|
logger("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", LOGGER_DEBUG);
|
||||||
return;
|
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
|
// 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"])) {
|
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);
|
logger("Item with uri " . $uri . " don't belong to contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG);
|
||||||
|
|
|
@ -2705,7 +2705,7 @@ class Diaspora
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch items that are about to be deleted
|
// 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.
|
// When we receive a public retraction, we delete every item that we find.
|
||||||
if ($importer['uid'] == 0) {
|
if ($importer['uid'] == 0) {
|
||||||
|
@ -2721,6 +2721,11 @@ class Diaspora
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($item = Item::fetch($r)) {
|
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
|
// Fetch the parent item
|
||||||
$parent = Item::selectFirst(['author-link'], ['id' => $item["parent"]]);
|
$parent = Item::selectFirst(['author-link'], ['id' => $item["parent"]]);
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ class Feed {
|
||||||
if (!$simulate) {
|
if (!$simulate) {
|
||||||
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
|
$condition = ["`uid` = ? AND `uri` = ? AND `network` IN (?, ?)",
|
||||||
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
|
$importer["uid"], $item["uri"], NETWORK_FEED, NETWORK_DFRN];
|
||||||
$previous = dba::selectFirst('item', ['id'], $condition);
|
$previous = Item::selectFirst(['id'], $condition);
|
||||||
if (DBM::is_result($previous)) {
|
if (DBM::is_result($previous)) {
|
||||||
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
|
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$previous["id"], LOGGER_DEBUG);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Delivery extends BaseObject
|
||||||
} elseif ($cmd == self::RELOCATION) {
|
} elseif ($cmd == self::RELOCATION) {
|
||||||
$uid = $item_id;
|
$uid = $item_id;
|
||||||
} else {
|
} else {
|
||||||
$item = dba::selectFirst('item', ['parent'], ['id' => $item_id]);
|
$item = Item::selectFirst(['parent'], ['id' => $item_id]);
|
||||||
if (!DBM::is_result($item) || empty($item['parent'])) {
|
if (!DBM::is_result($item) || empty($item['parent'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -436,12 +436,12 @@ class Delivery extends BaseObject
|
||||||
|
|
||||||
if (empty($target_item['title'])) {
|
if (empty($target_item['title'])) {
|
||||||
$condition = ['uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
|
$condition = ['uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
|
||||||
$title = dba::selectFirst('item', ['title'], $condition);
|
$title = Item::selectFirst(['title'], $condition);
|
||||||
if (DBM::is_result($title) && ($title['title'] != '')) {
|
if (DBM::is_result($title) && ($title['title'] != '')) {
|
||||||
$subject = $title['title'];
|
$subject = $title['title'];
|
||||||
} else {
|
} else {
|
||||||
$condition = ['parent-uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
|
$condition = ['parent-uri' => $target_item['parent-uri'], 'uid' => $owner['uid']];
|
||||||
$title = dba::selectFirst('item', ['title'], $condition);
|
$title = Item::selectFirst(['title'], $condition);
|
||||||
if (DBM::is_result($title) && ($title['title'] != '')) {
|
if (DBM::is_result($title) && ($title['title'] != '')) {
|
||||||
$subject = $title['title'];
|
$subject = $title['title'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ class Notifier {
|
||||||
|
|
||||||
$fields = ['network', 'author-id', 'owner-id'];
|
$fields = ['network', 'author-id', 'owner-id'];
|
||||||
$condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
|
$condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
|
||||||
$thr_parent = dba::selectFirst('item', $fields, $condition);
|
$thr_parent = Item::selectFirst($fields, $condition);
|
||||||
|
|
||||||
logger('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent['network'], LOGGER_DEBUG);
|
logger('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent['network'], LOGGER_DEBUG);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue