From be7a01f086ad2bf3f4ed479f72366c3de64a056e Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 31 May 2021 19:39:50 +0000 Subject: [PATCH 1/2] Fix commenting on mobile to Diaspora --- mod/item.php | 7 ------- src/Model/Item.php | 9 ++++++++- src/Protocol/Diaspora.php | 7 ------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/mod/item.php b/mod/item.php index 71793f14d..b1973147c 100644 --- a/mod/item.php +++ b/mod/item.php @@ -713,13 +713,6 @@ function item_post(App $a) { unset($datarray['self']); unset($datarray['api_source']); - if ($origin) { - $signed = Diaspora::createCommentSignature($uid, $datarray); - if (!empty($signed)) { - $datarray['diaspora_signed_text'] = json_encode($signed); - } - } - $post_id = Item::insert($datarray); if (!$post_id) { diff --git a/src/Model/Item.php b/src/Model/Item.php index 0ca1138f9..7d0a2d026 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1060,7 +1060,14 @@ class Item Post\Content::insert($item['uri-id'], $item); } - // Diaspora signature + // Create Diaspora signature + if ($item['origin'] && empty($item['diaspora_signed_text'])) { + $signed = Diaspora::createCommentSignature($uid, $item); + if (!empty($signed)) { + $item['diaspora_signed_text'] = json_encode($signed); + } + } + if (!empty($item['diaspora_signed_text'])) { DBA::replace('diaspora-interaction', ['uri-id' => $item['uri-id'], 'interaction' => $item['diaspora_signed_text']]); } diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 00da7d391..ce11a8370 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -4049,13 +4049,6 @@ class Diaspora return false; } - $parent = Post::selectFirst(['parent-uri'], ['uri' => $item['thr-parent']]); - if (!DBA::isResult($parent)) { - return; - } - - $item['parent-uri'] = $parent['parent-uri']; - $message = self::constructComment($item, $owner); if ($message === false) { return false; From 58531a27483d13cf16edf0496f8b2f8cb8987129 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 31 May 2021 20:02:53 +0000 Subject: [PATCH 2/2] Fix tests --- src/Protocol/Diaspora.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index ce11a8370..586b6e9ec 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -4049,6 +4049,11 @@ class Diaspora return false; } + // This is only needed for the automated tests + if (empty($owner['uprvkey'])) { + return false; + } + $message = self::constructComment($item, $owner); if ($message === false) { return false;