* Posts that are created on this system are using System::createUUID.
* Received ActivityPub posts are using Processor::getGUIDByURL.
*
- * @param string $uri uri of an item entry
- * @param string $host hostname for the GUID prefix
- * @return string unique guid
+ * @param string $uri uri of an item entry
+ * @param string|null $host hostname for the GUID prefix
+ * @return string Unique guid
*/
- public static function guidFromUri(string $uri, string $host): string
+ public static function guidFromUri(string $uri, string $host = null): string
{
// Our regular guid routine is using this kind of prefix as well
// We have to avoid that different routines could accidentally create the same value
$parsed = parse_url($uri);
// Remove the scheme to make sure that "https" and "http" doesn't make a difference
- unset($parsed["scheme"]);
+ unset($parsed['scheme']);
// Glue it together to be able to make a hash from it
- $host_id = implode("/", $parsed);
+ $host_id = implode('/', $parsed);
// Use a mixture of several hashes to provide some GUID like experience
- return hash("crc32", $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
+ return hash('crc32', $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id);
}
/**
* @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public static function newURI($uid, $guid = "")
+ public static function newURI(int $uid, string $guid = ''): string
{
- if ($guid == "") {
+ if ($guid == '') {
$guid = System::createUUID();
}
$shared_uri_id = 0;
$shared_links = [];
}
- $attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links, $item['has-media']);
+
+ $attachments = Post\Media::splitAttachments($item['uri-id'], $item['guid'] ?? '', $shared_links, $item['has-media'] ?? false);
$item['body'] = self::replaceVisualAttachments($attachments, $item['body'] ?? '');
$item['body'] = preg_replace("/\s*\[attachment .*?\].*?\[\/attachment\]\s*/ism", "\n", $item['body']);