*/
class Diaspora {
- private static $new = false;
-
/**
* @brief Return a list of relay servers
*
*/
private static function build_message($msg, $user, $contact, $prvkey, $pubkey, $public = false) {
+ //$new = Config::get('system', 'new_diaspora', null, true);
+
if ($public)
$magic_env = self::build_public_message($msg,$user,$contact,$prvkey,$pubkey);
else
*/
public static function build_post_xml($type, $message) {
- if (!self::$new) {
- $data = array("XML" => array("post" => array($type => $message)));
- } else {
- $data = array($type => $message);
- }
+ $data = array($type => $message);
+
return xml::from_array($data, $xml);
}
*/
public static function send_share($owner,$contact) {
- $message = array("sender_handle" => self::my_handle($owner),
- "recipient_handle" => $contact["addr"]);
+ /// @todo support the different possible combinations of "following" and "sharing"
+ $message = array("author" => self::my_handle($owner),
+ "recipient" => $contact["addr"],
+ "following" => "true",
+ "sharing" => "true");
logger("Send share ".print_r($message, true), LOGGER_DEBUG);
- return self::build_and_transmit($owner, $contact, "request", $message);
+ return self::build_and_transmit($owner, $contact, "contact", $message);
}
/**
*/
public static function send_unshare($owner,$contact) {
- self::$new = true;
-
$message = array("author" => self::my_handle($owner),
"target_guid" => $owner["guid"],
"target_type" => "Person");
*/
public static function build_status($item, $owner) {
- self::$new = true;
-
$cachekey = "diaspora:build_status:".$item['guid'];
$result = Cache::get($cachekey);
$created = datetime_convert("UTC", "UTC", $item["created"], 'Y-m-d\TH:i:s\Z');
- //self::$new = Config::get('system', 'new_diaspora', null, true);
-
// Detect a share element and do a reshare
if (!$item['private'] && ($ret = self::is_reshare($item["body"]))) {
$message = array("author" => $myaddr,
*/
private static function construct_like($item, $owner) {
- self::$new = true;
-
$p = q("SELECT `guid`, `uri`, `parent-uri` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($item["thr-parent"]));
if (!dbm::is_result($p))
*/
private static function construct_attend($item, $owner) {
- self::$new = true;
-
$p = q("SELECT `guid`, `uri`, `parent-uri` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($item["thr-parent"]));
if (!dbm::is_result($p))
*/
private static function construct_comment($item, $owner) {
- self::$new = true;
-
$cachekey = "diaspora:construct_comment:".$item['guid'];
$result = Cache::get($cachekey);
$signed_parts = explode(";", $signature['signed_text']);
if ($item["deleted"])
- $message = array("parent_author_signature" => "",
+ $message = array("author" => $signature['signer'],
"target_guid" => $signed_parts[0],
- "target_type" => $signed_parts[1],
- "sender_handle" => $signature['signer'],
- "target_author_signature" => $signature['signature']);
+ "target_type" => $signed_parts[1]);
elseif ($item['verb'] === ACTIVITY_LIKE)
- $message = array("positive" => $signed_parts[0],
+ $message = array("author" => $signed_parts[4],
"guid" => $signed_parts[1],
- "target_type" => $signed_parts[2],
"parent_guid" => $signed_parts[3],
- "parent_author_signature" => "",
+ "parent_type" => $signed_parts[2],
+ "positive" => $signed_parts[0],
"author_signature" => $signature['signature'],
- "diaspora_handle" => $signed_parts[4]);
+ "parent_author_signature" => "");
else {
// Remove the comment guid
$guid = array_shift($signed_parts);
// Glue the parts together
$text = implode(";", $signed_parts);
- $message = array("guid" => $guid,
+ $message = array("author" => $handle,
+ "guid" => $guid,
"parent_guid" => $parent_guid,
- "parent_author_signature" => "",
- "author_signature" => $signature['signature'],
"text" => implode(";", $signed_parts),
- "diaspora_handle" => $handle);
+ "author_signature" => $signature['signature'],
+ "parent_author_signature" => "");
}
return $message;
}
if (is_array($msg)) {
foreach ($msg AS $field => $data) {
if (!$item["deleted"]) {
- if ($field == "author")
- $field = "diaspora_handle";
- if ($field == "parent_type")
- $field = "target_type";
+ if ($field == "diaspora_handle") {
+ $field = "author";
+ }
+ if ($field == "target_type") {
+ $field = "parent_type";
+ }
}
$message[$field] = $data;
*/
public static function send_retraction($item, $owner, $contact, $public_batch = false, $relay = false) {
- self::$new = true;
-
$itemaddr = self::handle_from_contact($item["contact-id"], $item["gcontact-id"]);
$msg_type = "retraction";
*/
public static function send_mail($item, $owner, $contact) {
- self::$new = true;
-
$myaddr = self::my_handle($owner);
$r = q("SELECT * FROM `conv` WHERE `id` = %d AND `uid` = %d LIMIT 1",
$tags = trim($tags);
}
- $message = array("diaspora_handle" => $handle,
+ $message = array("author" => $handle,
"first_name" => $first,
"last_name" => $last,
"image_url" => $large,
"bio" => $about,
"location" => $location,
"searchable" => $searchable,
+ "nsfw" => "false",
"tag_string" => $tags);
foreach ($recips as $recip) {