Merge pull request #8137 from annando/ap-guid
AP: Create a GUID out of an URL
This commit is contained in:
commit
7d35cc6a09
|
@ -389,6 +389,26 @@ class Processor
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a GUID out of an URL
|
||||||
|
*
|
||||||
|
* @param string $url message URL
|
||||||
|
* @return string with GUID
|
||||||
|
*/
|
||||||
|
private static function getGUIDByURL(string $url)
|
||||||
|
{
|
||||||
|
$parsed = parse_url($url);
|
||||||
|
|
||||||
|
$host_hash = hash('crc32', $parsed['host']);
|
||||||
|
|
||||||
|
unset($parsed["scheme"]);
|
||||||
|
unset($parsed["host"]);
|
||||||
|
|
||||||
|
$path = implode("/", $parsed);
|
||||||
|
|
||||||
|
return $host_hash . '-'. hash('fnv164', $path) . '-'. hash('joaat', $path);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item post
|
* Creates an item post
|
||||||
*
|
*
|
||||||
|
@ -431,7 +451,7 @@ class Processor
|
||||||
|
|
||||||
$item['created'] = DateTimeFormat::utc($activity['published']);
|
$item['created'] = DateTimeFormat::utc($activity['published']);
|
||||||
$item['edited'] = DateTimeFormat::utc($activity['updated']);
|
$item['edited'] = DateTimeFormat::utc($activity['updated']);
|
||||||
$item['guid'] = $activity['diaspora:guid'];
|
$item['guid'] = $activity['diaspora:guid'] ?: self::getGUIDByURL($item['uri']);
|
||||||
|
|
||||||
$item = self::processContent($activity, $item);
|
$item = self::processContent($activity, $item);
|
||||||
if (empty($item)) {
|
if (empty($item)) {
|
||||||
|
|
Loading…
Reference in a new issue