We now store the verb in the item-content as well

This commit is contained in:
Michael 2018-06-27 19:37:13 +00:00
parent 76dab3b2d7
commit 028c9f4da5
6 changed files with 70 additions and 47 deletions

View file

@ -2313,15 +2313,15 @@ class DFRN
$item["gravity"] = GRAVITY_ACTIVITY;
// only one like or dislike per person
// splitted into two queries for performance issues
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"],
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
'verb' => $item["verb"], 'parent-uri' => $item["parent-uri"]];
if (dba::exists('item', $condition)) {
if (Item::exists($condition)) {
return false;
}
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"],
$condition = ['uid' => $item["uid"], 'author-id' => $item["author-id"], 'gravity' => GRAVITY_ACTIVITY,
'verb' => $item["verb"], 'thr-parent' => $item["parent-uri"]];
if (dba::exists('item', $condition)) {
if (Item::exists($condition)) {
return false;
}
} else {
@ -2770,7 +2770,7 @@ class DFRN
// Comments can be deleted by the thread owner or comment owner
if (($item['id'] != $item['parent']) && ($item['contact-id'] != $importer["id"])) {
$condition = ['id' => $item['parent'], 'contact-id' => $importer["id"]];
if (!dba::exists('item', $condition)) {
if (!Item::exists($condition)) {
logger("Item with uri " . $uri . " wasn't found or mustn't be deleted by contact " . $importer["id"] . " - ignoring deletion.", LOGGER_DEBUG);
return;
}

View file

@ -416,7 +416,7 @@ class OStatus
}
// Deletions come with the same uri, so we check for duplicates after processing deletions
if (dba::exists('item', ['uid' => $importer["uid"], 'uri' => $item["uri"]])) {
if (Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]])) {
logger('Post with URI '.$item["uri"].' already existed for user '.$importer["uid"].'.', LOGGER_DEBUG);
continue;
} else {
@ -489,7 +489,7 @@ class OStatus
}
} else {
// But we will only import complete threads
$valid = dba::exists('item', ['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]);
$valid = Item::exists(['uid' => $importer["uid"], 'uri' => self::$itemlist[0]['parent-uri']]);
if ($valid) {
logger("Item with uri ".self::$itemlist[0]["uri"]." belongs to parent ".self::$itemlist[0]['parent-uri']." of user ".$importer["uid"].". It will be imported.", LOGGER_DEBUG);
}
@ -506,7 +506,7 @@ class OStatus
}
}
foreach (self::$itemlist as $item) {
$found = dba::exists('item', ['uid' => $importer["uid"], 'uri' => $item["uri"]]);
$found = Item::exists(['uid' => $importer["uid"], 'uri' => $item["uri"]]);
if ($found) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already exists.", LOGGER_DEBUG);
} elseif ($item['contact-id'] < 0) {
@ -537,8 +537,8 @@ class OStatus
*/
private static function deleteNotice($item)
{
$condition = ['uid' => $item['uid'], 'author-link' => $item['author-link'], 'uri' => $item['uri']];
if (!dba::exists('item', $condition)) {
$condition = ['uid' => $item['uid'], 'author-id' => $item['author-id'], 'uri' => $item['uri']];
if (!Item::exists($condition)) {
logger('Item from '.$item['author-link'].' with uri '.$item['uri'].' for user '.$item['uid']." wasn't found. We don't delete it.");
return;
}
@ -674,7 +674,7 @@ class OStatus
}
if (isset($item["parent-uri"])) {
if (!dba::exists('item', ['uid' => $importer["uid"], 'uri' => $item['parent-uri']])) {
if (!Item::exists(['uid' => $importer["uid"], 'uri' => $item['parent-uri']])) {
if ($related != '') {
self::fetchRelated($related, $item["parent-uri"], $importer);
}