Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge

This commit is contained in:
zotlabs 2017-11-02 17:31:49 -07:00
commit 0403738981
7 changed files with 53 additions and 15 deletions

View File

@ -88,6 +88,14 @@ class Ratenotif {
'msg' => json_encode($encoded_item) '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; $deliver[] = $hash;
if(count($deliver) >= $deliveries_per_process) { if(count($deliver) >= $deliveries_per_process) {

View File

@ -19,7 +19,7 @@ class Mail extends \Zotlabs\Web\Controller {
$replyto = ((x($_REQUEST,'replyto')) ? notags(trim($_REQUEST['replyto'])) : ''); $replyto = ((x($_REQUEST,'replyto')) ? notags(trim($_REQUEST['replyto'])) : '');
$subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : ''); $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : '');
$body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); $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'])) : ''); $rstr = ((x($_REQUEST,'messagerecip')) ? notags(trim($_REQUEST['messagerecip'])) : '');
$preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
$expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE); $expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE);

View File

@ -381,7 +381,7 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) {
$chans[] = $s; $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) { foreach($r as $k => $rr) {
$r[$k]['from'] = find_xchan_in_array($rr['from_xchan'],$c); $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; $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) { foreach($messages as $k => $message) {
$messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c); $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) { foreach($messages as $k => $message) {
$messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c); $messages[$k]['from'] = find_xchan_in_array($message['from_xchan'],$c);

View File

@ -1438,6 +1438,17 @@ function do_delivery($deliveries) {
if(! (is_array($deliveries) && count($deliveries))) if(! (is_array($deliveries) && count($deliveries)))
return; 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) $interval = ((get_config('system','delivery_interval') !== false)
? intval(get_config('system','delivery_interval')) : 2 ); ? intval(get_config('system','delivery_interval')) : 2 );

View File

@ -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); $arr = array('outq' => $outq, 'base' => $base, 'handled' => false, 'immediate' => $immediate);

View File

@ -2160,7 +2160,7 @@ function xchan_mail_query(&$item) {
if(count($arr)) { if(count($arr)) {
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash $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) { if($chans) {
$item['from'] = find_xchan_in_array($item['from_xchan'],$chans); $item['from'] = find_xchan_in_array($item['from_xchan'],$chans);

View File

@ -285,6 +285,16 @@ function zot_refresh($them, $channel = null, $force = false) {
return 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(); $token = random_string();
$postvars = []; $postvars = [];
@ -3138,6 +3148,15 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
'msg' => json_encode($info) '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)); Zotlabs\Daemon\Master::Summon(array('Deliver', $hash));
$total = $total - 1; $total = $total - 1;
@ -3872,7 +3891,7 @@ function zot_reply_message_request($data) {
if ($messages) { if ($messages) {
$env_recips = null; $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) dbesc($sender_hash)
); );
if (! $r) { if (! $r) {
@ -3905,6 +3924,14 @@ function zot_reply_message_request($data) {
'msg' => $data_packet '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 * invoke delivery to send out the notify packet
*/ */