From 467176fa65bde8801945994aa2c68f7f91345c54 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 20 Jun 2016 22:43:14 +0200 Subject: [PATCH 1/3] Diaspora: Ensure that we always store the correct URI --- include/diaspora.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 2ff7a90cf..84aed8147 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -981,6 +981,23 @@ class diaspora { return true; } + /** + * @brief Fetch the uri from our database if we already have this item (maybe from ourselves) + * + * @param string $author Author handle + * @param string $guid Message guid + * + * @return string The constructed uri or the one from our database + */ + private function get_uri_from_guid($author, $guid) { + + $r = q("SELECT `uri` FROM `item` WHERE `guid` = '%s' LIMIT 1", dbesc($guid)); + if ($r) + return $r[0]["uri"]; + else + return $author.":".$guid; + } + /** * @brief Processes an incoming comment * @@ -1033,7 +1050,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = $author.":".$guid; + $datarray["uri"] = self::get_uri_from_guid($author, $guid); $datarray["type"] = "remote-comment"; $datarray["verb"] = ACTIVITY_POST; @@ -1370,7 +1387,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = $author.":".$guid; + $datarray["uri"] = self::get_uri_from_guid($author, $guid); $datarray["type"] = "activity"; $datarray["verb"] = $verb; @@ -1969,7 +1986,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; + $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; @@ -2171,7 +2188,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; + $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; From 40a44f15716abde7de658557a5738d251b642408 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 20 Jun 2016 22:48:09 +0200 Subject: [PATCH 2/3] Some manual revert ... --- include/diaspora.php | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 84aed8147..2ff7a90cf 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -981,23 +981,6 @@ class diaspora { return true; } - /** - * @brief Fetch the uri from our database if we already have this item (maybe from ourselves) - * - * @param string $author Author handle - * @param string $guid Message guid - * - * @return string The constructed uri or the one from our database - */ - private function get_uri_from_guid($author, $guid) { - - $r = q("SELECT `uri` FROM `item` WHERE `guid` = '%s' LIMIT 1", dbesc($guid)); - if ($r) - return $r[0]["uri"]; - else - return $author.":".$guid; - } - /** * @brief Processes an incoming comment * @@ -1050,7 +1033,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = self::get_uri_from_guid($author, $guid); + $datarray["uri"] = $author.":".$guid; $datarray["type"] = "remote-comment"; $datarray["verb"] = ACTIVITY_POST; @@ -1387,7 +1370,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = self::get_uri_from_guid($author, $guid); + $datarray["uri"] = $author.":".$guid; $datarray["type"] = "activity"; $datarray["verb"] = $verb; @@ -1986,7 +1969,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); + $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; @@ -2188,7 +2171,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); + $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; From a6573776160f1911784252f1ad960178d403f8ed Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 20 Jun 2016 22:48:55 +0200 Subject: [PATCH 3/3] Diaspora: Try to fetch the uri if we already received the message --- include/diaspora.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/include/diaspora.php b/include/diaspora.php index 2ff7a90cf..84aed8147 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -981,6 +981,23 @@ class diaspora { return true; } + /** + * @brief Fetch the uri from our database if we already have this item (maybe from ourselves) + * + * @param string $author Author handle + * @param string $guid Message guid + * + * @return string The constructed uri or the one from our database + */ + private function get_uri_from_guid($author, $guid) { + + $r = q("SELECT `uri` FROM `item` WHERE `guid` = '%s' LIMIT 1", dbesc($guid)); + if ($r) + return $r[0]["uri"]; + else + return $author.":".$guid; + } + /** * @brief Processes an incoming comment * @@ -1033,7 +1050,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = $author.":".$guid; + $datarray["uri"] = self::get_uri_from_guid($author, $guid); $datarray["type"] = "remote-comment"; $datarray["verb"] = ACTIVITY_POST; @@ -1370,7 +1387,7 @@ class diaspora { $datarray["owner-avatar"] = ((x($contact,"thumb")) ? $contact["thumb"] : $contact["photo"]); $datarray["guid"] = $guid; - $datarray["uri"] = $author.":".$guid; + $datarray["uri"] = self::get_uri_from_guid($author, $guid); $datarray["type"] = "activity"; $datarray["verb"] = $verb; @@ -1969,7 +1986,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; + $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT; @@ -2171,7 +2188,7 @@ class diaspora { $datarray["owner-avatar"] = $datarray["author-avatar"]; $datarray["guid"] = $guid; - $datarray["uri"] = $datarray["parent-uri"] = $author.":".$guid; + $datarray["uri"] = $datarray["parent-uri"] = self::get_uri_from_guid($author, $guid); $datarray["verb"] = ACTIVITY_POST; $datarray["gravity"] = GRAVITY_PARENT;