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