+ // delivery loop
+ if (DBA::isResult($contacts)) {
+ foreach ($contacts as $contact) {
+ // Don't deliver to Diaspora if it already had been done as batch delivery
+ if (($contact['network'] == Protocol::DIASPORA) && $batch_delivery) {
+ Logger::log('Already delivered id ' . $target_id . ' via batch to ' . json_encode($contact), Logger::DEBUG);
+ continue;
+ }
+
+ // Don't deliver to folks who have already been delivered to
+ if (in_array($contact['id'], $conversants)) {
+ Logger::log('Already delivered id ' . $target_id. ' to ' . json_encode($contact), Logger::DEBUG);
+ continue;
+ }
+
+ Logger::log('Delivery of item ' . $target_id . ' to ' . json_encode($contact), 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 ($contact['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];
+ }
+ Worker::add($deliver_options, 'Delivery', $cmd, $target_id, (int)$contact['id']);
+ }
+ }
+
+ // send salmon slaps to mentioned remote tags (@foo@example.com) in OStatus posts
+ // They are especially used for notifications to OStatus users that don't follow us.
+ if (!Config::get('system', 'dfrn_only') && count($url_recipients) && ($public_message || $push_notify) && $normal_mode) {
+ $slap = OStatus::salmon($target_item, $owner);
+ foreach ($url_recipients as $url) {
+ if ($url) {
+ Logger::log('Salmon delivery of item ' . $target_id . ' to ' . $url);
+ /// @TODO Redeliver/queue these items on failure, though there is no contact record
+ Salmon::slapper($owner, $url, $slap);
+ }
+ }
+ }
+