Merge pull request #5230 from annando/new-item-uri

New function for generating item URI
This commit is contained in:
Hypolite Petovan 2018-06-16 10:54:56 -04:00 committed by GitHub
commit 7d1bb9ecf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 51 additions and 45 deletions

View file

@ -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 "";