]> git.mxchange.org Git - friendica.git/blob - src/Model/APContact.php
Old stuff removed
[friendica.git] / src / Model / APContact.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Model;
23
24 use Friendica\Content\Text\HTML;
25 use Friendica\Core\Cache\Enum\Duration;
26 use Friendica\Core\Logger;
27 use Friendica\Core\Protocol;
28 use Friendica\Core\System;
29 use Friendica\Database\DBA;
30 use Friendica\DI;
31 use Friendica\Model\Item;
32 use Friendica\Network\HTTPException;
33 use Friendica\Network\Probe;
34 use Friendica\Protocol\ActivityNamespace;
35 use Friendica\Protocol\ActivityPub;
36 use Friendica\Protocol\ActivityPub\Transmitter;
37 use Friendica\Util\Crypto;
38 use Friendica\Util\DateTimeFormat;
39 use Friendica\Util\HTTPSignature;
40 use Friendica\Util\JsonLD;
41 use Friendica\Util\Network;
42 use GuzzleHttp\Psr7\Uri;
43
44 class APContact
45 {
46         /**
47          * Fetch webfinger data
48          *
49          * @param string $addr Address
50          * @return array webfinger data
51          */
52         private static function fetchWebfingerData(string $addr): array
53         {
54                 $addr_parts = explode('@', $addr);
55                 if (count($addr_parts) != 2) {
56                         return [];
57                 }
58
59                 if (Contact::isLocal($addr) && ($local_uid = User::getIdForURL($addr)) && ($local_owner = User::getOwnerDataById($local_uid))) {
60                         $data = [
61                                 'addr'      => $local_owner['addr'],
62                                 'baseurl'   => $local_owner['baseurl'],
63                                 'url'       => $local_owner['url'],
64                                 'subscribe' => $local_owner['baseurl'] . '/contact/follow?url={uri}'];
65
66                         if (!empty($local_owner['alias']) && ($local_owner['url'] != $local_owner['alias'])) {
67                                 $data['alias'] = $local_owner['alias'];
68                         }
69
70                         return $data;
71                 }
72
73                 $webfinger = Probe::getWebfingerArray($addr);
74                 if (empty($webfinger['webfinger']['links'])) {
75                         return [];
76                 }
77
78                 $data['baseurl'] = $webfinger['baseurl'];
79
80                 foreach ($webfinger['webfinger']['links'] as $link) {
81                         if (empty($link['rel'])) {
82                                 continue;
83                         }
84
85                         if (!empty($link['template']) && ($link['rel'] == ActivityNamespace::OSTATUSSUB)) {
86                                 $data['subscribe'] = $link['template'];
87                         }
88
89                         if (!empty($link['href']) && !empty($link['type']) && ($link['rel'] == 'self') && ($link['type'] == 'application/activity+json')) {
90                                 $data['url'] = $link['href'];
91                         }
92
93                         if (!empty($link['href']) && !empty($link['type']) && ($link['rel'] == 'http://webfinger.net/rel/profile-page') && ($link['type'] == 'text/html')) {
94                                 $data['alias'] = $link['href'];
95                         }
96                 }
97
98                 if (!empty($data['url']) && !empty($data['alias']) && ($data['url'] == $data['alias'])) {
99                         unset($data['alias']);
100                 }
101
102                 return $data;
103         }
104
105         /**
106          * Fetches a profile from a given url
107          *
108          * @param string  $url    profile url
109          * @param boolean $update true = always update, false = never update, null = update when not found or outdated
110          * @return array profile array
111          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
112          * @throws \ImagickException
113          * @todo Rewrite parameter $update to avoid true|false|null (boolean is binary, null adds a third case)
114          */
115         public static function getByURL(string $url, $update = null): array
116         {
117                 if (empty($url) || Network::isUrlBlocked($url)) {
118                         Logger::info('Domain is blocked', ['url' => $url]);
119                         return [];
120                 }
121
122                 $fetched_contact = [];
123
124                 if (empty($update)) {
125                         if (is_null($update)) {
126                                 $ref_update = DateTimeFormat::utc('now - 1 month');
127                         } else {
128                                 $ref_update = DBA::NULL_DATETIME;
129                         }
130
131                         $apcontact = DBA::selectFirst('apcontact', [], ['url' => $url]);
132                         if (!DBA::isResult($apcontact)) {
133                                 $apcontact = DBA::selectFirst('apcontact', [], ['alias' => $url]);
134                         }
135
136                         if (!DBA::isResult($apcontact)) {
137                                 $apcontact = DBA::selectFirst('apcontact', [], ['addr' => $url]);
138                         }
139
140                         if (DBA::isResult($apcontact) && ($apcontact['updated'] > $ref_update) && !empty($apcontact['pubkey']) && !empty($apcontact['uri-id'])) {
141                                 return $apcontact;
142                         }
143
144                         if (!is_null($update)) {
145                                 return DBA::isResult($apcontact) ? $apcontact : [];
146                         }
147
148                         if (DBA::isResult($apcontact)) {
149                                 $fetched_contact = $apcontact;
150                         }
151                 }
152
153                 $apcontact = [];
154
155                 $webfinger = empty(parse_url($url, PHP_URL_SCHEME));
156                 if ($webfinger) {
157                         $apcontact = self::fetchWebfingerData($url);
158                         if (empty($apcontact['url'])) {
159                                 return $fetched_contact;
160                         }
161                         $url = $apcontact['url'];
162                 } elseif (empty(parse_url($url, PHP_URL_PATH))) {
163                         $apcontact['baseurl'] = $url;
164                 }
165
166                 // Detect multiple fast repeating request to the same address
167                 // See https://github.com/friendica/friendica/issues/9303
168                 $cachekey = 'apcontact:' . ItemURI::getIdByURI($url);
169                 $result = DI::cache()->get($cachekey);
170                 if (!is_null($result)) {
171                         Logger::notice('Multiple requests for the address', ['url' => $url, 'update' => $update, 'callstack' => System::callstack(20), 'result' => $result]);
172                         if (!empty($fetched_contact)) {
173                                 return $fetched_contact;
174                         }
175                 } else {
176                         DI::cache()->set($cachekey, System::callstack(20), Duration::FIVE_MINUTES);
177                 }
178
179                 if (Network::isLocalLink($url) && ($local_uid = User::getIdForURL($url))) {
180                         try {
181                                 $data = Transmitter::getProfile($local_uid);
182                                 $local_owner = User::getOwnerDataById($local_uid);
183                         } catch(HTTPException\NotFoundException $e) {
184                                 $data = null;
185                         }
186                 }
187
188                 if (empty($data)) {
189                         $local_owner = [];
190
191                         $curlResult = HTTPSignature::fetchRaw($url);
192                         $failed = empty($curlResult) || empty($curlResult->getBody()) ||
193                                 (!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410));
194
195                         if (!$failed) {
196                                 $data = json_decode($curlResult->getBody(), true);
197                                 $failed = empty($data) || !is_array($data);
198                         }
199
200                         if (!$failed && ($curlResult->getReturnCode() == 410)) {
201                                 $data = ['@context' => ActivityPub::CONTEXT, 'id' => $url, 'type' => 'Tombstone'];
202                         }
203
204                         if ($failed) {
205                                 self::markForArchival($fetched_contact ?: []);
206                                 return $fetched_contact;
207                         }
208                 }
209
210                 $compacted = JsonLD::compact($data);
211                 if (empty($compacted['@id'])) {
212                         return $fetched_contact;
213                 }
214
215                 $apcontact['url'] = $compacted['@id'];
216                 $apcontact['uuid'] = JsonLD::fetchElement($compacted, 'diaspora:guid', '@value');
217                 $apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
218                 $apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
219                 $apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
220                 $apcontact['inbox'] = (JsonLD::fetchElement($compacted, 'ldp:inbox', '@id') ?? '');
221                 $apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
222
223                 $apcontact['sharedinbox'] = '';
224                 if (!empty($compacted['as:endpoints'])) {
225                         $apcontact['sharedinbox'] = (JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id') ?? '');
226                 }
227
228                 $apcontact['featured']      = JsonLD::fetchElement($compacted, 'toot:featured', '@id');
229                 $apcontact['featured-tags'] = JsonLD::fetchElement($compacted, 'toot:featuredTags', '@id');
230
231                 $apcontact['nick'] = JsonLD::fetchElement($compacted, 'as:preferredUsername', '@value') ?? '';
232                 $apcontact['name'] = JsonLD::fetchElement($compacted, 'as:name', '@value');
233
234                 if (empty($apcontact['name'])) {
235                         $apcontact['name'] = $apcontact['nick'];
236                 }
237
238                 $apcontact['about'] = HTML::toBBCode(JsonLD::fetchElement($compacted, 'as:summary', '@value') ?? '');
239
240                 $ims = JsonLD::fetchElementArray($compacted, 'vcard:hasInstantMessage');
241
242                 if (!empty($ims)) {
243                         foreach ($ims as $link) {
244                                 if (substr($link, 0, 5) == 'xmpp:') {
245                                         $apcontact['xmpp'] = substr($link, 5);
246                                 }
247                                 if (substr($link, 0, 7) == 'matrix:') {
248                                         $apcontact['matrix'] = substr($link, 7);
249                                 }
250                         }
251                 }
252
253                 $apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id');
254                 if (is_array($apcontact['photo']) || !empty($compacted['as:icon']['as:url']['@id'])) {
255                         $apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
256                 }
257
258                 $apcontact['header'] = JsonLD::fetchElement($compacted, 'as:image', '@id');
259                 if (is_array($apcontact['header']) || !empty($compacted['as:image']['as:url']['@id'])) {
260                         $apcontact['header'] = JsonLD::fetchElement($compacted['as:image'], 'as:url', '@id');
261                 }
262
263                 if (empty($apcontact['alias'])) {
264                         $apcontact['alias'] = JsonLD::fetchElement($compacted, 'as:url', '@id');
265                         if (is_array($apcontact['alias'])) {
266                                 $apcontact['alias'] = JsonLD::fetchElement($compacted['as:url'], 'as:href', '@id');
267                         }
268                 }
269
270                 // Quit if none of the basic values are set
271                 if (empty($apcontact['url']) || empty($apcontact['type']) || (($apcontact['type'] != 'Tombstone') && empty($apcontact['inbox']))) {
272                         return $fetched_contact;
273                 } elseif ($apcontact['type'] == 'Tombstone') {
274                         // The "inbox" field must have a content
275                         $apcontact['inbox'] = '';
276                 }
277
278                 // Quit if this doesn't seem to be an account at all
279                 if (!in_array($apcontact['type'], ActivityPub::ACCOUNT_TYPES)) {
280                         return $fetched_contact;
281                 }
282
283                 if (empty($apcontact['addr'])) {
284                         try {
285                                 $apcontact['addr'] = $apcontact['nick'] . '@' . (new Uri($apcontact['url']))->getAuthority();
286                         } catch (\Throwable $e) {
287                                 Logger::warning('Unable to coerce APContact URL into a UriInterface object', ['url' => $apcontact['url'], 'error' => $e->getMessage()]);
288                                 $apcontact['addr'] = '';
289                         }
290                 }
291
292                 $apcontact['pubkey'] = null;
293                 if (!empty($compacted['w3id:publicKey'])) {
294                         $apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted['w3id:publicKey'], 'w3id:publicKeyPem', '@value') ?? '');
295                         if (strpos($apcontact['pubkey'], 'RSA ') !== false) {
296                                 $apcontact['pubkey'] = Crypto::rsaToPem($apcontact['pubkey']);
297                         }
298                 }
299
300                 $apcontact['manually-approve'] = (int)JsonLD::fetchElement($compacted, 'as:manuallyApprovesFollowers');
301
302                 $apcontact['suspended'] = (int)JsonLD::fetchElement($compacted, 'toot:suspended');
303
304                 if (!empty($compacted['as:generator'])) {
305                         $apcontact['baseurl'] = JsonLD::fetchElement($compacted['as:generator'], 'as:url', '@id');
306                         $apcontact['generator'] = JsonLD::fetchElement($compacted['as:generator'], 'as:name', '@value');
307                 }
308
309                 if (!empty($apcontact['following'])) {
310                         if (!empty($local_owner)) {
311                                 $following = ActivityPub\Transmitter::getContacts($local_owner, [Contact::SHARING, Contact::FRIEND], 'following');
312                         } else {
313                                 $following = ActivityPub::fetchContent($apcontact['following']);
314                         }
315                         if (!empty($following['totalItems'])) {
316                                 // Mastodon seriously allows for this condition?
317                                 // Jul 14 2021 - See https://mastodon.social/@BLUW for a negative following count
318                                 if ($following['totalItems'] < 0) {
319                                         $following['totalItems'] = 0;
320                                 }
321                                 $apcontact['following_count'] = $following['totalItems'];
322                         }
323                 }
324
325                 if (!empty($apcontact['followers'])) {
326                         if (!empty($local_owner)) {
327                                 $followers = ActivityPub\Transmitter::getContacts($local_owner, [Contact::FOLLOWER, Contact::FRIEND], 'followers');
328                         } else {
329                                 $followers = ActivityPub::fetchContent($apcontact['followers']);
330                         }
331                         if (!empty($followers['totalItems'])) {
332                                 // Mastodon seriously allows for this condition?
333                                 // Jul 14 2021 - See https://mastodon.online/@goes11 for a negative followers count
334                                 if ($followers['totalItems'] < 0) {
335                                         $followers['totalItems'] = 0;
336                                 }
337                                 $apcontact['followers_count'] = $followers['totalItems'];
338                         }
339                 }
340
341                 if (!empty($apcontact['outbox'])) {
342                         if (!empty($local_owner)) {
343                                 $statuses_count = self::getStatusesCount($local_owner);
344                         } else {
345                                 $outbox = ActivityPub::fetchContent($apcontact['outbox']);
346                                 $statuses_count = $outbox['totalItems'] ?? 0;
347                         }
348                         if (!empty($statuses_count)) {
349                                 // Mastodon seriously allows for this condition?
350                                 // Jul 20 2021 - See https://chaos.social/@m11 for a negative posts count
351                                 if ($statuses_count < 0) {
352                                         $statuses_count = 0;
353                                 }
354                                 $apcontact['statuses_count'] = $statuses_count;
355                         }
356                 }
357
358                 $apcontact['discoverable'] = JsonLD::fetchElement($compacted, 'toot:discoverable', '@value');
359
360                 if (!empty($apcontact['photo'])) {
361                         $apcontact['photo'] = trim($apcontact['photo']);
362                 }
363
364                 if (!empty($apcontact['photo']) && !Network::isValidHttpUrl($apcontact['photo'])) {
365                         Logger::warning('Invalid URL for photo', ['url' => $apcontact['url'], 'photo' => $apcontact['photo']]);
366                         $apcontact['photo'] = '';
367                 }
368
369                 // When the photo is too large, try to shorten it by removing parts
370                 if (strlen($apcontact['photo'] ?? '') > 255) {
371                         $parts = parse_url($apcontact['photo']);
372                         unset($parts['fragment']);
373                         $apcontact['photo'] = (string)Uri::fromParts($parts);
374
375                         if (strlen($apcontact['photo']) > 255) {
376                                 unset($parts['query']);
377                                 $apcontact['photo'] = (string)Uri::fromParts($parts);
378                         }
379
380                         if (strlen($apcontact['photo']) > 255) {
381                                 $apcontact['photo'] = substr($apcontact['photo'], 0, 255);
382                         }
383                 }
384
385                 if (!$webfinger && !empty($apcontact['addr'])) {
386                         $data = self::fetchWebfingerData($apcontact['addr']);
387                         if (!empty($data)) {
388                                 $apcontact['baseurl'] = $data['baseurl'];
389
390                                 if (empty($apcontact['alias']) && !empty($data['alias'])) {
391                                         $apcontact['alias'] = $data['alias'];
392                                 }
393                                 if (!empty($data['subscribe'])) {
394                                         $apcontact['subscribe'] = $data['subscribe'];
395                                 }
396                         } else {
397                                 $apcontact['addr'] = null;
398                         }
399                 }
400
401                 if (empty($apcontact['baseurl'])) {
402                         $apcontact['baseurl'] = null;
403                 }
404
405                 if (empty($apcontact['subscribe'])) {
406                         $apcontact['subscribe'] = null;
407                 }
408
409                 if (!empty($apcontact['baseurl']) && empty($fetched_contact['gsid'])) {
410                         $apcontact['gsid'] = GServer::getID($apcontact['baseurl']);
411                 } elseif (!empty($fetched_contact['gsid'])) {
412                         $apcontact['gsid'] = $fetched_contact['gsid'];
413                 } else {
414                         $apcontact['gsid'] = null;
415                 }
416
417                 self::unarchiveInbox($apcontact['inbox'], false, $apcontact['gsid']);
418
419                 if (!empty($apcontact['sharedinbox'])) {
420                         self::unarchiveInbox($apcontact['sharedinbox'], true, $apcontact['gsid']);
421                 }
422
423                 if ($apcontact['url'] == $apcontact['alias']) {
424                         $apcontact['alias'] = null;
425                 }
426
427                 if (empty($apcontact['uuid'])) {
428                         $apcontact['uri-id'] = ItemURI::getIdByURI($apcontact['url']);
429                 } else {
430                         $apcontact['uri-id'] = ItemURI::insert(['uri' => $apcontact['url'], 'guid' => $apcontact['uuid']]);
431                 }
432
433                 foreach (APContact\Endpoint::ENDPOINT_NAMES as $type => $name) {
434                         $value = JsonLD::fetchElement($compacted, $name, '@id');
435                         if (empty($value)) {
436                                 continue;
437                         }
438                         APContact\Endpoint::update($apcontact['uri-id'], $type, $value);
439                 }
440
441                 if (!empty($compacted['as:endpoints'])) {
442                         foreach ($compacted['as:endpoints'] as $name => $endpoint) {
443                                 if (empty($endpoint['@id']) || !is_string($endpoint['@id'])) {
444                                         continue;
445                                 }
446
447                                 if (in_array($name, APContact\Endpoint::ENDPOINT_NAMES)) {
448                                         $key = array_search($name, APContact\Endpoint::ENDPOINT_NAMES);
449                                         APContact\Endpoint::update($apcontact['uri-id'], $key, $endpoint['@id']);
450                                         Logger::debug('Store endpoint', ['key' => $key, 'name' => $name, 'endpoint' => $endpoint['@id']]);
451                                 } elseif (!in_array($name, ['as:sharedInbox', 'as:uploadMedia', 'as:oauthTokenEndpoint', 'as:oauthAuthorizationEndpoint', 'litepub:oauthRegistrationEndpoint'])) {
452                                         Logger::debug('Unknown endpoint', ['name' => $name, 'endpoint' => $endpoint['@id']]);
453                                 }
454                         }
455                 }
456
457                 $apcontact['updated'] = DateTimeFormat::utcNow();
458
459                 // We delete the old entry when the URL is changed
460                 if ($url != $apcontact['url']) {
461                         Logger::info('Delete changed profile url', ['old' => $url, 'new' => $apcontact['url']]);
462                         DBA::delete('apcontact', ['url' => $url]);
463                 }
464
465                 // Limit the length on incoming fields
466                 $apcontact = DI::dbaDefinition()->truncateFieldsForTable('apcontact', $apcontact);
467
468                 if (DBA::exists('apcontact', ['url' => $apcontact['url']])) {
469                         DBA::update('apcontact', $apcontact, ['url' => $apcontact['url']]);
470                 } else {
471                         DBA::replace('apcontact', $apcontact);
472                 }
473
474                 Logger::info('Updated profile', ['url' => $url]);
475
476                 return DBA::selectFirst('apcontact', [], ['url' => $apcontact['url']]) ?: [];
477         }
478
479         /**
480          * Fetch the number of statuses for the given owner
481          *
482          * @param array $owner
483          *
484          * @return integer
485          */
486         private static function getStatusesCount(array $owner): int
487         {
488                 $condition = [
489                         'private'        => [Item::PUBLIC, Item::UNLISTED],
490                         'author-id'      => Contact::getIdForURL($owner['url'], 0, false),
491                         'gravity'        => [Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT],
492                         'network'        => Protocol::DFRN,
493                         'parent-network' => Protocol::FEDERATED,
494                         'deleted'        => false,
495                         'visible'        => true,
496                 ];
497
498                 $count = Post::countPosts($condition);
499
500                 return $count;
501         }
502
503         /**
504          * Mark the given AP Contact as "to archive"
505          *
506          * @param array $apcontact
507          * @return void
508          */
509         public static function markForArchival(array $apcontact)
510         {
511                 if (!empty($apcontact['inbox'])) {
512                         Logger::info('Set inbox status to failure', ['inbox' => $apcontact['inbox']]);
513                         HTTPSignature::setInboxStatus($apcontact['inbox'], false, false, $apcontact['gsid']);
514                 }
515
516                 if (!empty($apcontact['sharedinbox'])) {
517                         // Check if there are any available inboxes
518                         $available = DBA::exists('apcontact', ["`sharedinbox` = ? AnD `inbox` IN (SELECT `url` FROM `inbox-status` WHERE `success` > `failure`)",
519                                 $apcontact['sharedinbox']]);
520                         if (!$available) {
521                                 // If all known personal inboxes are failing then set their shared inbox to failure as well
522                                 Logger::info('Set shared inbox status to failure', ['sharedinbox' => $apcontact['sharedinbox']]);
523                                 HTTPSignature::setInboxStatus($apcontact['sharedinbox'], false, true, $apcontact['gsid']);
524                         }
525                 }
526         }
527
528         /**
529          * Unmark the given AP Contact as "to archive"
530          *
531          * @param array $apcontact
532          * @return void
533          */
534         public static function unmarkForArchival(array $apcontact)
535         {
536                 if (!empty($apcontact['inbox'])) {
537                         Logger::info('Set inbox status to success', ['inbox' => $apcontact['inbox']]);
538                         HTTPSignature::setInboxStatus($apcontact['inbox'], true, false, $apcontact['gsid']);
539                 }
540                 if (!empty($apcontact['sharedinbox'])) {
541                         Logger::info('Set shared inbox status to success', ['sharedinbox' => $apcontact['sharedinbox']]);
542                         HTTPSignature::setInboxStatus($apcontact['sharedinbox'], true, true, $apcontact['gsid']);
543                 }
544         }
545
546         /**
547          * Unarchive inboxes
548          *
549          * @param string  $url    inbox url
550          * @param boolean $shared Shared Inbox
551          * @param int     $gsid   Global server id
552          * @return void
553          */
554         private static function unarchiveInbox(string $url, bool $shared, int $gsid = null)
555         {
556                 if (empty($url)) {
557                         return;
558                 }
559
560                 HTTPSignature::setInboxStatus($url, true, $shared, $gsid);
561         }
562
563         /**
564          * Check if the apcontact is a relay account
565          *
566          * @param array $apcontact
567          *
568          * @return bool
569          */
570         public static function isRelay(array $apcontact): bool
571         {
572                 if (empty($apcontact['nick']) || $apcontact['nick'] != 'relay') {
573                         return false;
574                 }
575
576                 if (!empty($apcontact['type']) && $apcontact['type'] == 'Application') {
577                         return true;
578                 }
579
580                 if (!empty($apcontact['type']) && in_array($apcontact['type'], ['Group', 'Service']) && is_null($apcontact['outbox'])) {
581                         return true;
582                 }
583
584                 return false;
585         }
586 }