From 040abc7743aa5c1c7daa892497b68052057cbf4c Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 14 Mar 2022 23:15:24 +0000 Subject: [PATCH 1/2] Use a nicer GUID style format --- src/Model/Item.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 09abf95997..aff9dfed0b 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1785,19 +1785,14 @@ class Item // We have to avoid that different routines could accidentally create the same value $parsed = parse_url($uri); - // We use a hash of the hostname as prefix for the guid - $guid_prefix = hash("crc32", $host); - // Remove the scheme to make sure that "https" and "http" doesn't make a difference unset($parsed["scheme"]); // Glue it together to be able to make a hash from it $host_id = implode("/", $parsed); - // We could use any hash algorithm since it isn't a security issue - $host_hash = hash("ripemd128", $host_id); - - return $guid_prefix.$host_hash; + // Use a mixture of several hashes to provide some GUID like experience + return hash("crc32", $host) . '-'. hash('joaat', $host_id) . '-'. hash('fnv164', $host_id); } /** From 0aa229489f9e3fe275702bdf1bca4f987186caa3 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 17 Mar 2022 14:05:06 +0000 Subject: [PATCH 2/2] Improved function description --- src/Model/Item.php | 5 ++++- src/Protocol/ActivityPub/Processor.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index aff9dfed0b..5047af5986 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1773,7 +1773,10 @@ class Item } /** - * Creates an unique guid out of a given uri + * Creates an unique guid out of a given uri. + * This function is used for messages outside the fediverse (Connector posts, feeds, Mails, ...) + * 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 diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 9aeb301cf3..5651343cb5 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -553,7 +553,7 @@ class Processor } /** - * Generate a GUID out of an URL + * Generate a GUID out of an URL of an ActivityPub post. * * @param string $url message URL * @return string with GUID