another round of heavy lifting
This commit is contained in:
parent
69d3e5468d
commit
1abd2a2917
@ -126,19 +126,17 @@ function diaspora_is_blacklisted($s) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function diaspora_handle_from_contact($contact_id) {
|
function diaspora_handle_from_contact($contact_hash) {
|
||||||
$handle = false;
|
|
||||||
|
|
||||||
logger("diaspora_handle_from_contact: contact id is " . $contact_id, LOGGER_DEBUG);
|
logger("diaspora_handle_from_contact: contact id is " . $contact_hash, LOGGER_DEBUG);
|
||||||
|
|
||||||
$r = q("SELECT * from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d",
|
$r = q("SELECT * from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' limit 1",
|
||||||
intval($contact_id)
|
intval($contact_hash)
|
||||||
);
|
);
|
||||||
if($r) {
|
if($r) {
|
||||||
$contact = $r[0];
|
return $r[0]['xchan_addr'];
|
||||||
}
|
}
|
||||||
$handle = $contact['xchan_addr'];
|
return false;
|
||||||
return $handle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function diaspora_get_contact_by_handle($uid,$handle) {
|
function diaspora_get_contact_by_handle($uid,$handle) {
|
||||||
@ -150,9 +148,7 @@ function diaspora_get_contact_by_handle($uid,$handle) {
|
|||||||
dbesc($handle),
|
dbesc($handle),
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
if($r)
|
return (($r) ? $r[0] : false);
|
||||||
return $r[0];
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_diaspora_person_by_handle($handle) {
|
function find_diaspora_person_by_handle($handle) {
|
||||||
@ -188,6 +184,7 @@ function find_diaspora_person_by_handle($handle) {
|
|||||||
$result = discover_by_webbie($handle);
|
$result = discover_by_webbie($handle);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -195,13 +192,10 @@ function find_diaspora_person_by_handle($handle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_diaspora_key($uri) {
|
function get_diaspora_key($handle) {
|
||||||
logger('Fetching diaspora key for: ' . $uri);
|
logger('Fetching diaspora key for: ' . $handle, LOGGER_DEBUG);
|
||||||
|
$r = find_diaspora_person_by_handle($handle);
|
||||||
$r = find_diaspora_person_by_handle($uri);
|
return(($r) ? $r['xchan_pubkey'] : '');
|
||||||
if($r)
|
|
||||||
return $r['pubkey'];
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -376,7 +370,7 @@ function diaspora_decode($importer,$xml) {
|
|||||||
$ciphertext = base64_decode($encrypted_header->ciphertext);
|
$ciphertext = base64_decode($encrypted_header->ciphertext);
|
||||||
|
|
||||||
$outer_key_bundle = '';
|
$outer_key_bundle = '';
|
||||||
openssl_private_decrypt($encrypted_aes_key_bundle,$outer_key_bundle,$importer['prvkey']);
|
openssl_private_decrypt($encrypted_aes_key_bundle,$outer_key_bundle,$importer['channel_prvkey']);
|
||||||
|
|
||||||
$j_outer_key_bundle = json_decode($outer_key_bundle);
|
$j_outer_key_bundle = json_decode($outer_key_bundle);
|
||||||
|
|
||||||
@ -454,7 +448,6 @@ function diaspora_decode($importer,$xml) {
|
|||||||
$encoding = $base->encoding;
|
$encoding = $base->encoding;
|
||||||
$alg = $base->alg;
|
$alg = $base->alg;
|
||||||
|
|
||||||
|
|
||||||
$signed_data = $data . '.' . base64url_encode($type) . '.' . base64url_encode($encoding) . '.' . base64url_encode($alg);
|
$signed_data = $data . '.' . base64url_encode($type) . '.' . base64url_encode($encoding) . '.' . base64url_encode($alg);
|
||||||
|
|
||||||
|
|
||||||
@ -606,15 +599,14 @@ function diaspora_request($importer,$xml) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME
|
/** If there is a default group for this channel, add this member to it */
|
||||||
// $g = q("select def_gid from user where uid = %d limit 1",
|
|
||||||
// intval($importer['channel_id'])
|
|
||||||
// );
|
|
||||||
// if($g && intval($g[0]['def_gid'])) {
|
|
||||||
// require_once('include/group.php');
|
|
||||||
// group_add_member($importer['channel_id'],'',$contact_record['id'],$g[0]['def_gid']);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
if($importer['channel_default_group']) {
|
||||||
|
require_once('include/group.php');
|
||||||
|
$g = group_rec_byhash($importer['channel_id'],$importer['channel_default_group']);
|
||||||
|
if($g)
|
||||||
|
group_add_member($importer['channel_id'],'',$contact_record['xchan_hash'],$g['id']);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -706,9 +698,6 @@ function diaspora_post($importer,$xml,$msg) {
|
|||||||
$datarray['uid'] = $importer['channel_id'];
|
$datarray['uid'] = $importer['channel_id'];
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
$datarray['contact-id'] = $contact['id'];
|
|
||||||
$datarray['wall'] = 0;
|
|
||||||
$datarray['network'] = NETWORK_DIASPORA;
|
|
||||||
|
|
||||||
|
|
||||||
$datarray['verb'] = ACTIVITY_POST;
|
$datarray['verb'] = ACTIVITY_POST;
|
||||||
@ -717,7 +706,6 @@ function diaspora_post($importer,$xml,$msg) {
|
|||||||
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
|
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
|
||||||
$datarray['item_private'] = $private;
|
$datarray['item_private'] = $private;
|
||||||
|
|
||||||
|
|
||||||
$datarray['plink'] = $plink;
|
$datarray['plink'] = $plink;
|
||||||
|
|
||||||
$datarray['author_xchan'] = $contact['xchan_hash'];
|
$datarray['author_xchan'] = $contact['xchan_hash'];
|
||||||
@ -2055,8 +2043,8 @@ function diaspora_profile($importer,$xml,$msg) {
|
|||||||
|
|
||||||
function diaspora_share($me,$contact) {
|
function diaspora_share($me,$contact) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$myaddr = $me['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
|
$myaddr = $me['channel_address'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
|
||||||
$theiraddr = $contact['addr'];
|
$theiraddr = $contact['xchan_addr'];
|
||||||
|
|
||||||
$tpl = get_markup_template('diaspora_share.tpl');
|
$tpl = get_markup_template('diaspora_share.tpl');
|
||||||
$msg = replace_macros($tpl, array(
|
$msg = replace_macros($tpl, array(
|
||||||
@ -2093,8 +2081,8 @@ function diaspora_unshare($me,$contact) {
|
|||||||
function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
|
function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
|
$myaddr = $owner['channel_address'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
|
||||||
$theiraddr = $contact['addr'];
|
$theiraddr = $contact['xchan_addr'];
|
||||||
|
|
||||||
$images = array();
|
$images = array();
|
||||||
|
|
||||||
@ -2146,44 +2134,44 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$public = (($item['private']) ? 'false' : 'true');
|
$public = (($item['item_private']) ? 'false' : 'true');
|
||||||
|
|
||||||
require_once('include/datetime.php');
|
require_once('include/datetime.php');
|
||||||
$created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
|
$created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
|
||||||
|
|
||||||
// Detect a share element and do a reshare
|
// Detect a share element and do a reshare
|
||||||
// see: https://github.com/Raven24/diaspora-federation/blob/master/lib/diaspora-federation/entities/reshare.rb
|
// see: https://github.com/Raven24/diaspora-federation/blob/master/lib/diaspora-federation/entities/reshare.rb
|
||||||
if (!$item['private'] AND ($ret = diaspora_is_reshare($item["body"]))) {
|
if (!$item['item_private'] AND ($ret = diaspora_is_reshare($item["body"]))) {
|
||||||
$tpl = get_markup_template('diaspora_reshare.tpl');
|
$tpl = get_markup_template('diaspora_reshare.tpl');
|
||||||
$msg = replace_macros($tpl, array(
|
$msg = replace_macros($tpl, array(
|
||||||
'$root_handle' => xmlify($ret['root_handle']),
|
'$root_handle' => xmlify($ret['root_handle']),
|
||||||
'$root_guid' => $ret['root_guid'],
|
'$root_guid' => $ret['root_guid'],
|
||||||
'$guid' => $item['guid'],
|
'$guid' => $item['mid'],
|
||||||
'$handle' => xmlify($myaddr),
|
'$handle' => xmlify($myaddr),
|
||||||
'$public' => $public,
|
'$public' => $public,
|
||||||
'$created' => $created,
|
'$created' => $created,
|
||||||
'$provider' => $item["app"]
|
'$provider' => $item['app']
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
$tpl = get_markup_template('diaspora_post.tpl');
|
$tpl = get_markup_template('diaspora_post.tpl');
|
||||||
$msg = replace_macros($tpl, array(
|
$msg = replace_macros($tpl, array(
|
||||||
'$body' => $body,
|
'$body' => $body,
|
||||||
'$guid' => $item['guid'],
|
'$guid' => $item['mid'],
|
||||||
'$handle' => xmlify($myaddr),
|
'$handle' => xmlify($myaddr),
|
||||||
'$public' => $public,
|
'$public' => $public,
|
||||||
'$created' => $created,
|
'$created' => $created,
|
||||||
'$provider' => $item["app"]
|
'$provider' => $item['app']
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('diaspora_send_status: '.$owner['username'].' -> '.$contact['name'].' base message: '.$msg, LOGGER_DATA);
|
logger('diaspora_send_status: '.$owner['channel_name'].' -> '.$contact['xchan_name'].' base message: '.$msg, LOGGER_DATA);
|
||||||
|
|
||||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
|
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['channel_prvkey'],$contact['xchan_pubkey'],$public_batch)));
|
||||||
//$slap = 'xml=' . urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch));
|
//$slap = 'xml=' . urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch));
|
||||||
|
|
||||||
$return_code = diaspora_transmit($owner,$contact,$slap,$public_batch);
|
$return_code = diaspora_transmit($owner,$contact,$slap,$public_batch);
|
||||||
|
|
||||||
logger('diaspora_send_status: guid: '.$item['guid'].' result '.$return_code, LOGGER_DEBUG);
|
logger('diaspora_send_status: guid: '.$item['mid'].' result '.$return_code, LOGGER_DEBUG);
|
||||||
|
|
||||||
if(count($images)) {
|
if(count($images)) {
|
||||||
diaspora_send_images($item,$owner,$contact,$images,$public_batch);
|
diaspora_send_images($item,$owner,$contact,$images,$public_batch);
|
||||||
@ -2193,15 +2181,16 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function diaspora_is_reshare($body) {
|
function diaspora_is_reshare($body) {
|
||||||
|
|
||||||
$body = trim($body);
|
$body = trim($body);
|
||||||
|
|
||||||
// Skip if it isn't a pure repeated messages
|
// Skip if it isn't a pure repeated messages
|
||||||
// Does it start with a share?
|
// Does it start with a share?
|
||||||
if (strpos($body, "[share") > 0)
|
if(strpos($body, "[share") > 0)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
// Does it end with a share?
|
// Does it end with a share?
|
||||||
if (strlen($body) > (strrpos($body, "[/share]") + 8))
|
if(strlen($body) > (strrpos($body, "[/share]") + 8))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
|
$attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
|
||||||
@ -2253,18 +2242,18 @@ function diaspora_send_images($item,$owner,$contact,$images,$public_batch = fals
|
|||||||
$resource = str_replace('.jpg','',$image['file']);
|
$resource = str_replace('.jpg','',$image['file']);
|
||||||
$resource = substr($resource,0,strpos($resource,'-'));
|
$resource = substr($resource,0,strpos($resource,'-'));
|
||||||
|
|
||||||
$r = q("select * from photo where `resource-id` = '%s' and `uid` = %d limit 1",
|
$r = q("select * from photo where `resource_id` = '%s' and `uid` = %d limit 1",
|
||||||
dbesc($resource),
|
dbesc($resource),
|
||||||
intval($owner['uid'])
|
intval($owner['uid'])
|
||||||
);
|
);
|
||||||
if(! count($r))
|
if(! $r)
|
||||||
continue;
|
continue;
|
||||||
$public = (($r[0]['allow_cid'] || $r[0]['allow_gid'] || $r[0]['deny_cid'] || $r[0]['deny_gid']) ? 'false' : 'true' );
|
$public = (($r[0]['allow_cid'] || $r[0]['allow_gid'] || $r[0]['deny_cid'] || $r[0]['deny_gid']) ? 'false' : 'true' );
|
||||||
$msg = replace_macros($tpl,array(
|
$msg = replace_macros($tpl,array(
|
||||||
'$path' => xmlify($image['path']),
|
'$path' => xmlify($image['path']),
|
||||||
'$filename' => xmlify($image['file']),
|
'$filename' => xmlify($image['file']),
|
||||||
'$msg_guid' => xmlify($image['guid']),
|
'$msg_guid' => xmlify($image['guid']),
|
||||||
'$guid' => xmlify($r[0]['guid']),
|
'$guid' => xmlify($r[0]['resource_id']),
|
||||||
'$handle' => xmlify($image['handle']),
|
'$handle' => xmlify($image['handle']),
|
||||||
'$public' => xmlify($public),
|
'$public' => xmlify($public),
|
||||||
'$created_at' => xmlify(datetime_convert('UTC','UTC',$r[0]['created'],'Y-m-d H:i:s \U\T\C'))
|
'$created_at' => xmlify(datetime_convert('UTC','UTC',$r[0]['created'],'Y-m-d H:i:s \U\T\C'))
|
||||||
@ -2272,7 +2261,7 @@ function diaspora_send_images($item,$owner,$contact,$images,$public_batch = fals
|
|||||||
|
|
||||||
|
|
||||||
logger('diaspora_send_photo: base message: ' . $msg, LOGGER_DATA);
|
logger('diaspora_send_photo: base message: ' . $msg, LOGGER_DATA);
|
||||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
|
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['channel_prvkey'],$contact['xchan_pubkey'],$public_batch)));
|
||||||
//$slap = 'xml=' . urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch));
|
//$slap = 'xml=' . urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch));
|
||||||
|
|
||||||
diaspora_transmit($owner,$contact,$slap,$public_batch);
|
diaspora_transmit($owner,$contact,$slap,$public_batch);
|
||||||
@ -2283,27 +2272,27 @@ function diaspora_send_images($item,$owner,$contact,$images,$public_batch = fals
|
|||||||
function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
|
function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
|
$myaddr = $owner['channel_address'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
|
||||||
// $theiraddr = $contact['addr'];
|
$theiraddr = $contact['xchan_addr'];
|
||||||
|
|
||||||
// Diaspora doesn't support threaded comments, but some
|
// Diaspora doesn't support threaded comments, but some
|
||||||
// versions of Diaspora (i.e. Diaspora-pistos) support
|
// versions of Diaspora (i.e. Diaspora-pistos) support
|
||||||
// likes on comments
|
// likes on comments
|
||||||
if($item['verb'] === ACTIVITY_LIKE && $item['thr-parent']) {
|
if($item['verb'] === ACTIVITY_LIKE && $item['thr_parent']) {
|
||||||
$p = q("select guid, type, uri, `parent-uri` from item where uri = '%s' limit 1",
|
$p = q("select mid, parent_mid from item where mid = '%s' limit 1",
|
||||||
dbesc($item['thr-parent'])
|
dbesc($item['thr_parent'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
|
// 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.
|
// 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.
|
// 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",
|
$p = q("select * from item where parent = %d and id = %d limit 1",
|
||||||
intval($item['parent']),
|
intval($item['parent']),
|
||||||
intval($item['parent'])
|
intval($item['parent'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(count($p))
|
if($p)
|
||||||
$parent = $p[0];
|
$parent = $p[0];
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@ -2311,12 +2300,10 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
|
|||||||
if($item['verb'] === ACTIVITY_LIKE) {
|
if($item['verb'] === ACTIVITY_LIKE) {
|
||||||
$tpl = get_markup_template('diaspora_like.tpl');
|
$tpl = get_markup_template('diaspora_like.tpl');
|
||||||
$like = true;
|
$like = true;
|
||||||
$target_type = ( $parent['uri'] === $parent['parent-uri'] ? 'Post' : 'Comment');
|
$target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment');
|
||||||
// $target_type = (strpos($parent['type'], 'comment') ? 'Comment' : 'Post');
|
|
||||||
// $positive = (($item['deleted']) ? 'false' : 'true');
|
|
||||||
$positive = 'true';
|
$positive = 'true';
|
||||||
|
|
||||||
if(($item['deleted']))
|
if(($item_['item_restrict'] & ITEM_DELETED))
|
||||||
logger('diaspora_send_followup: received deleted "like". Those should go to diaspora_send_retraction');
|
logger('diaspora_send_followup: received deleted "like". Those should go to diaspora_send_retraction');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2329,15 +2316,15 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
|
|||||||
// sign it
|
// sign it
|
||||||
|
|
||||||
if($like)
|
if($like)
|
||||||
$signed_text = $item['guid'] . ';' . $target_type . ';' . $parent['guid'] . ';' . $positive . ';' . $myaddr;
|
$signed_text = $item['mid'] . ';' . $target_type . ';' . $parent['mid'] . ';' . $positive . ';' . $myaddr;
|
||||||
else
|
else
|
||||||
$signed_text = $item['guid'] . ';' . $parent['guid'] . ';' . $text . ';' . $myaddr;
|
$signed_text = $item['mid'] . ';' . $parent['mid'] . ';' . $text . ';' . $myaddr;
|
||||||
|
|
||||||
$authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
|
$authorsig = base64_encode(rsa_sign($signed_text,$owner['channel_prvkey'],'sha256'));
|
||||||
|
|
||||||
$msg = replace_macros($tpl,array(
|
$msg = replace_macros($tpl,array(
|
||||||
'$guid' => xmlify($item['guid']),
|
'$guid' => xmlify($item['mid']),
|
||||||
'$parent_guid' => xmlify($parent['guid']),
|
'$parent_guid' => xmlify($parent['mid']),
|
||||||
'$target_type' =>xmlify($target_type),
|
'$target_type' =>xmlify($target_type),
|
||||||
'$authorsig' => xmlify($authorsig),
|
'$authorsig' => xmlify($authorsig),
|
||||||
'$body' => xmlify($text),
|
'$body' => xmlify($text),
|
||||||
@ -2347,8 +2334,8 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
|
|||||||
|
|
||||||
logger('diaspora_followup: base message: ' . $msg, LOGGER_DATA);
|
logger('diaspora_followup: base message: ' . $msg, LOGGER_DATA);
|
||||||
|
|
||||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
|
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['channel_prvkey'],$contact['xchan_pubkey'],$public_batch)));
|
||||||
//$slap = 'xml=' . urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch));
|
|
||||||
|
|
||||||
return(diaspora_transmit($owner,$contact,$slap,$public_batch));
|
return(diaspora_transmit($owner,$contact,$slap,$public_batch));
|
||||||
}
|
}
|
||||||
@ -2358,7 +2345,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
|
|||||||
|
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
|
$myaddr = $owner['channel_address'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
|
||||||
// $theiraddr = $contact['addr'];
|
// $theiraddr = $contact['addr'];
|
||||||
|
|
||||||
$body = $item['body'];
|
$body = $item['body'];
|
||||||
@ -2367,21 +2354,21 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
|
|||||||
// Diaspora doesn't support threaded comments, but some
|
// Diaspora doesn't support threaded comments, but some
|
||||||
// versions of Diaspora (i.e. Diaspora-pistos) support
|
// versions of Diaspora (i.e. Diaspora-pistos) support
|
||||||
// likes on comments
|
// likes on comments
|
||||||
if($item['verb'] === ACTIVITY_LIKE && $item['thr-parent']) {
|
if($item['verb'] === ACTIVITY_LIKE && $item['thr_parent']) {
|
||||||
$p = q("select guid, type, uri, `parent-uri` from item where uri = '%s' limit 1",
|
$p = q("select * from item where mid = '%s' limit 1",
|
||||||
dbesc($item['thr-parent'])
|
dbesc($item['thr_parent'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
|
// 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.
|
// 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.
|
// 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",
|
$p = q("select * from item where parent = %d and id = %d limit 1",
|
||||||
intval($item['parent']),
|
intval($item['parent']),
|
||||||
intval($item['parent'])
|
intval($item['parent'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(count($p))
|
if($p)
|
||||||
$parent = $p[0];
|
$parent = $p[0];
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@ -2389,7 +2376,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
|
|||||||
$like = false;
|
$like = false;
|
||||||
$relay_retract = false;
|
$relay_retract = false;
|
||||||
$sql_sign_id = 'iid';
|
$sql_sign_id = 'iid';
|
||||||
if( $item['deleted']) {
|
if( $item['item_restrict'] & ITEM_DELETED) {
|
||||||
$relay_retract = true;
|
$relay_retract = true;
|
||||||
|
|
||||||
$target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment');
|
$target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment');
|
||||||
@ -2400,8 +2387,8 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
|
|||||||
elseif($item['verb'] === ACTIVITY_LIKE) {
|
elseif($item['verb'] === ACTIVITY_LIKE) {
|
||||||
$like = true;
|
$like = true;
|
||||||
|
|
||||||
$target_type = ( $parent['uri'] === $parent['parent-uri'] ? 'Post' : 'Comment');
|
$target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment');
|
||||||
// $positive = (($item['deleted']) ? 'false' : 'true');
|
// $positive = (($item['item_restrict'] & ITEM_DELETED) ? 'false' : 'true');
|
||||||
$positive = 'true';
|
$positive = 'true';
|
||||||
|
|
||||||
$tpl = get_markup_template('diaspora_like_relay.tpl');
|
$tpl = get_markup_template('diaspora_like_relay.tpl');
|
||||||
@ -2445,7 +2432,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
|
|||||||
* been done yet
|
* been done yet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$handle = diaspora_handle_from_contact($item['contact-id']);
|
$handle = diaspora_handle_from_contact($item['author_xchan']);
|
||||||
if(! $handle)
|
if(! $handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user