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