X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fnotifier.php;h=6ac882c1992cf96511901f3c6f54033444aaffc2;hb=d284f8017cefb79571fe51c4ae3f85b9b4e517c9;hp=cde156cbdce3e75659cd24cc0263a43cfb503ddd;hpb=846c4cea7c0e3868a63a187ee9a504a031b2a7e4;p=friendica.git diff --git a/include/notifier.php b/include/notifier.php index cde156cbdc..6ac882c199 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -2,6 +2,20 @@ require_once("boot.php"); +/* + * This file was at one time responsible for doing all deliveries, but this caused + * big problems on shared hosting systems, where the process might get killed by the + * hosting provider and nothing would get delivered. + * It now only delivers one message under certain cases, and invokes a queued + * delivery mechanism (include/deliver.php) to deliver individual contacts at + * controlled intervals. + * This has a much better chance of surviving random processes getting killed + * by the hosting provider. + * A lot of this code is duplicated in include/deliver.php until we have time to go back + * and re-structure the delivery procedure based on the obstacles that have been thrown at + * us by hosting providers. + */ + function notifier_run($argv, $argc){ global $a, $db; @@ -125,8 +139,11 @@ function notifier_run($argv, $argc){ $item['deleted'] = 1; } - if(count($items) == 1 && $items[0]['uri'] === $items[0]['parent-uri']) + if((count($items) == 1) && ($items[0]['uri'] === $items[0]['parent-uri'])) { + logger('notifier: top level post'); $top_level = true; + } + } $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`, @@ -142,6 +159,8 @@ function notifier_run($argv, $argc){ $owner = $r[0]; + $walltowall = ((($top_level) && ($owner['id'] != $items[0]['contact-id'])) ? true : false); + $hub = get_config('system','huburl'); // If this is a public conversation, notify the feed hub @@ -382,9 +401,7 @@ function notifier_run($argv, $argc){ require_once('include/salmon.php'); - $interval = intval(get_config('system','delivery_interval')); - if(! $interval) - $interval = 2; + $interval = ((get_config('system','delivery_interval') === false) ? 2 : intval(get_config('system','delivery_interval'))); // delivery loop @@ -409,7 +426,9 @@ function notifier_run($argv, $argc){ if((! $mail) && (! $fsuggest) && (! $followup)) { proc_run('php','include/delivery.php',$cmd,$item_id,$contact['id']); - @time_sleep_until(microtime(true) + (float) $interval); + if($interval) + @time_sleep_until(microtime(true) + (float) $interval); + continue; } $deliver_status = 0; @@ -589,7 +608,8 @@ function notifier_run($argv, $argc){ diaspora_send_relay($target_item,$owner,$contact); break; } - elseif($top_level) { + elseif(($top_level) && (! $walltowall)) { + // currently no workable solution for sending walltowall diaspora_send_status($target_item,$owner,$contact); break; } @@ -659,7 +679,8 @@ function notifier_run($argv, $argc){ if((! $mail) && (! $fsuggest) && (! $followup)) { logger('notifier: delivery agent: ' . $rr['name'] . ' ' . $rr['id']); proc_run('php','include/delivery.php',$cmd,$item_id,$rr['id']); - @time_sleep_until(microtime(true) + (float) $interval); + if($interval) + @time_sleep_until(microtime(true) + (float) $interval); } } }