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