]> git.mxchange.org Git - friendica.git/blob - include/notifier.php
Merge remote-tracking branch 'upstream/develop' into 1706-worker-even-faster
[friendica.git] / include / notifier.php
1 <?php
2
3 use Friendica\App;
4 use Friendica\Core\Config;
5
6 require_once 'include/queue_fn.php';
7 require_once 'include/html2plain.php';
8 require_once 'include/probe.php';
9 require_once 'include/diaspora.php';
10 require_once 'include/ostatus.php';
11 require_once 'include/salmon.php';
12
13 /*
14  * This file was at one time responsible for doing all deliveries, but this caused
15  * big problems when the process was killed or stalled during the delivery process.
16  * It now invokes separate queues that are delivering via delivery.php and pubsubpublish.php.
17  */
18
19 /*
20  * The notifier is typically called with:
21  *
22  *              proc_run(PRIORITY_HIGH, "include/notifier.php", COMMAND, ITEM_ID);
23  *
24  * where COMMAND is one of the following:
25  *
26  *              activity                                (in diaspora.php, dfrn_confirm.php, profiles.php)
27  *              comment-import                  (in diaspora.php, items.php)
28  *              comment-new                             (in item.php)
29  *              drop                                    (in diaspora.php, items.php, photos.php)
30  *              edit_post                               (in item.php)
31  *              event                                   (in events.php)
32  *              expire                                  (in items.php)
33  *              like                                    (in like.php, poke.php)
34  *              mail                                    (in message.php)
35  *              suggest                                 (in fsuggest.php)
36  *              tag                                             (in photos.php, poke.php, tagger.php)
37  *              tgroup                                  (in items.php)
38  *              wall-new                                (in photos.php, item.php)
39  *              removeme                                (in Contact.php)
40  *              relocate                                (in uimport.php)
41  *
42  * and ITEM_ID is the id of the item in the database that needs to be sent to others.
43  */
44
45
46 function notifier_run(&$argv, &$argc){
47         global $a;
48
49         require_once 'include/datetime.php';
50         require_once 'include/items.php';
51         require_once 'include/bbcode.php';
52         require_once 'include/email.php';
53
54         if ($argc < 3) {
55                 return;
56         }
57
58         // Inherit the priority
59         $queue = dba::select('workerqueue', array('priority', 'created'), array('pid' => getmypid()), array('limit' => 1));
60         if (dbm::is_result($queue)) {
61                 $priority = (int)$queue['priority'];
62                 $process_created = $queue['created'];
63                 logger('inherited priority: '.$priority);
64         } else {
65                 // Normally this shouldn't happen.
66                 $priority = PRIORITY_HIGH;
67                 $process_created = datetime_convert();
68                 logger('no inherited priority! Something is wrong.');
69         }
70
71         logger('notifier: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
72
73         $cmd = $argv[1];
74
75         switch($cmd) {
76                 case 'mail':
77                 default:
78                         $item_id = intval($argv[2]);
79                         if (! $item_id) {
80                                 return;
81                         }
82                         break;
83         }
84
85         $expire = false;
86         $mail = false;
87         $fsuggest = false;
88         $relocate = false;
89         $top_level = false;
90         $recipients = array();
91         $url_recipients = array();
92
93         $normal_mode = true;
94
95         if ($cmd === 'mail') {
96                 $normal_mode = false;
97                 $mail = true;
98                 $message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1",
99                                 intval($item_id)
100                 );
101                 if (! count($message)) {
102                         return;
103                 }
104                 $uid = $message[0]['uid'];
105                 $recipients[] = $message[0]['contact-id'];
106                 $item = $message[0];
107
108         } elseif ($cmd === 'expire') {
109                 $normal_mode = false;
110                 $expire = true;
111                 $items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1
112                         AND `deleted` = 1 AND `changed` > UTC_TIMESTAMP() - INTERVAL 10 MINUTE",
113                         intval($item_id)
114                 );
115                 $uid = $item_id;
116                 $item_id = 0;
117                 if (! count($items)) {
118                         return;
119                 }
120         } elseif ($cmd === 'suggest') {
121                 $normal_mode = false;
122                 $fsuggest = true;
123
124                 $suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1",
125                         intval($item_id)
126                 );
127                 if (! count($suggest)) {
128                         return;
129                 }
130                 $uid = $suggest[0]['uid'];
131                 $recipients[] = $suggest[0]['cid'];
132                 $item = $suggest[0];
133         } elseif ($cmd === 'removeme') {
134                 $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
135                                 `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
136                                 `user`.`page-flags`, `user`.`prvnets`, `user`.`account-type`, `user`.`guid`
137                         FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
138                                 WHERE `contact`.`uid` = %d AND `contact`.`self` LIMIT 1",
139                                 intval($item_id));
140                 if (!$r)
141                         return;
142
143                 $user = $r[0];
144
145                 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($item_id));
146                 if (!$r)
147                         return;
148
149                 $self = $r[0];
150
151                 $r = q("SELECT * FROM `contact` WHERE NOT `self` AND `uid` = %d", intval($item_id));
152                 if (!$r) {
153                         return;
154                 }
155                 require_once 'include/Contact.php';
156                 foreach ($r as $contact) {
157                         terminate_friendship($user, $self, $contact);
158                 }
159                 return;
160         } elseif ($cmd === 'relocate') {
161                 $normal_mode = false;
162                 $relocate = true;
163                 $uid = $item_id;
164
165                 $recipients_relocate = q("SELECT * FROM contact WHERE uid = %d  AND self = 0 AND network = '%s'" , intval($uid), NETWORK_DFRN);
166         } else {
167                 // find ancestors
168                 $r = q("SELECT * FROM `item` WHERE `id` = %d AND visible = 1 AND moderated = 0 LIMIT 1",
169                         intval($item_id)
170                 );
171
172                 if ((! dbm::is_result($r)) || (! intval($r[0]['parent']))) {
173                         return;
174                 }
175
176                 $target_item = $r[0];
177                 $parent_id = intval($r[0]['parent']);
178                 $uid = $r[0]['uid'];
179                 $updated = $r[0]['edited'];
180
181                 $items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer`
182                         FROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d AND visible = 1 AND moderated = 0 ORDER BY `id` ASC",
183                         intval($parent_id)
184                 );
185
186                 if (! count($items)) {
187                         return;
188                 }
189
190                 // avoid race condition with deleting entries
191
192                 if ($items[0]['deleted']) {
193                         foreach ($items as $item) {
194                                 $item['deleted'] = 1;
195                         }
196                 }
197
198                 if ((count($items) == 1) && ($items[0]['id'] === $target_item['id']) && ($items[0]['uri'] === $items[0]['parent-uri'])) {
199                         logger('notifier: top level post');
200                         $top_level = true;
201                 }
202
203         }
204
205         $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`,
206                 `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`,
207                 `user`.`page-flags`, `user`.`prvnets`, `user`.`account-type`
208                 FROM `contact` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
209                 WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
210                 intval($uid)
211         );
212
213         if (! dbm::is_result($r)) {
214                 return;
215         }
216
217         $owner = $r[0];
218
219         $walltowall = ((($top_level) && ($owner['id'] != $items[0]['contact-id'])) ? true : false);
220
221         $hub = get_config('system','huburl');
222
223         // Should the post be transmitted to Diaspora?
224         $diaspora_delivery = true;
225
226         // If this is a public conversation, notify the feed hub
227         $public_message = true;
228
229         // Do a PuSH
230         $push_notify = false;
231
232         // fill this in with a single salmon slap if applicable
233         $slap = '';
234
235         if (! ($mail || $fsuggest || $relocate)) {
236
237                 $slap = ostatus::salmon($target_item,$owner);
238
239                 require_once 'include/group.php';
240
241                 $parent = $items[0];
242
243                 $thr_parent = q("SELECT `network`, `author-link`, `owner-link` FROM `item` WHERE `uri` = '%s' AND `uid` = %d",
244                         dbesc($target_item["thr-parent"]), intval($target_item["uid"]));
245
246                 logger('GUID: '.$target_item["guid"].': Parent is '.$parent['network'].'. Thread parent is '.$thr_parent[0]['network'], LOGGER_DEBUG);
247
248                 // This is IMPORTANT!!!!
249
250                 // We will only send a "notify owner to relay" or followup message if the referenced post
251                 // originated on our system by virtue of having our hostname somewhere
252                 // in the URI, AND it was a comment (not top_level) AND the parent originated elsewhere.
253
254                 // if $parent['wall'] == 1 we will already have the parent message in our array
255                 // and we will relay the whole lot.
256
257                 // expire sends an entire group of expire messages and cannot be forwarded.
258                 // However the conversation owner will be a part of the conversation and will
259                 // be notified during this run.
260                 // Other DFRN conversation members will be alerted during polled updates.
261
262
263
264                 // Diaspora members currently are not notified of expirations, and other networks have
265                 // either limited or no ability to process deletions. We should at least fix Diaspora
266                 // by stringing togther an array of retractions and sending them onward.
267
268
269                 $localhost = str_replace('www.','',$a->get_hostname());
270                 if (strpos($localhost,':')) {
271                         $localhost = substr($localhost,0,strpos($localhost,':'));
272                 }
273                 /**
274                  *
275                  * Be VERY CAREFUL if you make any changes to the following several lines. Seemingly innocuous changes
276                  * have been known to cause runaway conditions which affected several servers, along with
277                  * permissions issues.
278                  *
279                  */
280
281                 $relay_to_owner = false;
282
283                 if (!$top_level && ($parent['wall'] == 0) && !$expire && (stristr($target_item['uri'],$localhost))) {
284                         $relay_to_owner = true;
285                 }
286
287
288                 if (($cmd === 'uplink') && (intval($parent['forum_mode']) == 1) && !$top_level) {
289                         $relay_to_owner = true;
290                 }
291
292                 // until the 'origin' flag has been in use for several months
293                 // we will just use it as a fallback test
294                 // later we will be able to use it as the primary test of whether or not to relay.
295
296                 if (! $target_item['origin']) {
297                         $relay_to_owner = false;
298                 }
299                 if ($parent['origin']) {
300                         $relay_to_owner = false;
301                 }
302                 if ($relay_to_owner) {
303                         logger('notifier: followup '.$target_item["guid"], LOGGER_DEBUG);
304                         // local followup to remote post
305                         $followup = true;
306                         $public_message = false; // not public
307                         $conversant_str = dbesc($parent['contact-id']);
308                         $recipients = array($parent['contact-id']);
309                         $recipients_followup  = array($parent['contact-id']);
310
311                         //if (!$target_item['private'] && $target_item['wall'] &&
312                         if (!$target_item['private'] &&
313                                 (strlen($target_item['allow_cid'].$target_item['allow_gid'].
314                                         $target_item['deny_cid'].$target_item['deny_gid']) == 0))
315                                 $push_notify = true;
316
317                         if (($thr_parent && ($thr_parent[0]['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) {
318
319                                 $push_notify = true;
320
321                                 if ($parent["network"] == NETWORK_OSTATUS) {
322                                         // Distribute the message to the DFRN contacts as if this wasn't a followup since OStatus can't relay comments
323                                         // Currently it is work at progress
324                                         $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `network` = '%s' AND NOT `blocked` AND NOT `pending` AND NOT `archive`",
325                                                 intval($uid),
326                                                 dbesc(NETWORK_DFRN)
327                                         );
328                                         if (dbm::is_result($r)) {
329                                                 foreach ($r as $rr) {
330                                                         $recipients_followup[] = $rr['id'];
331                                                 }
332                                         }
333                                 }
334                         }
335                         logger("Notify ".$target_item["guid"]." via PuSH: ".($push_notify?"Yes":"No"), LOGGER_DEBUG);
336                 } else {
337                         $followup = false;
338
339                         logger('Distributing directly '.$target_item["guid"], LOGGER_DEBUG);
340
341                         // don't send deletions onward for other people's stuff
342
343                         if ($target_item['deleted'] && (! intval($target_item['wall']))) {
344                                 logger('notifier: ignoring delete notification for non-wall item');
345                                 return;
346                         }
347
348                         if ((strlen($parent['allow_cid']))
349                                 || (strlen($parent['allow_gid']))
350                                 || (strlen($parent['deny_cid']))
351                                 || (strlen($parent['deny_gid']))) {
352                                 $public_message = false; // private recipients, not public
353                         }
354
355                         $allow_people = expand_acl($parent['allow_cid']);
356                         $allow_groups = expand_groups(expand_acl($parent['allow_gid']),true);
357                         $deny_people  = expand_acl($parent['deny_cid']);
358                         $deny_groups  = expand_groups(expand_acl($parent['deny_gid']));
359
360                         // if our parent is a public forum (forum_mode == 1), uplink to the origional author causing
361                         // a delivery fork. private groups (forum_mode == 2) do not uplink
362
363                         if ((intval($parent['forum_mode']) == 1) && (! $top_level) && ($cmd !== 'uplink')) {
364                                 proc_run($priority, 'include/notifier.php', 'uplink', $item_id);
365                         }
366
367                         $conversants = array();
368
369                         foreach ($items as $item) {
370                                 $recipients[] = $item['contact-id'];
371                                 $conversants[] = $item['contact-id'];
372                                 // pull out additional tagged people to notify (if public message)
373                                 if ($public_message && strlen($item['inform'])) {
374                                         $people = explode(',',$item['inform']);
375                                         foreach ($people as $person) {
376                                                 if (substr($person,0,4) === 'cid:') {
377                                                         $recipients[] = intval(substr($person,4));
378                                                         $conversants[] = intval(substr($person,4));
379                                                 } else {
380                                                         $url_recipients[] = substr($person,4);
381                                                 }
382                                         }
383                                 }
384                         }
385
386                         if (count($url_recipients))
387                                 logger('notifier: '.$target_item["guid"].' url_recipients ' . print_r($url_recipients,true));
388
389                         $conversants = array_unique($conversants);
390
391
392                         $recipients = array_unique(array_merge($recipients,$allow_people,$allow_groups));
393                         $deny = array_unique(array_merge($deny_people,$deny_groups));
394                         $recipients = array_diff($recipients,$deny);
395
396                         $conversant_str = dbesc(implode(', ',$conversants));
397                 }
398
399                 // If the thread parent is OStatus then do some magic to distribute the messages.
400                 // We have not only to look at the parent, since it could be a Friendica thread.
401                 if (($thr_parent && ($thr_parent[0]['network'] == NETWORK_OSTATUS)) || ($parent['network'] == NETWORK_OSTATUS)) {
402
403                         $diaspora_delivery = false;
404
405                         logger('Some parent is OStatus for '.$target_item["guid"]." - Author: ".$thr_parent[0]['author-link']." - Owner: ".$thr_parent[0]['owner-link'], LOGGER_DEBUG);
406
407                         // Send a salmon to the parent author
408                         $r = q("SELECT `url`, `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''",
409                                 dbesc(normalise_link($thr_parent[0]['author-link'])),
410                                 intval($uid));
411                         if (dbm::is_result($r)) {
412                                 $probed_contact = $r[0];
413                         } else {
414                                 $probed_contact = probe_url($thr_parent[0]['author-link']);
415                         }
416
417                         if ($probed_contact["notify"] != "") {
418                                 logger('Notify parent author '.$probed_contact["url"].': '.$probed_contact["notify"]);
419                                 $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
420                         }
421
422                         // Send a salmon to the parent owner
423                         $r = q("SELECT `url`, `notify` FROM `contact` WHERE `nurl`='%s' AND `uid` IN (0, %d) AND `notify` != ''",
424                                 dbesc(normalise_link($thr_parent[0]['owner-link'])),
425                                 intval($uid));
426                         if (dbm::is_result($r)) {
427                                 $probed_contact = $r[0];
428                         } else {
429                                 $probed_contact = probe_url($thr_parent[0]['owner-link']);
430                         }
431
432                         if ($probed_contact["notify"] != "") {
433                                 logger('Notify parent owner '.$probed_contact["url"].': '.$probed_contact["notify"]);
434                                 $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
435                         }
436
437                         // Send a salmon notification to every person we mentioned in the post
438                         $arr = explode(',',$target_item['tag']);
439                         foreach ($arr as $x) {
440                                 //logger('Checking tag '.$x, LOGGER_DEBUG);
441                                 $matches = null;
442                                 if (preg_match('/@\[url=([^\]]*)\]/',$x,$matches)) {
443                                                 $probed_contact = probe_url($matches[1]);
444                                         if ($probed_contact["notify"] != "") {
445                                                 logger('Notify mentioned user '.$probed_contact["url"].': '.$probed_contact["notify"]);
446                                                 $url_recipients[$probed_contact["notify"]] = $probed_contact["notify"];
447                                         }
448                                 }
449                         }
450
451                         // It only makes sense to distribute answers to OStatus messages to Friendica and OStatus - but not Diaspora
452                         $sql_extra = " AND `network` IN ('".NETWORK_OSTATUS."', '".NETWORK_DFRN."')";
453                 } else {
454                         $sql_extra = " AND `network` IN ('".NETWORK_OSTATUS."', '".NETWORK_DFRN."', '".NETWORK_DIASPORA."', '".NETWORK_MAIL."', '".NETWORK_MAIL2."')";
455                 }
456         } else {
457                 $public_message = false;
458         }
459
460         // If this is a public message and pubmail is set on the parent, include all your email contacts
461
462         $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
463
464         if (! $mail_disabled) {
465                 if ((! strlen($target_item['allow_cid'])) && (! strlen($target_item['allow_gid']))
466                         && (! strlen($target_item['deny_cid'])) && (! strlen($target_item['deny_gid']))
467                         && (intval($target_item['pubmail']))) {
468                         $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `network` = '%s'",
469                                 intval($uid),
470                                 dbesc(NETWORK_MAIL)
471                         );
472                         if (dbm::is_result($r)) {
473                                 foreach ($r as $rr) {
474                                         $recipients[] = $rr['id'];
475                                 }
476                         }
477                 }
478         }
479
480         if ($followup) {
481                 $recip_str = implode(', ', $recipients_followup);
482         } else {
483                 $recip_str = implode(', ', $recipients);
484         }
485         if ($relocate) {
486                 $r = $recipients_relocate;
487         } else {
488                 $r = q("SELECT `id`, `url`, `network`, `self` FROM `contact`
489                         WHERE `id` IN (%s) AND NOT `blocked` AND NOT `pending` AND NOT `archive`".$sql_extra,
490                         dbesc($recip_str)
491                 );
492         }
493
494         // delivery loop
495
496         if (dbm::is_result($r)) {
497                 foreach ($r as $contact) {
498                         if ($contact['self']) {
499                                 continue;
500                         }
501                         logger("Deliver ".$target_item["guid"]." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG);
502
503                         proc_run(array('priority' => $priority, 'created' => $process_created, 'dont_fork' => true),
504                                         'include/delivery.php', $cmd, $item_id, $contact['id']);
505                 }
506         }
507
508         // send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
509         // They are especially used for notifications to OStatus users that don't follow us.
510
511         if ($slap && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) {
512                 if (!get_config('system','dfrn_only')) {
513                         foreach ($url_recipients as $url) {
514                                 if ($url) {
515                                         logger('notifier: urldelivery: ' . $url);
516                                         $deliver_status = slapper($owner,$url,$slap);
517                                         /// @TODO Redeliver/queue these items on failure, though there is no contact record
518                                 }
519                         }
520                 }
521         }
522
523
524         if ($public_message) {
525
526                 $r0 = array();
527                 $r1 = array();
528
529                 if ($diaspora_delivery) {
530                         if (!$followup) {
531                                 $r0 = Diaspora::relay_list();
532                         }
533
534                         $r1 = q("SELECT `batch`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`name`) AS `name`, ANY_VALUE(`network`) AS `network`
535                                 FROM `contact` WHERE `network` = '%s'
536                                 AND `uid` = %d AND `rel` != %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` GROUP BY `batch` ORDER BY rand()",
537                                 dbesc(NETWORK_DIASPORA),
538                                 intval($owner['uid']),
539                                 intval(CONTACT_IS_SHARING)
540                         );
541                 }
542
543                 $r2 = q("SELECT `id`, `name`,`network` FROM `contact`
544                         WHERE `network` in ( '%s', '%s')  AND `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `archive`
545                         AND `rel` != %d order by rand() ",
546                         dbesc(NETWORK_DFRN),
547                         dbesc(NETWORK_MAIL2),
548                         intval($owner['uid']),
549                         intval(CONTACT_IS_SHARING)
550                 );
551
552                 $r = array_merge($r2,$r1,$r0);
553
554                 if (dbm::is_result($r)) {
555                         logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
556
557                         foreach ($r as $rr) {
558
559                                 // except for Diaspora batch jobs
560                                 // Don't deliver to folks who have already been delivered to
561
562                                 if (($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'],$conversants))) {
563                                         logger('notifier: already delivered id=' . $rr['id']);
564                                         continue;
565                                 }
566
567                                 if ((! $mail) && (! $fsuggest) && (! $followup)) {
568                                         logger('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]);
569                                         proc_run(array('priority' => $priority, 'created' => $process_created, 'dont_fork' => true),
570                                                         'include/delivery.php', $cmd, $item_id, $rr['id']);
571                                 }
572                         }
573                 }
574
575                 $push_notify = true;
576
577         }
578
579         // Notify PuSH subscribers (Used for OStatus distribution of regular posts)
580         if ($push_notify && strlen($hub)) {
581                 $hubs = explode(',', $hub);
582                 if (count($hubs)) {
583                         foreach ($hubs as $h) {
584                                 $h = trim($h);
585                                 if (! strlen($h)) {
586                                         continue;
587                                 }
588
589                                 if ($h === '[internal]') {
590                                         // Set push flag for PuSH subscribers to this topic,
591                                         // they will be notified in queue.php
592                                         q("UPDATE `push_subscriber` SET `push` = 1 ".
593                                           "WHERE `nickname` = '%s' AND `push` = 0", dbesc($owner['nickname']));
594
595                                         logger('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG);
596
597                                 } else {
598
599                                         $params = 'hub.mode=publish&hub.url=' . urlencode( App::get_baseurl() . '/dfrn_poll/' . $owner['nickname'] );
600                                         post_url($h,$params);
601                                         logger('publish for item '.$item_id.' ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code());
602                                 }
603                                 if (count($hubs) > 1) {
604                                         sleep(7);                               // try and avoid multiple hubs responding at precisely the same time
605                                 }
606                         }
607                 }
608
609                 // Handling the pubsubhubbub requests
610                 proc_run(array('priority' => PRIORITY_HIGH, 'created' => $process_created, 'dont_fork' => true),
611                                 'include/pubsubpublish.php');
612         }
613
614         logger('notifier: calling hooks', LOGGER_DEBUG);
615
616         if ($normal_mode) {
617                 call_hooks('notifier_normal',$target_item);
618         }
619
620         call_hooks('notifier_end',$target_item);
621
622         return;
623 }