Issue 5733: Changing relationship values does work now again with DFRN

This commit is contained in:
Michael 2018-09-06 09:20:45 +00:00
parent 8ac018813c
commit 6113fdc940
3 changed files with 42 additions and 11 deletions

View File

@ -182,7 +182,7 @@ function dfrn_notify_post(App $a) {
function dfrn_dispatch_public($postdata) function dfrn_dispatch_public($postdata)
{ {
$msg = Diaspora::decodeRaw([], $postdata); $msg = Diaspora::decodeRaw([], $postdata, true);
if (!$msg) { if (!$msg) {
// We have to fail silently to be able to hand it over to the salmon parser // We have to fail silently to be able to hand it over to the salmon parser
return false; return false;

View File

@ -367,13 +367,14 @@ class Diaspora
* *
* @param array $importer Array of the importer user * @param array $importer Array of the importer user
* @param string $raw raw post message * @param string $raw raw post message
* @param boolean $no_exit Don't do an http exit on error
* *
* @return array * @return array
* 'message' -> decoded Diaspora XML message * 'message' -> decoded Diaspora XML message
* 'author' -> author diaspora handle * 'author' -> author diaspora handle
* 'key' -> author public key (converted to pkcs#8) * 'key' -> author public key (converted to pkcs#8)
*/ */
public static function decodeRaw(array $importer, $raw) public static function decodeRaw(array $importer, $raw, $no_exit = false)
{ {
$data = json_decode($raw); $data = json_decode($raw);
@ -388,8 +389,12 @@ class Diaspora
if (!is_object($j_outer_key_bundle)) { if (!is_object($j_outer_key_bundle)) {
logger('Outer Salmon did not verify. Discarding.'); logger('Outer Salmon did not verify. Discarding.');
if ($no_exit) {
return false;
} else {
System::httpExit(400); System::httpExit(400);
} }
}
$outer_iv = base64_decode($j_outer_key_bundle->iv); $outer_iv = base64_decode($j_outer_key_bundle->iv);
$outer_key = base64_decode($j_outer_key_bundle->key); $outer_key = base64_decode($j_outer_key_bundle->key);
@ -403,8 +408,12 @@ class Diaspora
if (!is_object($basedom)) { if (!is_object($basedom)) {
logger('Received data does not seem to be an XML. Discarding. '.$xml); logger('Received data does not seem to be an XML. Discarding. '.$xml);
if ($no_exit) {
return false;
} else {
System::httpExit(400); System::httpExit(400);
} }
}
$base = $basedom->children(NAMESPACE_SALMON_ME); $base = $basedom->children(NAMESPACE_SALMON_ME);
@ -425,20 +434,32 @@ class Diaspora
$author_addr = base64_decode($key_id); $author_addr = base64_decode($key_id);
if ($author_addr == '') { if ($author_addr == '') {
logger('No author could be decoded. Discarding. Message: ' . $xml); logger('No author could be decoded. Discarding. Message: ' . $xml);
if ($no_exit) {
return false;
} else {
System::httpExit(400); System::httpExit(400);
} }
}
$key = self::key($author_addr); $key = self::key($author_addr);
if ($key == '') { if ($key == '') {
logger("Couldn't get a key for handle " . $author_addr . ". Discarding."); logger("Couldn't get a key for handle " . $author_addr . ". Discarding.");
if ($no_exit) {
return false;
} else {
System::httpExit(400); System::httpExit(400);
} }
}
$verify = Crypto::rsaVerify($signed_data, $signature, $key); $verify = Crypto::rsaVerify($signed_data, $signature, $key);
if (!$verify) { if (!$verify) {
logger('Message did not verify. Discarding.'); logger('Message did not verify. Discarding.');
if ($no_exit) {
return false;
} else {
System::httpExit(400); System::httpExit(400);
} }
}
return ['message' => (string)base64url_decode($base->data), return ['message' => (string)base64url_decode($base->data),
'author' => unxmlify($author_addr), 'author' => unxmlify($author_addr),

View File

@ -74,6 +74,16 @@ class OStatus
$author["contact-id"] = $contact["id"]; $author["contact-id"] = $contact["id"];
$contact = null; $contact = null;
/*
This here would be better, but we would get problems with contacts from the statusnet addon
This is kept here as a reminder for the future
$cid = Contact::getIdForURL($author["author-link"], $importer["uid"]);
if ($cid) {
$contact = DBA::selectFirst('contact', [], ['id' => $cid]);
}
*/
if ($aliaslink != '') { if ($aliaslink != '') {
$condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)", $condition = ["`uid` = ? AND `alias` = ? AND `network` != ? AND `rel` IN (?, ?)",
$importer["uid"], $aliaslink, Protocol::STATUSNET, $importer["uid"], $aliaslink, Protocol::STATUSNET,
@ -219,7 +229,7 @@ class OStatus
$gcid = GContact::update($contact); $gcid = GContact::update($contact);
GContact::link($gcid, $contact["uid"], $contact["id"]); GContact::link($gcid, $contact["uid"], $contact["id"]);
} else { } elseif ($contact["network"] != Protocol::DFRN) {
$contact = null; $contact = null;
} }
@ -312,7 +322,7 @@ class OStatus
self::$conv_list = []; self::$conv_list = [];
} }
logger("Import OStatus message", LOGGER_DEBUG); logger('Import OStatus message for user ' . $importer['uid'], LOGGER_DEBUG);
if ($xml == "") { if ($xml == "") {
return false; return false;