- /**
- * Checks if the current delivery process needs to be transported via DFRN.
- *
- * @param array $contact Receiver of the post
- * @param array $item The post
- * @param array $parent The parent
- * @param array $thr_parent The thread parent
- * @param array $owner Owner array
- * @param string $cmd Notifier command
- * @return bool
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- * @throws \ImagickException
- */
- private static function skipDFRN($contact, $item, $parent, $thr_parent, $owner, $cmd)
- {
- if (empty($parent['network'])) {
- return false;
- }
-
- // Don't skip when the starting post is delivered via Diaspora
- if ($parent['network'] == Protocol::DIASPORA) {
- return false;
- }
-
- // Also don't skip when the direct thread parent was delivered via Diaspora
- if ($thr_parent['network'] == Protocol::DIASPORA) {
- return false;
- }
-
- // Use DFRN if we are on the same site
- if (!empty($contact['url']) && Contact::isLocal($contact['url'])) {
- return false;
- }
-
- // Don't skip when author or owner don't have AP profiles
- if ((!empty($item['author-link']) && empty(APContact::getByURL($item['author-link'], false))) || (!empty($item['owner-link']) && empty(APContact::getByURL($item['owner-link'], false)))) {
- return false;
- }
-
- // Don't skip DFRN delivery for these commands
- if (in_array($cmd, [Delivery::SUGGESTION, Delivery::REMOVAL, Delivery::RELOCATION, Delivery::POKE])) {
- return false;
- }
-
- // We deliver reshares via AP whenever possible
- if (ActivityPub\Transmitter::isAnnounce($item)) {
- return true;
- }
-
- // For the time being we always deliver forum post via DFRN if possible
- // This can be removed possible at the end of 2020 when hopefully most system can process AP forum posts
- if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
- return false;
- }
-
- // Skip DFRN when the item will be (forcefully) delivered via AP
- if (DI::config()->get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) {
- return true;
- }
-
- // Skip DFRN delivery if the contact speaks ActivityPub
- return in_array($contact['network'], [Protocol::DFRN, Protocol::DIASPORA]) && ($contact['protocol'] == Protocol::ACTIVITYPUB);
- }
-