The generated XML is now valid and it seems to work.
This commit is contained in:
parent
75f1a17f7e
commit
7d7e2e74f4
4 changed files with 30 additions and 29 deletions
|
@ -392,8 +392,8 @@ function delivery_run(&$argv, &$argc){
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
|
if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
|
||||||
//$slaps[] = ostatus_salmon($item,$owner);
|
$slaps[] = ostatus_salmon($item,$owner);
|
||||||
$slaps[] = atom_entry($item,'html',null,$owner,true);
|
//$slaps[] = atom_entry($item,'html',null,$owner,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('notifier: slapdelivery: ' . $contact['name']);
|
logger('notifier: slapdelivery: ' . $contact['name']);
|
||||||
|
|
|
@ -530,8 +530,8 @@ function notifier_run(&$argv, &$argc){
|
||||||
unset($photos);
|
unset($photos);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//$slap = ostatus_salmon($target_item,$owner);
|
$slap = ostatus_salmon($target_item,$owner);
|
||||||
$slap = atom_entry($target_item,'html',null,$owner,false);
|
//$slap = atom_entry($target_item,'html',null,$owner,false);
|
||||||
|
|
||||||
if($followup) {
|
if($followup) {
|
||||||
foreach($items as $item) { // there is only one item
|
foreach($items as $item) { // there is only one item
|
||||||
|
@ -571,8 +571,8 @@ function notifier_run(&$argv, &$argc){
|
||||||
$atom .= atom_entry($item,'text',null,$owner,true);
|
$atom .= atom_entry($item,'text',null,$owner,true);
|
||||||
|
|
||||||
if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
|
if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
|
||||||
//$slaps[] = ostatus_salmon($item,$owner);
|
$slaps[] = ostatus_salmon($item,$owner);
|
||||||
$slaps[] = atom_entry($item,'html',null,$owner,true);
|
//$slaps[] = atom_entry($item,'html',null,$owner,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1078,11 +1078,11 @@ function ostatus_store_conversation($itemid, $conversation_url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function xml_add_element($doc, $parent, $element, $value = "", $attributes = array()) {
|
function xml_add_element($doc, $parent, $element, $value = "", $attributes = array()) {
|
||||||
$element = $doc->createElement($element, $value);
|
$element = $doc->createElement($element, xmlify($value));
|
||||||
|
|
||||||
foreach ($attributes AS $key => $value) {
|
foreach ($attributes AS $key => $value) {
|
||||||
$attribute = $doc->createAttribute($key);
|
$attribute = $doc->createAttribute($key);
|
||||||
$attribute->value = $value;
|
$attribute->value = xmlify($value);
|
||||||
$element->appendChild($attribute);
|
$element->appendChild($attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1093,7 +1093,7 @@ function ostatus_add_header($doc, $owner) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`",
|
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`",
|
||||||
intval($owner["user_uid"]));
|
intval($owner["uid"]));
|
||||||
if (!$r)
|
if (!$r)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1102,13 +1102,13 @@ function ostatus_add_header($doc, $owner) {
|
||||||
$root = $doc->createElementNS(NS_ATOM, 'feed');
|
$root = $doc->createElementNS(NS_ATOM, 'feed');
|
||||||
$doc->appendChild($root);
|
$doc->appendChild($root);
|
||||||
|
|
||||||
$root->setAttributeNS(NS_ATOM, "xmlns:thr", NS_THR);
|
$root->setAttribute("xmlns:thr", NS_THR);
|
||||||
$root->setAttributeNS(NS_ATOM, "xmlns:georss", NS_GEORSS);
|
$root->setAttribute("xmlns:georss", NS_GEORSS);
|
||||||
$root->setAttributeNS(NS_ATOM, "xmlns:activity", NS_ACTIVITY);
|
$root->setAttribute("xmlns:activity", NS_ACTIVITY);
|
||||||
$root->setAttributeNS(NS_ATOM, "xmlns:media", NS_MEDIA);
|
$root->setAttribute("xmlns:media", NS_MEDIA);
|
||||||
$root->setAttributeNS(NS_ATOM, "xmlns:poco", NS_POCO);
|
$root->setAttribute("xmlns:poco", NS_POCO);
|
||||||
$root->setAttributeNS(NS_ATOM, "xmlns:ostatus", NS_OSTATUS);
|
$root->setAttribute("xmlns:ostatus", NS_OSTATUS);
|
||||||
$root->setAttributeNS(NS_ATOM, "xmlns:statusnet", NS_STATUSNET);
|
$root->setAttribute("xmlns:statusnet", NS_STATUSNET);
|
||||||
|
|
||||||
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
|
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
|
||||||
xml_add_element($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
|
xml_add_element($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
|
||||||
|
@ -1269,7 +1269,7 @@ function ostatus_add_author($doc, $owner, $profile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
xml_add_element($doc, $author, "followers", "", array("url" => $a->get_baseurl()."/viewcontacts/".$owner["nick"]));
|
xml_add_element($doc, $author, "followers", "", array("url" => $a->get_baseurl()."/viewcontacts/".$owner["nick"]));
|
||||||
xml_add_element($doc, $author, "statusnet:profile_info", "", array("local_id" => $owner["user_uid"]));
|
xml_add_element($doc, $author, "statusnet:profile_info", "", array("local_id" => $owner["uid"]));
|
||||||
|
|
||||||
return $author;
|
return $author;
|
||||||
}
|
}
|
||||||
|
@ -1283,16 +1283,16 @@ function ostatus_entry($doc, $item, $owner, $toplevel = false) {
|
||||||
} else {
|
} else {
|
||||||
$entry = $doc->createElementNS(NS_ATOM, "entry");
|
$entry = $doc->createElementNS(NS_ATOM, "entry");
|
||||||
|
|
||||||
$entry->setAttributeNS(NS_ATOM, "xmlns:thr", NS_THR);
|
$entry->setAttribute("xmlns:thr", NS_THR);
|
||||||
$entry->setAttributeNS(NS_ATOM, "xmlns:georss", NS_GEORSS);
|
$entry->setAttribute("xmlns:georss", NS_GEORSS);
|
||||||
$entry->setAttributeNS(NS_ATOM, "xmlns:activity", NS_ACTIVITY);
|
$entry->setAttribute("xmlns:activity", NS_ACTIVITY);
|
||||||
$entry->setAttributeNS(NS_ATOM, "xmlns:media", NS_MEDIA);
|
$entry->setAttribute("xmlns:media", NS_MEDIA);
|
||||||
$entry->setAttributeNS(NS_ATOM, "xmlns:poco", NS_POCO);
|
$entry->setAttribute("xmlns:poco", NS_POCO);
|
||||||
$entry->setAttributeNS(NS_ATOM, "xmlns:ostatus", NS_OSTATUS);
|
$entry->setAttribute("xmlns:ostatus", NS_OSTATUS);
|
||||||
$entry->setAttributeNS(NS_ATOM, "xmlns:statusnet", NS_STATUSNET);
|
$entry->setAttribute("xmlns:statusnet", NS_STATUSNET);
|
||||||
|
|
||||||
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`",
|
$r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`",
|
||||||
intval($owner["user_uid"]));
|
intval($owner["uid"]));
|
||||||
if (!$r)
|
if (!$r)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1317,6 +1317,7 @@ function ostatus_entry($doc, $item, $owner, $toplevel = false) {
|
||||||
$body = "[b]".$item['title']."[/b]\n\n".$body;
|
$body = "[b]".$item['title']."[/b]\n\n".$body;
|
||||||
|
|
||||||
$body = bbcode($body, false, false, 7);
|
$body = bbcode($body, false, false, 7);
|
||||||
|
|
||||||
xml_add_element($doc, $entry, "content", $body, array("type" => "html"));
|
xml_add_element($doc, $entry, "content", $body, array("type" => "html"));
|
||||||
|
|
||||||
xml_add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
|
xml_add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
|
||||||
|
@ -1389,7 +1390,7 @@ function ostatus_entry($doc, $item, $owner, $toplevel = false) {
|
||||||
|
|
||||||
function ostatus_feed(&$a, $owner_nick, $last_update) {
|
function ostatus_feed(&$a, $owner_nick, $last_update) {
|
||||||
|
|
||||||
$r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`
|
$r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`timezone`, `user`.`page-flags`
|
||||||
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||||
WHERE `contact`.`self` AND `user`.`nickname` = '%s' LIMIT 1",
|
WHERE `contact`.`self` AND `user`.`nickname` = '%s' LIMIT 1",
|
||||||
dbesc($owner_nick));
|
dbesc($owner_nick));
|
||||||
|
@ -1413,7 +1414,7 @@ function ostatus_feed(&$a, $owner_nick, $last_update) {
|
||||||
AND (`item`.`owner-link` IN ('%s', '%s'))
|
AND (`item`.`owner-link` IN ('%s', '%s'))
|
||||||
ORDER BY `item`.`received` DESC
|
ORDER BY `item`.`received` DESC
|
||||||
LIMIT 0, 300",
|
LIMIT 0, 300",
|
||||||
intval($owner["user_uid"]), dbesc($check_date),
|
intval($owner["uid"]), dbesc($check_date),
|
||||||
dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_OSTATUS),
|
dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_OSTATUS),
|
||||||
dbesc($owner["nurl"]), dbesc(str_replace("http://", "https://", $owner["nurl"]))
|
dbesc($owner["nurl"]), dbesc(str_replace("http://", "https://", $owner["nurl"]))
|
||||||
);
|
);
|
||||||
|
|
|
@ -66,8 +66,6 @@ function get_salmon_key($uri,$keyhash) {
|
||||||
|
|
||||||
function slapper($owner,$url,$slap) {
|
function slapper($owner,$url,$slap) {
|
||||||
|
|
||||||
logger('slapper called for '.$url.'. Data: ' . $slap);
|
|
||||||
|
|
||||||
// does contact have a salmon endpoint?
|
// does contact have a salmon endpoint?
|
||||||
|
|
||||||
if(! strlen($url))
|
if(! strlen($url))
|
||||||
|
@ -97,6 +95,8 @@ EOT;
|
||||||
|
|
||||||
$slap = str_replace('<entry>',$namespaces,$slap);
|
$slap = str_replace('<entry>',$namespaces,$slap);
|
||||||
|
|
||||||
|
logger('slapper called for '.$url.'. Data: ' . $slap);
|
||||||
|
|
||||||
// create a magic envelope
|
// create a magic envelope
|
||||||
|
|
||||||
$data = base64url_encode($slap);
|
$data = base64url_encode($slap);
|
||||||
|
|
Loading…
Reference in a new issue