Merge remote-tracking branch 'remotes/origin/develop' into lock_abstraction

This commit is contained in:
Philipp Holzer 2018-07-03 20:16:31 +02:00
commit b07dfbb03f
No known key found for this signature in database
GPG key ID: 58160D7D6AF942B6
17 changed files with 136 additions and 109 deletions

View file

@ -2310,18 +2310,18 @@ class DFRN
) {
$is_like = true;
$item["type"] = "activity";
$item["gravity"] = GRAVITY_LIKE;
$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

@ -2049,7 +2049,7 @@ class Diaspora
$datarray["type"] = "activity";
$datarray["verb"] = $verb;
$datarray["gravity"] = GRAVITY_LIKE;
$datarray["gravity"] = GRAVITY_ACTIVITY;
$datarray["parent-uri"] = $parent_item["uri"];
$datarray["object-type"] = ACTIVITY_OBJ_NOTE;

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 {
@ -451,7 +451,7 @@ class OStatus
$item["verb"] = ACTIVITY_LIKE;
$item["parent-uri"] = $orig_uri;
$item["gravity"] = GRAVITY_LIKE;
$item["gravity"] = GRAVITY_ACTIVITY;
}
// http://activitystrea.ms/schema/1.0/rsvp-yes
@ -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);
}