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