It should be now valid
This commit is contained in:
parent
c0669d365b
commit
2c7fd1cb3c
2 changed files with 25 additions and 8 deletions
|
@ -2242,7 +2242,7 @@ class diaspora {
|
||||||
*
|
*
|
||||||
* @return string the handle in the format user@domain.tld
|
* @return string the handle in the format user@domain.tld
|
||||||
*/
|
*/
|
||||||
private function my_handle($contact) {
|
function my_handle($contact) {
|
||||||
if ($contact["addr"] != "")
|
if ($contact["addr"] != "")
|
||||||
return $contact["addr"];
|
return $contact["addr"];
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ function fetch_init($a){
|
||||||
|
|
||||||
$guid = $a->argv[2];
|
$guid = $a->argv[2];
|
||||||
|
|
||||||
$item = q("SELECT `uid`, `title`, `body`, `guid`, `contact-id`, `private`, `created`, `app`, `location`
|
$item = q("SELECT `uid`, `title`, `body`, `guid`, `contact-id`, `private`, `created`, `app`, `location`, `coord`
|
||||||
FROM `item` WHERE `wall` AND NOT `private` AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1",
|
FROM `item` WHERE `wall` AND NOT `private` AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1",
|
||||||
dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA);
|
dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA);
|
||||||
if (!$item) {
|
if (!$item) {
|
||||||
|
@ -35,6 +35,18 @@ function fetch_init($a){
|
||||||
$post["public"] = (!$item[0]["private"] ? 'true':'false');
|
$post["public"] = (!$item[0]["private"] ? 'true':'false');
|
||||||
$post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
|
$post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
$location = array();
|
||||||
|
|
||||||
|
if ($item[0]["location"] != "")
|
||||||
|
$location["address"] = $item[0]["location"];
|
||||||
|
|
||||||
|
if ($item[0]["coord"] != "") {
|
||||||
|
$coord = explode(" ", $item[0]["coord"]);
|
||||||
|
$location["lat"] = $coord[0];
|
||||||
|
$location["lng"] = $coord[1];
|
||||||
|
}
|
||||||
|
|
||||||
$body = bb2diaspora($item[0]["body"]);
|
$body = bb2diaspora($item[0]["body"]);
|
||||||
|
|
||||||
if(strlen($item[0]["title"]))
|
if(strlen($item[0]["title"]))
|
||||||
|
@ -42,7 +54,7 @@ function fetch_init($a){
|
||||||
|
|
||||||
$nodename = "status_message";
|
$nodename = "status_message";
|
||||||
$post["raw_message"] = str_replace("&", "&", $body);
|
$post["raw_message"] = str_replace("&", "&", $body);
|
||||||
$post["location"] = $item[0]["location"];
|
$post["location"] = $location;
|
||||||
$post["guid"] = $item[0]["guid"];
|
$post["guid"] = $item[0]["guid"];
|
||||||
$post["diaspora_handle"] = diaspora::handle_from_contact($item[0]["contact-id"]);
|
$post["diaspora_handle"] = diaspora::handle_from_contact($item[0]["contact-id"]);
|
||||||
$post["public"] = (!$item[0]["private"] ? 'true':'false');
|
$post["public"] = (!$item[0]["private"] ? 'true':'false');
|
||||||
|
@ -53,7 +65,9 @@ function fetch_init($a){
|
||||||
$data = array("XML" => array("post" => array($nodename => $post)));
|
$data = array("XML" => array("post" => array($nodename => $post)));
|
||||||
$xml = xml::from_array($data, $xmlobj);
|
$xml = xml::from_array($data, $xmlobj);
|
||||||
|
|
||||||
$r = q("SELECT `guid`, `prvkey` FROM `user` WHERE `uid` = %d", intval($item[0]["uid"]));
|
$r = q("SELECT `user`.`prvkey`, `contact`.`addr`, `user`.`nickname`, `contact`.`nick` FROM `user`
|
||||||
|
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid`
|
||||||
|
WHERE `user`.`uid` = %d", intval($item[0]["uid"]));
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
|
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
|
||||||
killme();
|
killme();
|
||||||
|
@ -64,7 +78,7 @@ function fetch_init($a){
|
||||||
$b64url_data = base64url_encode($xml);
|
$b64url_data = base64url_encode($xml);
|
||||||
$data = str_replace(array("\n", "\r", " ", "\t"), array("", "", "", ""), $b64url_data);
|
$data = str_replace(array("\n", "\r", " ", "\t"), array("", "", "", ""), $b64url_data);
|
||||||
|
|
||||||
$key_id = base64url_encode($user["guid"]);
|
$key_id = base64url_encode(diaspora::my_handle($user));
|
||||||
$type = "application/xml";
|
$type = "application/xml";
|
||||||
$encoding = "base64url";
|
$encoding = "base64url";
|
||||||
$alg = "RSA-SHA256";
|
$alg = "RSA-SHA256";
|
||||||
|
@ -81,9 +95,12 @@ function fetch_init($a){
|
||||||
|
|
||||||
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
|
$namespaces = array("me" => "http://salmon-protocol.org/ns/magic-env");
|
||||||
|
|
||||||
$envelope = xml::from_array($xmldata, $xml, false, $namespaces);
|
//header("Content-Type: application/xml; charset=utf-8");
|
||||||
header("Content-Type: application/xml; charset=utf-8");
|
//echo $xml;
|
||||||
echo $envelope;
|
//killme();
|
||||||
|
|
||||||
|
$envelope = xml::from_array($xmldata, $xml, false, $namespaces);
|
||||||
|
header("Content-Type: application/magic-envelope+xml; charset=utf-8");
|
||||||
|
echo $envelope;
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue