function diaspora_dispatch_public($msg) {
- $r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN ( SELECT `uid` FROM `contact` WHERE `network` = '%s' AND `addr` = '%s' ) ",
+ $r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN ( SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s' ) ",
dbesc(NETWORK_DIASPORA),
dbesc($msg['author'])
);
if(count($r)) {
foreach($r as $rr) {
+ logger('diaspora_public: delivering to: ' . $rr['username']);
diaspora_dispatch($rr,$msg);
}
}
+ else
+ logger('diaspora_public: no subscribers');
}
$outer_iv = random_string(16);
$b_outer_iv = base64_encode($outer_iv);
- $handle = 'acct:' . $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $handle = $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
$padded_data = pkcs5_pad($msg,16);
$inner_encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $padded_data, MCRYPT_MODE_CBC, $inner_iv);
$b64url_data = base64url_encode($b64_data);
$data = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data);
- $type = 'application/atom+xml';
+ $type = 'application/xml';
$encoding = 'base64url';
$alg = 'RSA-SHA256';
<decrypted_header>
<iv>$b_inner_iv</iv>
<aes_key>$b_inner_aes_key</aes_key>
- <author>
- <name>{$user['username']}</name>
- <uri>$handle</uri>
- </author>
+ <author_id>$handle</author_id>
</decrypted_header>
EOT;
$magic_env = <<< EOT
<?xml version='1.0' encoding='UTF-8'?>
-<entry xmlns='http://www.w3.org/2005/Atom'>
+<diaspora xmlns="https://joindiaspora.org/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env" >
$encrypted_header
- <me:env xmlns:me="http://salmon-protocol.org/ns/magic-env">
+ <me:env>
<me:encoding>base64url</me:encoding>
<me:alg>RSA-SHA256</me:alg>
<me:data type="application/xml">$data</me:data>
<me:sig>$sig</me:sig>
</me:env>
-</entry>
+</diaspora>
EOT;
logger('diaspora_msg_build: magic_env: ' . $magic_env, LOGGER_DATA);
$public = false;
$basedom = parse_xml_string($xml);
- $children = $basedom->children(NAMESPACE_DIASPORA_PROTOCOL);
+ $children = $basedom->children('https://joindiaspora.com/protocol');
if($children->header) {
$public = true;
- $author_link = str_replace('acct:','',$children->author_id);
+ $author_link = str_replace('acct:','',$children->header->author_id);
}
else {
// strip whitespace so our data element will return to one big base64 blob
$data = str_replace(array(" ","\t","\r","\n"),array("","","",""),$base->data);
- // Add back the 60 char linefeeds
-
- // This completely violates the entire principle of salmon magic signatures,
- // which was to have a message signing format that was completely ambivalent to linefeeds
- // and transport whitespace mangling, and base64 wrapping rules. Guess what? PHP and Ruby
- // use different linelengths for base64 output.
-
-// $lines = str_split($data,60);
- // $data = implode("\n",$lines);
-
// stash away some other stuff for later
if(! $verify) {
logger('mod-diaspora: Message did not verify. Discarding.');
- http_status_exit(400);
+// http_status_exit(400);
}
logger('mod-diaspora: Message verified.');