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