From 9196c9eef091e7f4a41fbc9452521d6ca2de55a3 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 22 Aug 2014 21:37:08 -0700 Subject: We really can't do this without a hubloc. I was hoping we could, but notifier is setup to take hublocs, not xchans. --- include/notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index 9d5c7cb8e..180a538bc 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -382,7 +382,7 @@ function notifier_run($argv, $argc){ $env_recips = (($private) ? array() : null); - $details = q("select xchan_hash, xchan_instance_url, xchan_addr, xchan_guid, xchan_guid_sig from xchan where xchan_hash in (" . implode(',',$recipients) . ")"); + $details = q("select xchan_hash, xchan_instance_url, xchan_network, xchan_addr, xchan_guid, xchan_guid_sig from xchan where xchan_hash in (" . implode(',',$recipients) . ")"); $recip_list = array(); -- cgit v1.2.3 From 84ff380302764703dcc0bdf9ab5d69bac549726e Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 25 Aug 2014 20:57:10 -0700 Subject: more diaspora heavy lifting --- include/notifier.php | 77 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 17 deletions(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index 180a538bc..0a5cf3f4c 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -103,28 +103,33 @@ function notifier_run($argv, $argc){ ); if($r) { // Get the sender - $s = q("select * from channel where channel_id = %d limit 1", + $s = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d limit 1", intval($r[0]['abook_channel']) ); if($s) { - - // send a refresh message to each hub they have registered here - $h = q("select * from hubloc where hubloc_hash = '%s'", - dbesc($r[0]['hubloc_hash']) - ); - if($h) { - foreach($h as $hh) { - $data = zot_build_packet($s[0],'refresh',array(array( - 'guid' => $hh['hubloc_guid'], - 'guid_sig' => $hh['hubloc_guid_sig'], - 'url' => $hh['hubloc_url']) - )); - if($data) { - $result = zot_zot($hh['hubloc_callback'],$data); + if($r[0]['hubloc_network'] === 'diaspora' || $r[0]['hubloc_network'] === 'friendica_over_diaspora') { + require_once('include/diaspora.php'); + diaspora_share($s[0],$r[0]); + } + else { + // send a refresh message to each hub they have registered here + $h = q("select * from hubloc where hubloc_hash = '%s'", + dbesc($r[0]['hubloc_hash']) + ); + if($h) { + foreach($h as $hh) { + $data = zot_build_packet($s[0],'refresh',array(array( + 'guid' => $hh['hubloc_guid'], + 'guid_sig' => $hh['hubloc_guid_sig'], + 'url' => $hh['hubloc_url']) + )); + if($data) { + $result = zot_zot($hh['hubloc_callback'],$data); // zot_queue_item is not yet written // if(! $result['success']) // zot_queue_item(); + } } } } @@ -366,6 +371,8 @@ function notifier_run($argv, $argc){ } + $walltowall = (($top_level_post && $channel['xchan_hash'] === $target_item['author_xchan']) ? true : false); + // Generic delivery section, we have an encoded item and recipients // Now start the delivery process @@ -438,11 +445,11 @@ function notifier_run($argv, $argc){ // aren't the owner or author. - $r = q("select hubloc_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc + $r = q("select 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_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc + $r = q("select hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey"); } @@ -485,6 +492,42 @@ function notifier_run($argv, $argc){ } } + + if($hub['network'] === 'diaspora' || $hub['network'] === 'friendica-over-diaspora') { + if(! get_config('system','diaspora_enabled')) + continue; + + require_once('include/diaspora.php'); + + diaspora_process_outbound(array( + 'channel' => $channel, + 'env_recips' => $env_recips, + 'recipients' => $recipients, + 'item' => $item, + 'target_item' => $target_item, + 'hub' => $hub, + 'top_level_post' => $top_level_post, + 'private' => $private, + 'followup' => $followup, + 'relay_to_owner' => $relay_to_owner, + 'uplink' => $uplink, + 'cmd' => $cmd, + 'expire' => $expire, + 'mail' => $mail, + 'fsuggest' => $fsuggest, + 'normal_mode' => $normal_mode, + 'packet_type' => $packet_type, + 'walltowall' => $walltowall + )); + + continue; + + } + + + // default: zot protocol + + $hash = random_string(); if($packet_type === 'refresh' || $packet_type === 'purge') { $n = zot_build_packet($channel,$packet_type); -- cgit v1.2.3 From eb8f194419975a6cd3debba145c8769da055b8dc Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 25 Aug 2014 21:42:46 -0700 Subject: sort out some anomalies --- include/notifier.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index 0a5cf3f4c..7c4f64ae0 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -445,11 +445,11 @@ function notifier_run($argv, $argc){ // aren't the owner or author. - $r = q("select hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc + $r = q("select hubloc_guid, 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_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc + $r = q("select hubloc_guid, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey"); } -- cgit v1.2.3 From 6e99848043d198af5013c2439e7a2d16d8a32c52 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 25 Aug 2014 22:43:44 -0700 Subject: more diaspora stuff - most of the basic bits are there except queueing and physical delivery (I'm keeping delivery turned off until some of the bugs are fixed so we don't cause inifinite loops or network meltdowns) - now it's just a matter of going through and methodically finding all the bugs --- include/notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index 7c4f64ae0..7f4d7a9f8 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -493,7 +493,7 @@ function notifier_run($argv, $argc){ } - if($hub['network'] === 'diaspora' || $hub['network'] === 'friendica-over-diaspora') { + if($hub['hubloc_network'] === 'diaspora' || $hub['hubloc_network'] === 'friendica-over-diaspora') { if(! get_config('system','diaspora_enabled')) continue; -- cgit v1.2.3 From e42205cec25fbe7ee93fde4a0f267d54b0e30193 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 26 Aug 2014 17:32:51 -0700 Subject: houston we have liftoff --- include/notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/notifier.php') diff --git a/include/notifier.php b/include/notifier.php index 7f4d7a9f8..5f4462b6a 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -107,7 +107,7 @@ function notifier_run($argv, $argc){ intval($r[0]['abook_channel']) ); if($s) { - if($r[0]['hubloc_network'] === 'diaspora' || $r[0]['hubloc_network'] === 'friendica_over_diaspora') { + if($r[0]['hubloc_network'] === 'diaspora' || $r[0]['hubloc_network'] === 'friendica-over-diaspora') { require_once('include/diaspora.php'); diaspora_share($s[0],$r[0]); } -- cgit v1.2.3 From 6a42d6fe3b1e50af16942d0f22e8cfa01abfde39 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 26 Aug 2014 18:58:48 -0700 Subject: works one way sort of - now to go the other way - which will require fixing a whole slew of FIXMEs --- include/notifier.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/notifier.php') 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"); } -- cgit v1.2.3