From 28cd2759d76c9227c474c8c1da073a4f91cf5523 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 1 Nov 2017 17:50:57 -0700 Subject: do not send message_list responses to dead sites (this delivery method bypassed the notifier) --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index 5270ed8b8..6647daa0a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3872,7 +3872,7 @@ function zot_reply_message_request($data) { if ($messages) { $env_recips = null; - $r = q("select hubloc.*, site.site_crypto from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s' and hubloc_error = 0 and hubloc_deleted = 0", + $r = q("select hubloc.*, site.site_crypto from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s' and hubloc_error = 0 and hubloc_deleted = 0 and site.site_dead = 0 ", dbesc($sender_hash) ); if (! $r) { -- cgit v1.2.3 From 52657b6215b3b7104a89c8c3fea09a7f37ebf71e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 1 Nov 2017 19:24:29 -0700 Subject: don't perform zot_refresh on dead sites unless $force is set --- include/zot.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/zot.php b/include/zot.php index 6647daa0a..bb87a234c 100644 --- a/include/zot.php +++ b/include/zot.php @@ -285,6 +285,16 @@ function zot_refresh($them, $channel = null, $force = false) { return false; } + $s = q("select site_dead from site where site_url = '%s' limit 1", + dbesc($url) + ); + + if($s && intval($s[0]['site_dead']) && (! $force)) { + logger('zot_refresh: site ' . $url . ' is marked dead and force flag is not set. Cancelling operation.'); + return false; + } + + $token = random_string(); $postvars = []; -- cgit v1.2.3 From cdaf5f3fc0756157863008df185f6b344241c147 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 2 Nov 2017 08:44:46 +0100 Subject: fix issues with diaspora xchans --- Zotlabs/Module/Mail.php | 4 ++-- include/message.php | 6 +++--- include/text.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 12f3b8152..b58b169d0 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -19,7 +19,7 @@ class Mail extends \Zotlabs\Web\Controller { $replyto = ((x($_REQUEST,'replyto')) ? notags(trim($_REQUEST['replyto'])) : ''); $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : ''); $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); - $recipient = ((x($_REQUEST,'messageto')) ? notags(trim($_REQUEST['messageto'])) : ''); + $recipient = ((x($_REQUEST,'messageto')) ? notags(trim(urldecode($_REQUEST['messageto']))) : ''); $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : ''); $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); @@ -124,7 +124,7 @@ class Mail extends \Zotlabs\Web\Controller { // We have a local_channel, let send_message use the session channel and save a lookup $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw); - + if($ret['success']) { xchan_mail_query($ret['mail']); build_sync_packet(0,array('conv' => array($ret['conv']),'mail' => array(encode_mail($ret['mail'],true)))); diff --git a/include/message.php b/include/message.php index 3f003e020..477c7172c 100644 --- a/include/message.php +++ b/include/message.php @@ -381,7 +381,7 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) { $chans[] = $s; } - $c = q("select * from xchan where xchan_hash in (" . implode(',',$chans) . ")"); + $c = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$chans)) . ")"); foreach($r as $k => $rr) { $r[$k]['from'] = find_xchan_in_array($rr['from_xchan'],$c); @@ -420,7 +420,7 @@ function private_messages_fetch_message($channel_id, $messageitem_id, $updatesee $chans[] = $s; } - $c = q("select * from xchan where xchan_hash in (" . implode(',',$chans) . ")"); + $c = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$chans)) . ")"); foreach($messages as $k => $message) { $messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c); @@ -545,7 +545,7 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda } - $c = q("select * from xchan where xchan_hash in (" . implode(',',$chans) . ")"); + $c = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$chans)) . ")"); foreach($messages as $k => $message) { $messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c); diff --git a/include/text.php b/include/text.php index d81b59d75..746c35679 100644 --- a/include/text.php +++ b/include/text.php @@ -2160,7 +2160,7 @@ function xchan_mail_query(&$item) { if(count($arr)) { $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash - where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1"); + where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1"); } if($chans) { $item['from'] = find_xchan_in_array($item['from_xchan'],$chans); -- cgit v1.2.3 From 1b290f573acdd4f003b6ffcce6c0705ea461bd9d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 2 Nov 2017 03:13:30 -0700 Subject: put deferred queue logic every place we create a delivery process (except for protocol 'friend requests' which aren't likely to swamp the delivery system). Remove it from the queue_delivery function which was too late to do anything. --- Zotlabs/Daemon/Ratenotif.php | 8 ++++++++ include/network.php | 11 +++++++++++ include/queue_fn.php | 8 -------- include/zot.php | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php index a94b89004..c7bf79854 100644 --- a/Zotlabs/Daemon/Ratenotif.php +++ b/Zotlabs/Daemon/Ratenotif.php @@ -88,6 +88,14 @@ class Ratenotif { 'msg' => json_encode($encoded_item) )); + + $x = q("select count(outq_hash) as total from outq where outq_delivered = 0"); + if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) { + logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO); + update_queue_item($hash); + continue; + } + $deliver[] = $hash; if(count($deliver) >= $deliveries_per_process) { diff --git a/include/network.php b/include/network.php index 2f29a70c4..73a6aeff2 100644 --- a/include/network.php +++ b/include/network.php @@ -1438,6 +1438,17 @@ function do_delivery($deliveries) { if(! (is_array($deliveries) && count($deliveries))) return; + + $x = q("select count(outq_hash) as total from outq where outq_delivered = 0"); + if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) { + logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO); + foreach($deliveries as $d) { + update_queue_item($d); + } + return; + } + + $interval = ((get_config('system','delivery_interval') !== false) ? intval(get_config('system','delivery_interval')) : 2 ); diff --git a/include/queue_fn.php b/include/queue_fn.php index c09033d0a..0d98e1e21 100644 --- a/include/queue_fn.php +++ b/include/queue_fn.php @@ -158,14 +158,6 @@ function queue_deliver($outq, $immediate = false) { } } - if($immediate) { - $x = q("select count(outq_hash) as total from outq where outq_delivered = 0"); - if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) { - logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO); - update_queue_item($outq['outq_hash']); - return; - } - } $arr = array('outq' => $outq, 'base' => $base, 'handled' => false, 'immediate' => $immediate); diff --git a/include/zot.php b/include/zot.php index bb87a234c..5764bb99a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3148,6 +3148,15 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { 'msg' => json_encode($info) )); + + $x = q("select count(outq_hash) as total from outq where outq_delivered = 0"); + if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) { + logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO); + update_queue_item($hash); + continue; + } + + Zotlabs\Daemon\Master::Summon(array('Deliver', $hash)); $total = $total - 1; @@ -3915,6 +3924,14 @@ function zot_reply_message_request($data) { 'msg' => $data_packet )); + + $x = q("select count(outq_hash) as total from outq where outq_delivered = 0"); + if(intval($x[0]['total']) > intval(get_config('system','force_queue_threshold',300))) { + logger('immediate delivery deferred.', LOGGER_DEBUG, LOG_INFO); + update_queue_item($hash); + continue; + } + /* * invoke delivery to send out the notify packet */ -- cgit v1.2.3