aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-08-26 18:58:48 -0700
committerfriendica <info@friendica.com>2014-08-26 18:58:48 -0700
commit6a42d6fe3b1e50af16942d0f22e8cfa01abfde39 (patch)
treec4bc72223e915a2e83aed11ca09daa059ad6a8c3
parente42205cec25fbe7ee93fde4a0f267d54b0e30193 (diff)
downloadvolse-hubzilla-6a42d6fe3b1e50af16942d0f22e8cfa01abfde39.tar.gz
volse-hubzilla-6a42d6fe3b1e50af16942d0f22e8cfa01abfde39.tar.bz2
volse-hubzilla-6a42d6fe3b1e50af16942d0f22e8cfa01abfde39.zip
works one way sort of - now to go the other way - which will require fixing a whole slew of FIXMEs
-rw-r--r--include/deliver.php2
-rwxr-xr-xinclude/diaspora.php67
-rw-r--r--include/notifier.php6
-rw-r--r--include/zot.php5
4 files changed, 51 insertions, 29 deletions
diff --git a/include/deliver.php b/include/deliver.php
index 6edf3d60f..08c4f9b64 100644
--- a/include/deliver.php
+++ b/include/deliver.php
@@ -22,7 +22,7 @@ function deliver_run($argv, $argc) {
if($r) {
if($r[0]['outq_driver'] === 'post') {
$result = z_post_url($r[0]['outq_posturl'],$r[0]['outq_msg']);
- if($result['success'] && $result['status_code'] < 300) {
+ if($result['success'] && $result['return_code'] < 300) {
logger('deliver: queue post success to ' . $r[0]['outq_posturl'], LOGGER_DEBUG);
}
else {
diff --git a/include/diaspora.php b/include/diaspora.php
index 0d2037666..017fd4ed8 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -150,15 +150,32 @@ function diaspora_process_outbound($arr) {
*/
+ $target_item = $arr['target_item'];
+
+ if($target_item && array_key_exists('item_flags',$target_item) && ($target_item['item_flags'] & ITEM_OBSCURED)) {
+ $key = get_config('system','prvkey');
+ if($target_item['title'])
+ $target_item['title'] = crypto_unencapsulate(json_decode($target_item['title'],true),$key);
+ if($target_item['body'])
+ $target_item['body'] = crypto_unencapsulate(json_decode($target_item['body'],true),$key);
+ }
+
if($arr['walltowall'])
return;
if($arr['env_recips']) {
+ $hashes = array();
+
+ // re-explode the recipients, but only for this hub/pod
+
+ foreach($arr['env_recips'] as $recip)
+ $hashes[] = "'" . $recip['hash'] . "'";
+
$r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url = '%s'
- and xchan_hash in (" . implode(',',$arr['env_recips']) . ")
- and xchan_network in ('diaspora', 'friendica-over-diaspora') ",
+ and xchan_hash in (" . implode(',', $hashes) . ") and xchan_network in ('diaspora', 'friendica-over-diaspora') ",
dbesc($arr['hub']['hubloc_url'])
);
+
if(! $r) {
logger('diaspora_process_outbound: no recipients');
return;
@@ -178,36 +195,36 @@ function diaspora_process_outbound($arr) {
// all other public posts processed as public batches further below
if((! $arr['private']) && ($arr['followup'])) {
- diaspora_send_followup($arr['target_item'],$arr['channel'],$contact, true);
+ diaspora_send_followup($target_item,$arr['channel'],$contact, true);
continue;
}
if(! $contact['xchan_pubkey'])
continue;
- if(activity_match($arr['target_item']['verb'],ACTIVITY_DISLIKE)) {
+ if(activity_match($target_item['verb'],ACTIVITY_DISLIKE)) {
continue;
}
- elseif(($arr['target_item']['item_restrict'] & ITEM_DELETED)
- && (($arr['target_item']['mid'] === $arr['target_item']['parent_mid']) || $arr['followup'])) {
+ elseif(($target_item['item_restrict'] & ITEM_DELETED)
+ && (($target_item['mid'] === $target_item['parent_mid']) || $arr['followup'])) {
// send both top-level retractions and relayable retractions for owner to relay
- diaspora_send_retraction($arr['target_item'],$arr['channel'],$contact);
+ diaspora_send_retraction($target_item,$arr['channel'],$contact);
continue;
}
elseif($arr['followup']) {
// send comments and likes to owner to relay
- diaspora_send_followup($arr['target_item'],$arr['channel'],$contact);
+ diaspora_send_followup($target_item,$arr['channel'],$contact);
continue;
}
elseif($target_item['mid'] !== $target_item['parent_mid']) {
// we are the relay - send comments, likes and relayable_retractions
// (of comments and likes) to our conversants
- diaspora_send_relay($arr['target_item'],$arr['channel'],$contact);
+ diaspora_send_relay($target_item,$arr['channel'],$contact);
continue;
}
- elseif($arr['top_level']) {
- diaspora_send_status($arr['target_item'],$arr['channel'],$contact);
+ elseif($arr['top_level_post']) {
+ diaspora_send_status($target_item,$arr['channel'],$contact);
continue;
}
}
@@ -221,23 +238,23 @@ function diaspora_process_outbound($arr) {
// unsupported
return;
}
- elseif(($arr['target_item']['deleted'])
- && ($arr['target_item']['mid'] === $arr['target_item']['parent_mod'])) {
+ elseif(($target_item['deleted'])
+ && ($target_item['mid'] === $target_item['parent_mod'])) {
// top-level retraction
logger('delivery: diaspora retract: ' . $loc);
- diaspora_send_retraction($arr['target_item'],$arr['channel'],$contact,true);
+ diaspora_send_retraction($target_item,$arr['channel'],$contact,true);
return;
}
- elseif($arr['target_item']['mid'] !== $arr['target_item']['parent_mid']) {
+ elseif($target_item['mid'] !== $target_item['parent_mid']) {
// we are the relay - send comments, likes and relayable_retractions to our conversants
logger('delivery: diaspora relay: ' . $loc);
- diaspora_send_relay($arr['target_item'],$arr['channel'],$contact,true);
+ diaspora_send_relay($target_item,$arr['channel'],$contact,true);
return;
}
elseif($arr['top_level_post']) {
// currently no workable solution for sending walltowall
logger('delivery: diaspora status: ' . $loc);
- diaspora_send_status($arr['target_item'],$arr['channel'],$contact,true);
+ diaspora_send_status($target_item,$arr['channel'],$contact,true);
return;
}
@@ -392,7 +409,7 @@ function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey,$public = false)
$outer_iv = random_string(16);
$b_outer_iv = base64_encode($outer_iv);
- $handle = $user['xchan_addr'];
+ $handle = $user['channel_address'] . '@' . get_app()->get_hostname();
$padded_data = pkcs5_pad($msg,16);
$inner_encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $padded_data, MCRYPT_MODE_CBC, $inner_iv);
@@ -1174,18 +1191,20 @@ function diaspora_comment($importer,$xml,$msg) {
return 202;
}
- $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `mid` = '%s' LIMIT 1",
+ // Friendica is truncating guids at 64 chars
+
+ $r = q("SELECT * FROM item WHERE uid = %d AND mid like '%s' LIMIT 1",
intval($importer['channel_id']),
- dbesc($guid)
+ dbesc($guid . '%')
);
if($r) {
logger('diaspora_comment: our comment just got relayed back to us (or there was a guid collision) : ' . $guid);
return;
}
- $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `mid` = '%s' LIMIT 1",
+ $r = q("SELECT * FROM item WHERE uid = %d AND mid LIKE '%s' LIMIT 1",
intval($importer['channel_id']),
- dbesc($parent_guid)
+ dbesc($parent_guid . '%')
);
if(! $r) {
logger('diaspora_comment: parent item not found: parent: ' . $parent_guid . ' item: ' . $guid);
@@ -1298,7 +1317,7 @@ function diaspora_comment($importer,$xml,$msg) {
// No timestamps for comments? OK, we'll the use current time.
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert();
- $datarray['private'] = $parent_item['private'];
+ $datarray['item_private'] = $parent_item['item_private'];
$datarray['owner_xchan'] = $parent_item['owner_xchan'];
$datarray['author_xchan'] = $person['xchan_hash'];
@@ -2326,7 +2345,7 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
$return_code = diaspora_transmit($owner,$contact,$slap,$public_batch);
- logger('diaspora_send_status: guid: '.$item['mid'].' result '.$return_code, LOGGER_DEBUG);
+// logger('diaspora_send_status: guid: '.$item['mid'].' result '.$return_code, LOGGER_DEBUG);
if(count($images)) {
diaspora_send_images($item,$owner,$contact,$images,$public_batch);
diff --git a/include/notifier.php b/include/notifier.php
index 5f4462b6a..88bb9a0cb 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -412,7 +412,7 @@ function notifier_run($argv, $argc){
$recip_list[] = $d['xchan_addr'] . ' (' . $d['xchan_hash'] . ')';
if($private)
- $env_recips[] = array('guid' => $d['xchan_guid'],'guid_sig' => $d['xchan_guid_sig']);
+ $env_recips[] = array('guid' => $d['xchan_guid'],'guid_sig' => $d['xchan_guid_sig'],'hash' => $d['xchan_hash']);
}
}
@@ -445,11 +445,11 @@ function notifier_run($argv, $argc){
// aren't the owner or author.
- $r = q("select hubloc_guid, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc
+ $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc
where hubloc_hash in (" . implode(',',$recipients) . ") group by hubloc_sitekey order by hubloc_connected desc limit 1");
}
else {
- $r = q("select hubloc_guid, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc
+ $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc
where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey");
}
diff --git a/include/zot.php b/include/zot.php
index 65c092b93..54efe1343 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -117,8 +117,11 @@ function zot_build_packet($channel,$type = 'notify',$recipients = null, $remote_
'version' => ZOT_REVISION
);
- if($recipients)
+ if($recipients) {
+ for($x = 0; $x < count($recipients); $x ++)
+ unset($recipients[$x]['hash']);
$data['recipients'] = $recipients;
+ }
if($secret) {
$data['secret'] = $secret;