]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Notifier.php
Merge pull request #4243 from MrPetovan/task/switch-to-array-new-style
[friendica.git] / src / Worker / Notifier.php
index 50ac15200c6b900063f6f5fdb88d508037d8b7a9..7c1749f5fd566f91785b17bf2479e8b16dc36986 100644 (file)
@@ -66,8 +66,8 @@ class Notifier {
                $fsuggest = false;
                $relocate = false;
                $top_level = false;
-               $recipients = array();
-               $url_recipients = array();
+               $recipients = [];
+               $url_recipients = [];
 
                $normal_mode = true;
 
@@ -267,7 +267,7 @@ class Notifier {
 
                                $fields = ['forum', 'prv'];
                                $condition = ['id' => $target_item['contact-id']];
-                               $contact = dba::selectOne('contact', $fields, $condition);
+                               $contact = dba::selectFirst('contact', $fields, $condition);
                                if (!DBM::is_result($contact)) {
                                        // Should never happen
                                        return false;
@@ -284,8 +284,8 @@ class Notifier {
                                $followup = true;
                                $public_message = false; // not public
                                $conversant_str = dbesc($parent['contact-id']);
-                               $recipients = array($parent['contact-id']);
-                               $recipients_followup  = array($parent['contact-id']);
+                               $recipients = [$parent['contact-id']];
+                               $recipients_followup  = [$parent['contact-id']];
 
                                logger('notifier: followup '.$target_item["guid"].' to '.$conversant_str, LOGGER_DEBUG);
 
@@ -349,7 +349,7 @@ class Notifier {
                                        Worker::add($a->queue['priority'], 'Notifier', 'uplink', $item_id);
                                }
 
-                               $conversants = array();
+                               $conversants = [];
 
                                foreach ($items as $item) {
                                        $recipients[] = $item['contact-id'];
@@ -484,7 +484,7 @@ class Notifier {
                                }
                                logger("Deliver ".$target_item["guid"]." to ".$contact['url']." via network ".$contact['network'], LOGGER_DEBUG);
 
-                               Worker::add(array('priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true),
+                               Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
                                                'Delivery', $cmd, $item_id, (int)$contact['id']);
                        }
                }
@@ -507,8 +507,8 @@ class Notifier {
 
                if ($public_message) {
 
-                       $r0 = array();
-                       $r1 = array();
+                       $r0 = [];
+                       $r1 = [];
 
                        if ($diaspora_delivery) {
                                if (!$followup) {
@@ -522,6 +522,11 @@ class Notifier {
                                        intval($owner['uid']),
                                        intval(CONTACT_IS_SHARING)
                                );
+
+                               // Fetch the participation list
+                               // The function will ensure that there are no duplicates
+                               $r1 = Diaspora::participantsForThread($item_id, $r1);
+
                        }
 
                        $r2 = q("SELECT `id`, `name`,`network` FROM `contact`
@@ -531,7 +536,8 @@ class Notifier {
                                intval(CONTACT_IS_SHARING)
                        );
 
-                       $r = array_merge($r2,$r1,$r0);
+
+                       $r = array_merge($r2, $r1, $r0);
 
                        if (DBM::is_result($r)) {
                                logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
@@ -548,7 +554,7 @@ class Notifier {
 
                                        if (!$mail && !$fsuggest && !$followup) {
                                                logger('notifier: delivery agent: '.$rr['name'].' '.$rr['id'].' '.$rr['network'].' '.$target_item["guid"]);
-                                               Worker::add(array('priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true),
+                                               Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
                                                                'Delivery', $cmd, $item_id, (int)$rr['id']);
                                        }
                                }
@@ -568,7 +574,7 @@ class Notifier {
                        logger('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG);
 
                        // Handling the pubsubhubbub requests
-                       Worker::add(array('priority' => PRIORITY_HIGH, 'created' => $a->queue['created'], 'dont_fork' => true),
+                       Worker::add(['priority' => PRIORITY_HIGH, 'created' => $a->queue['created'], 'dont_fork' => true],
                                        'PubSubPublish');
                }