Merge pull request #3733 from annando/diaspora-relais

Diaspora: Posts from Diaspora relais are transmitted the old way
This commit is contained in:
Tobias Diekershoff 2017-09-25 10:23:58 +02:00 committed by GitHub
commit dc6593f418
3 changed files with 17 additions and 4 deletions

View File

@ -3,6 +3,9 @@
/** /**
* @file include/Smilies.php * @file include/Smilies.php
* @brief This file contains the Smilies class which contains functions to handle smiles * @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; use Friendica\App;

View File

@ -227,7 +227,7 @@ class Diaspora {
$basedom = parse_xml_string($xml); $basedom = parse_xml_string($xml);
if (!is_object($basedom)) { 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); http_status_exit(400);
} }
@ -287,6 +287,11 @@ class Diaspora {
$public = true; $public = true;
$author_link = str_replace('acct:','',$children->header->author_id); $author_link = str_replace('acct:','',$children->header->author_id);
} else { } 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)); $encrypted_header = json_decode(base64_decode($children->encrypted_header));

View File

@ -17,11 +17,11 @@ function receive_post(App $a) {
http_status_exit(500); http_status_exit(500);
} }
$public = false;
if (($a->argc == 2) && ($a->argv[1] === 'public')) { if (($a->argc == 2) && ($a->argv[1] === 'public')) {
$public = true; $public = true;
$importer = false;
} else { } else {
$public = false;
if ($a->argc != 3 || $a->argv[1] !== 'users') { if ($a->argc != 3 || $a->argv[1] !== 'users') {
http_status_exit(500); http_status_exit(500);
@ -49,8 +49,13 @@ function receive_post(App $a) {
logger('mod-diaspora: message is in the new format', LOGGER_DEBUG); logger('mod-diaspora: message is in the new format', LOGGER_DEBUG);
$msg = Diaspora::decode_raw($importer, $postdata); $msg = Diaspora::decode_raw($importer, $postdata);
} else { } 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); $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); logger('mod-diaspora: decoded', LOGGER_DEBUG);