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