X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDiaspora.php;h=20d1d74fea12ad99133019a3b72f537815e24181;hb=e3ee9ee501f6a02ba64b95cd593f7f2cbffa1631;hp=d2a7995d867c4e510caf3eaf68752625dc3d7caa;hpb=c41332364f2f8f2a55db8d318d8f96a22ce85f73;p=friendica.git diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index d2a7995d86..20d1d74fea 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -1602,11 +1602,21 @@ class Diaspora */ private static function getUriFromGuid($author, $guid, $onlyfound = false) { - $r = q("SELECT `uri` FROM `item` WHERE `guid` = '%s' LIMIT 1", dbesc($guid)); - if (DBM::is_result($r)) { - return $r[0]["uri"]; + $item = dba::selectFirst('item', ['uri'], ['guid' => $guid]); + if (DBM::is_result($item)) { + return $item["uri"]; } elseif (!$onlyfound) { - return $author.":".$guid; + $contact = Contact::getDetailsByAddr($author, 0); + if (!empty($contact['network'])) { + $prefix = 'urn:X-' . $contact['network'] . ':'; + } else { + // This fallback should happen most unlikely + $prefix = 'urn:X-dspr:'; + } + + $author_parts = explode('@', $author); + + return $prefix . $author_parts[1] . ':' . $author_parts[0] . ':'. $guid; } return ""; @@ -2785,7 +2795,7 @@ class Diaspora while ($item = dba::fetch($r)) { // Fetch the parent item - $parent = dba::selectFirst('item', ['author-link', 'origin'], ['id' => $item["parent"]]); + $parent = dba::selectFirst('item', ['author-link'], ['id' => $item["parent"]]); // Only delete it if the parent author really fits if (!link_compare($parent["author-link"], $contact["url"]) && !link_compare($item["author-link"], $contact["url"])) { @@ -2793,7 +2803,7 @@ class Diaspora continue; } - Item::deleteById($item["id"]); + Item::delete(['id' => $item['id']]); logger("Deleted target ".$target_guid." (".$item["id"].") from user ".$item["uid"]." parent: ".$item["parent"], LOGGER_DEBUG); }