From 66515ed85e61e9d566118018e65c76f62f56741e Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Sep 2017 04:24:47 +0000 Subject: [PATCH 1/2] Diaspora: Posts from Diaspora relais are transmitted the old way --- include/Smilies.php | 3 +++ include/diaspora.php | 5 +++++ mod/receive.php | 11 ++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/Smilies.php b/include/Smilies.php index d63511cd1..8d527d7c8 100644 --- a/include/Smilies.php +++ b/include/Smilies.php @@ -3,6 +3,9 @@ /** * @file include/Smilies.php * @brief This file contains the Smilies class which contains functions to handle smiles + * + * @todo Use the shortcodes from here: + * https://github.com/iamcal/emoji-data/blob/master/emoji_pretty.json?raw=true */ use Friendica\App; diff --git a/include/diaspora.php b/include/diaspora.php index cd857ba6b..f7dee831d 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -287,6 +287,11 @@ class Diaspora { $public = true; $author_link = str_replace('acct:','',$children->header->author_id); } else { + // This happens with posts from a relais + if (!$importer) { + logger("This is no private post in the old format", LOGGER_DEBUG); + return false; + } $encrypted_header = json_decode(base64_decode($children->encrypted_header)); diff --git a/mod/receive.php b/mod/receive.php index 8b28c1656..68fc7f69f 100644 --- a/mod/receive.php +++ b/mod/receive.php @@ -17,11 +17,11 @@ function receive_post(App $a) { http_status_exit(500); } - $public = false; - if (($a->argc == 2) && ($a->argv[1] === 'public')) { $public = true; + $importer = false; } else { + $public = false; if ($a->argc != 3 || $a->argv[1] !== 'users') { http_status_exit(500); @@ -49,8 +49,13 @@ function receive_post(App $a) { logger('mod-diaspora: message is in the new format', LOGGER_DEBUG); $msg = Diaspora::decode_raw($importer, $postdata); } else { - logger('mod-diaspora: message is in the old format', LOGGER_DEBUG); + logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG); $msg = Diaspora::decode($importer, $xml); + + if ($public && !$msg) { + logger('mod-diaspora: decode message in the new format', LOGGER_DEBUG); + $msg = Diaspora::decode_raw($importer, $xml); + } } logger('mod-diaspora: decoded', LOGGER_DEBUG); From 1aafb807434905e4b8cf166ea09d26ed8d760fee Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 25 Sep 2017 06:04:40 +0000 Subject: [PATCH 2/2] Added log information --- include/diaspora.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/diaspora.php b/include/diaspora.php index f7dee831d..5ecbfa4dc 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -227,7 +227,7 @@ class Diaspora { $basedom = parse_xml_string($xml); if (!is_object($basedom)) { - logger('Received data does not seem to be an XML. Discarding.'); + logger('Received data does not seem to be an XML. Discarding. '.$xml); http_status_exit(400); }