]> git.mxchange.org Git - friendica.git/commitdiff
The generated XML is now valid and it seems to work.
authorMichael Vogel <icarus@dabo.de>
Mon, 23 Nov 2015 22:49:14 +0000 (23:49 +0100)
committerMichael Vogel <icarus@dabo.de>
Mon, 23 Nov 2015 22:49:14 +0000 (23:49 +0100)
include/delivery.php
include/notifier.php
include/ostatus.php
include/salmon.php

index 851f633e6eec0e296b3ab1540e42b54852854212..dc02faaba8e03d1957797861a6cd4a0ee9defa59 100644 (file)
@@ -392,8 +392,8 @@ function delivery_run(&$argv, &$argc){
                                                        continue;
 
                                                if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
-                                                       //$slaps[] = ostatus_salmon($item,$owner);
-                                                       $slaps[] = atom_entry($item,'html',null,$owner,true);
+                                                       $slaps[] = ostatus_salmon($item,$owner);
+                                                       //$slaps[] = atom_entry($item,'html',null,$owner,true);
                                        }
 
                                        logger('notifier: slapdelivery: ' . $contact['name']);
index 52ec5765d07ca86704a093c64bf35ac92ec142ab..ec2b666bede9109304020a3bc3993c66abe7ea03 100644 (file)
@@ -530,8 +530,8 @@ function notifier_run(&$argv, &$argc){
                unset($photos);
        } else {
 
-               //$slap = ostatus_salmon($target_item,$owner);
-               $slap = atom_entry($target_item,'html',null,$owner,false);
+               $slap = ostatus_salmon($target_item,$owner);
+               //$slap = atom_entry($target_item,'html',null,$owner,false);
 
                if($followup) {
                        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);
 
                                if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
-                                       //$slaps[] = ostatus_salmon($item,$owner);
-                                       $slaps[] = atom_entry($item,'html',null,$owner,true);
+                                       $slaps[] = ostatus_salmon($item,$owner);
+                                       //$slaps[] = atom_entry($item,'html',null,$owner,true);
                        }
                }
        }
index 2a252b947ca25beb5af3dd9d3b7ca074f49ca093..875e1527e29103a8c19fa53531361f6256c36ed5 100644 (file)
@@ -1078,11 +1078,11 @@ function ostatus_store_conversation($itemid, $conversation_url) {
 }
 
 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) {
                $attribute = $doc->createAttribute($key);
-               $attribute->value = $value;
+               $attribute->value = xmlify($value);
                $element->appendChild($attribute);
        }
 
@@ -1093,7 +1093,7 @@ function ostatus_add_header($doc, $owner) {
        $a = get_app();
 
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`",
-               intval($owner["user_uid"]));
+               intval($owner["uid"]));
        if (!$r)
                return;
 
@@ -1102,13 +1102,13 @@ function ostatus_add_header($doc, $owner) {
        $root = $doc->createElementNS(NS_ATOM, 'feed');
        $doc->appendChild($root);
 
-       $root->setAttributeNS(NS_ATOM, "xmlns:thr", NS_THR);
-       $root->setAttributeNS(NS_ATOM, "xmlns:georss", NS_GEORSS);
-       $root->setAttributeNS(NS_ATOM, "xmlns:activity", NS_ACTIVITY);
-       $root->setAttributeNS(NS_ATOM, "xmlns:media", NS_MEDIA);
-       $root->setAttributeNS(NS_ATOM, "xmlns:poco", NS_POCO);
-       $root->setAttributeNS(NS_ATOM, "xmlns:ostatus", NS_OSTATUS);
-       $root->setAttributeNS(NS_ATOM, "xmlns:statusnet", NS_STATUSNET);
+       $root->setAttribute("xmlns:thr", NS_THR);
+       $root->setAttribute("xmlns:georss", NS_GEORSS);
+       $root->setAttribute("xmlns:activity", NS_ACTIVITY);
+       $root->setAttribute("xmlns:media", NS_MEDIA);
+       $root->setAttribute("xmlns:poco", NS_POCO);
+       $root->setAttribute("xmlns:ostatus", NS_OSTATUS);
+       $root->setAttribute("xmlns:statusnet", NS_STATUSNET);
 
        $attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
        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, "statusnet:profile_info", "", array("local_id" => $owner["user_uid"]));
+       xml_add_element($doc, $author, "statusnet:profile_info", "", array("local_id" => $owner["uid"]));
 
        return $author;
 }
@@ -1283,16 +1283,16 @@ function ostatus_entry($doc, $item, $owner, $toplevel = false) {
        } else {
                $entry = $doc->createElementNS(NS_ATOM, "entry");
 
-               $entry->setAttributeNS(NS_ATOM, "xmlns:thr", NS_THR);
-               $entry->setAttributeNS(NS_ATOM, "xmlns:georss", NS_GEORSS);
-               $entry->setAttributeNS(NS_ATOM, "xmlns:activity", NS_ACTIVITY);
-               $entry->setAttributeNS(NS_ATOM, "xmlns:media", NS_MEDIA);
-               $entry->setAttributeNS(NS_ATOM, "xmlns:poco", NS_POCO);
-               $entry->setAttributeNS(NS_ATOM, "xmlns:ostatus", NS_OSTATUS);
-               $entry->setAttributeNS(NS_ATOM, "xmlns:statusnet", NS_STATUSNET);
+               $entry->setAttribute("xmlns:thr", NS_THR);
+               $entry->setAttribute("xmlns:georss", NS_GEORSS);
+               $entry->setAttribute("xmlns:activity", NS_ACTIVITY);
+               $entry->setAttribute("xmlns:media", NS_MEDIA);
+               $entry->setAttribute("xmlns:poco", NS_POCO);
+               $entry->setAttribute("xmlns:ostatus", NS_OSTATUS);
+               $entry->setAttribute("xmlns:statusnet", NS_STATUSNET);
 
                $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default`",
-                       intval($owner["user_uid"]));
+                       intval($owner["uid"]));
                if (!$r)
                        return;
 
@@ -1317,6 +1317,7 @@ function ostatus_entry($doc, $item, $owner, $toplevel = false) {
                $body = "[b]".$item['title']."[/b]\n\n".$body;
 
        $body = bbcode($body, false, false, 7);
+
        xml_add_element($doc, $entry, "content", $body, array("type" => "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) {
 
-       $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`
                        WHERE `contact`.`self` AND `user`.`nickname` = '%s' LIMIT 1",
                        dbesc($owner_nick));
@@ -1413,7 +1414,7 @@ function ostatus_feed(&$a, $owner_nick, $last_update) {
                                AND (`item`.`owner-link` IN ('%s', '%s'))
                        ORDER BY `item`.`received` DESC
                        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($owner["nurl"]), dbesc(str_replace("http://", "https://", $owner["nurl"]))
                );
index 7574374907eabf3f4cca2789b5be712dfebadee5..a254fe7e97086953d4a8b1c607ad0e1feefd6b39 100644 (file)
@@ -66,8 +66,6 @@ function get_salmon_key($uri,$keyhash) {
 
 function slapper($owner,$url,$slap) {
 
-       logger('slapper called for '.$url.'. Data: ' . $slap);
-
        // does contact have a salmon endpoint?
 
        if(! strlen($url))
@@ -97,6 +95,8 @@ EOT;
 
        $slap = str_replace('<entry>',$namespaces,$slap);
 
+       logger('slapper called for '.$url.'. Data: ' . $slap);
+
        // create a magic envelope
 
        $data      = base64url_encode($slap);