- if ($item['deleted'])
- ; // Relayed Retraction
- elseif($item['verb'] === ACTIVITY_LIKE)
- $msg = self::construct_like($item, $owner, $contact, $public_batch, $data);
- else
- $msg = self::construct_comment($item, $owner, $contact, $public_batch, $data);
-die($msg);
-
- logger('base message: '.$msg, LOGGER_DATA);
- 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;
- }
-
-/*
- // Diaspora doesn't support threaded comments, but some
- // versions of Diaspora (i.e. Diaspora-pistos) support
- // likes on comments
- if($item['verb'] === ACTIVITY_LIKE && $item['thr-parent']) {
- $p = q("select guid, type, uri, `parent-uri` from item where uri = '%s' limit 1",
- dbesc($item['thr-parent'])
- );
- }
- else {
- // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
- // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
- // The only item with `parent` and `id` as the parent id is the parent item.
- $p = q("select guid, type, uri, `parent-uri` from item where parent = %d and id = %d limit 1",
- intval($item['parent']),
- intval($item['parent'])
- );
- }
- if(count($p))
- $parent = $p[0];
- else
- return;
-
- $like = false;
- $relay_retract = false;
- $sql_sign_id = 'iid';
- if( $item['deleted']) {
- $relay_retract = true;
-
- $target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment');
-
- $sql_sign_id = 'retract_iid';
- $tpl = get_markup_template('diaspora_relayable_retraction.tpl');
- }
- elseif($item['verb'] === ACTIVITY_LIKE) {
- $like = true;
-
- $target_type = ( $parent['uri'] === $parent['parent-uri'] ? 'Post' : 'Comment');
-// $positive = (($item['deleted']) ? 'false' : 'true');
- $positive = 'true';
-
- $tpl = get_markup_template('diaspora_like_relay.tpl');
- }
- else { // item is a comment
- $tpl = get_markup_template('diaspora_comment_relay.tpl');
- }
-
-
- // fetch the original signature if the relayable was created by a Diaspora
- // or DFRN user. Relayables for other networks are not supported.
-
- $r = q("SELECT `signed_text`, `signature`, `signer` FROM `sign` WHERE " . $sql_sign_id . " = %d LIMIT 1",
- intval($item['id'])
- );
- if(count($r)) {
- $orig_sign = $r[0];
- $signed_text = $orig_sign['signed_text'];
- $authorsig = $orig_sign['signature'];
- $handle = $orig_sign['signer'];
-
- // Split the signed text
- $signed_parts = explode(";", $signed_text);
-
- // Remove the parent guid
- array_shift($signed_parts);
-
- // Remove the comment guid
- array_shift($signed_parts);
-
- // Remove the handle
- array_pop($signed_parts);
-
- // Glue the parts together
- $text = implode(";", $signed_parts);
- }
- else {
- // This part is meant for cases where we don't have the signatur. (Which shouldn't happen with posts from Diaspora and Friendica)
- // This means that the comment won't be accepted by newer Diaspora servers
-
- $body = $item['body'];
- $text = html_entity_decode(bb2diaspora($body));
-
- $handle = diaspora_handle_from_contact($item['contact-id']);
- if(! $handle)
- return;
-
- if($relay_retract)
- $signed_text = $item['guid'] . ';' . $target_type;
- elseif($like)
- $signed_text = $item['guid'] . ';' . $target_type . ';' . $parent['guid'] . ';' . $positive . ';' . $handle;
- else
- $signed_text = $item['guid'] . ';' . $parent['guid'] . ';' . $text . ';' . $handle;