Standards and documentation

This commit is contained in:
Michael 2017-05-04 05:11:19 +00:00
parent a9c263a375
commit 65823fe28f

View File

@ -380,6 +380,7 @@ class Diaspora {
* *
* @param array $importer Array of the importer user * @param array $importer Array of the importer user
* @param array $msg The post that will be dispatched * @param array $msg The post that will be dispatched
* @param object $fields SimpleXML object that contains the message
* *
* @return int The message id of the generated message, "true" or "false" if there was an error * @return int The message id of the generated message, "true" or "false" if there was an error
*/ */
@ -457,9 +458,8 @@ class Diaspora {
* It also does the conversion between the old and the new diaspora format. * It also does the conversion between the old and the new diaspora format.
* *
* @param array $msg Array with the XML, the sender handle and the sender signature * @param array $msg Array with the XML, the sender handle and the sender signature
* @param object $fields SimpleXML object that contains the posting when it is valid
* *
* @return bool Is the posting valid? * @return bool|array If the posting is valid then an array with an SimpleXML object is returned
*/ */
private static function valid_posting($msg) { private static function valid_posting($msg) {
@ -556,9 +556,9 @@ class Diaspora {
} }
// Only some message types have signatures. So we quit here for the other types. // Only some message types have signatures. So we quit here for the other types.
if (!in_array($type, array("comment", "message", "like"))) if (!in_array($type, array("comment", "message", "like"))) {
return array("fields" => $fields, "relayed" => false); return array("fields" => $fields, "relayed" => false);
}
// No author_signature? This is a must, so we quit. // No author_signature? This is a must, so we quit.
if (!isset($author_signature)) { if (!isset($author_signature)) {
logger("No author signature for type ".$type." - Message: ".$msg["message"], LOGGER_DEBUG); logger("No author signature for type ".$type." - Message: ".$msg["message"], LOGGER_DEBUG);
@ -583,9 +583,10 @@ class Diaspora {
if (!rsa_verify($signed_data, $author_signature, $key, "sha256")) { if (!rsa_verify($signed_data, $author_signature, $key, "sha256")) {
logger("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG); logger("No valid author signature for author ".$fields->author. " in type ".$type." - signed data: ".$signed_data." - Message: ".$msg["message"]." - Signature ".$author_signature, LOGGER_DEBUG);
return false; return false;
} else } else {
return array("fields" => $fields, "relayed" => $relayed); return array("fields" => $fields, "relayed" => $relayed);
} }
}
/** /**
* @brief Fetches the public key for a given handle * @brief Fetches the public key for a given handle