]> git.mxchange.org Git - friendica.git/commitdiff
Retraction could work now as well.
authorMichael Vogel <icarus@dabo.de>
Sun, 6 Mar 2016 00:37:47 +0000 (01:37 +0100)
committerMichael Vogel <icarus@dabo.de>
Sun, 6 Mar 2016 00:37:47 +0000 (01:37 +0100)
include/diaspora2.php
include/xml.php
view/templates/diaspora_relay_retraction.tpl

index 197cb1da11541de1f53bc8f90c939045039246bb..c745ab8366513a75e6a6a5e0f5f42597a4eb6f9f 100644 (file)
@@ -2031,6 +2031,40 @@ EOT;
                return $return_code;
        }
 
+       function send_retraction($item, $owner, $contact, $public_batch = false) {
+
+               $myaddr = self::get_my_handle($owner);
+
+               // Check whether the retraction is for a top-level post or whether it's a relayable
+               if ($item["uri"] !== $item["parent-uri"]) {
+                       $msg_type = "relayable_retraction";
+                       $target_type = (($item["verb"] === ACTIVITY_LIKE) ? "Like" : "Comment");
+               } else {
+                       $msg_type = "signed_retraction";
+                       $target_type = "StatusMessage";
+               }
+
+               $signed_text = $item["guid"].";".$target_type;
+
+               $message = array("target_guid" => $item['guid'],
+                               "target_type" => $target_type,
+                               "sender_handle" => $myaddr,
+                               "target_author_signature" => base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256')));
+
+               $data = array("XML" => array("post" => array($msg_type => $message)));
+               $msg = xml::from_array($data, $xml);
+
+               logger("send guid ".$item["guid"], LOGGER_DEBUG);
+
+               $slap = self::build_message($msg, $owner, $contact, $owner["uprvkey"], $contact["pubkey"], $public_batch);
+
+               $return_code = self::transmit($owner, $contact, $slap, $public_batch, false, $item["guid"]);
+
+               logger("guid: ".$item["guid"]." result ".$return_code, LOGGER_DEBUG);
+
+               return $return_code;
+       }
+
        function send_mail($item,$owner,$contact) {
 
                $myaddr = self::get_my_handle($owner);
index e46f53acc05066967e919908dc1a7e5a7437da85..9c458dab12da0a4e1d0ab158a23cee6924479dda 100644 (file)
@@ -20,7 +20,7 @@ class xml {
 
                foreach($array as $key => $value) {
                        if (!is_array($value) AND !is_numeric($key))
-                               $xml->addChild($key, $value);
+                               $xml->addChild($key, xmlify($value));
                        elseif (is_array($value))
                                self::from_array($value, $xml->addChild($key));
                }
index b3f97a2e13b0a367c5ff302b2f0fd8bf6d792834..c4b44cd05fc48e294568018d2daefbea4e11fb4e 100644 (file)
@@ -1,11 +1,10 @@
-
 <XML>
   <post>
     <relayable_retraction>
-      <target_type>{{$type}}</target_type>
       <target_guid>{{$guid}}</target_guid>
-      <target_author_signature>{{$signature}}</target_author_signature>
+      <target_type>{{$type}}</target_type>
       <sender_handle>{{$handle}}</sender_handle>
+      <target_author_signature>{{$signature}}</target_author_signature>
     </relayable_retraction>
   </post>
 </XML>