+ $relay_list = DBA::toArray($relay_list_stmt);
+
+ // Fetch the participation list
+ // The function will ensure that there are no duplicates
+ $relay_list = Diaspora::participantsForThread($target_id, $relay_list);
+
+ // Add the relay to the list, avoid duplicates.
+ // Don't send community posts to the relay. Forum posts via the Diaspora protocol are looking ugly.
+ if (!$followup && !self::isForumPost($target_item, $owner)) {
+ $relay_list = Diaspora::relayList($target_id, $relay_list);
+ }
+ }
+
+ $condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
+ 'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
+
+ $r2 = DBA::toArray(DBA::select('contact', ['id', 'url', 'name', 'network'], $condition));
+
+ $r = array_merge($r2, $relay_list);
+
+ if (DBA::isResult($r)) {
+ foreach ($r as $rr) {
+ if (Config::get('debug', 'total_ap_delivery') && !empty($rr['url']) && ($rr['network'] == Protocol::DFRN) && !empty(APContact::getByURL($rr['url'], false))) {
+ Logger::log('Skipping contact ' . $rr['url'] . ' since it will be delivered via AP', Logger::DEBUG);
+ continue;
+ }
+
+ $conversants[] = $rr['id'];
+
+ $delivery_queue_count++;
+
+ Logger::log('Public delivery of item ' . $target_item["guid"] . ' (' . $target_id . ') to ' . json_encode($rr), Logger::DEBUG);
+
+ // Ensure that posts with our own protocol arrives before Diaspora posts arrive.
+ // Situation is that sometimes Friendica servers receive Friendica posts over the Diaspora protocol first.
+ // The conversion in Markdown reduces the formatting, so these posts should arrive after the Friendica posts.
+ if ($rr['network'] == Protocol::DIASPORA) {
+ $deliver_options = ['priority' => $a->queue['priority'], 'dont_fork' => true];
+ } else {
+ $deliver_options = ['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true];