]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Notifier.php
update to the FI translation THX Kris
[friendica.git] / src / Worker / Notifier.php
index 2dc5dca581605be853513ac98a1917c1fd8b506c..422adafede712452f84c77177437a984c62b14eb 100644 (file)
@@ -18,9 +18,7 @@ use Friendica\Protocol\Salmon;
 use dba;
 
 require_once 'include/dba.php';
-require_once 'include/html2plain.php';
 require_once 'include/items.php';
-require_once 'include/bbcode.php';
 
 /*
  * This file was at one time responsible for doing all deliveries, but this caused
@@ -67,6 +65,7 @@ class Notifier {
                $url_recipients = [];
 
                $normal_mode = true;
+               $recipients_relocate = [];
 
                if ($cmd === 'mail') {
                        $normal_mode = false;
@@ -178,6 +177,10 @@ class Notifier {
                // fill this in with a single salmon slap if applicable
                $slap = '';
 
+               $followup = false;
+               $recipients_followup = [];
+               $conversants = [];
+               $sql_extra = '';
                if (! ($mail || $fsuggest || $relocate)) {
 
                        $slap = OStatus::salmon($target_item, $owner);
@@ -321,8 +324,6 @@ class Notifier {
                                        Worker::add($a->queue['priority'], 'Notifier', 'uplink', $item_id);
                                }
 
-                               $conversants = [];
-
                                foreach ($items as $item) {
                                        $recipients[] = $item['contact-id'];
                                        $conversants[] = $item['contact-id'];
@@ -478,15 +479,9 @@ class Notifier {
 
 
                if ($public_message) {
-
-                       $r0 = [];
                        $r1 = [];
 
                        if ($diaspora_delivery) {
-                               if (!$followup) {
-                                       $r0 = Diaspora::relayList();
-                               }
-
                                $r1 = q("SELECT `batch`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`name`) AS `name`, ANY_VALUE(`network`) AS `network`
                                        FROM `contact` WHERE `network` = '%s' AND `batch` != ''
                                        AND `uid` = %d AND `rel` != %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` GROUP BY `batch`",
@@ -499,17 +494,17 @@ class Notifier {
                                // The function will ensure that there are no duplicates
                                $r1 = Diaspora::participantsForThread($item_id, $r1);
 
+                               // Add the relay to the list, avoid duplicates
+                               if (!$followup) {
+                                       $r1 = Diaspora::relayList($item_id, $r1);
+                               }
                        }
 
-                       $r2 = q("SELECT `id`, `name`,`network` FROM `contact`
-                               WHERE `network` in ('%s') AND `uid` = %d AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `rel` != %d",
-                               dbesc(NETWORK_DFRN),
-                               intval($owner['uid']),
-                               intval(CONTACT_IS_SHARING)
-                       );
-
+                       $condition = ['network' => NETWORK_DFRN, 'uid' => $owner['uid'], 'blocked' => false,
+                               'pending' => false, 'archive' => false, 'rel' => [CONTACT_IS_FOLLOWER, CONTACT_IS_FRIEND]];
+                       $r2 = dba::inArray(dba::select('contact', ['id', 'name', 'network'], $condition));
 
-                       $r = array_merge($r2, $r1, $r0);
+                       $r = array_merge($r2, $r1);
 
                        if (DBM::is_result($r)) {
                                logger('pubdeliver '.$target_item["guid"].': '.print_r($r,true), LOGGER_DEBUG);
@@ -519,7 +514,7 @@ class Notifier {
                                        // except for Diaspora batch jobs
                                        // Don't deliver to folks who have already been delivered to
 
-                                       if (($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'],$conversants))) {
+                                       if (($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'], $conversants))) {
                                                logger('notifier: already delivered id=' . $rr['id']);
                                                continue;
                                        }
@@ -540,8 +535,8 @@ class Notifier {
                if ($push_notify) {
                        // Set push flag for PuSH subscribers to this topic,
                        // they will be notified in queue.php
-                       q("UPDATE `push_subscriber` SET `push` = 1 ".
-                         "WHERE `nickname` = '%s' AND `push` = 0", dbesc($owner['nickname']));
+                       $condition = ['push' => false, 'nickname' => $owner['nickname']];
+                       dba::update('push_subscriber', ['push' => true], $condition);
 
                        logger('Activating internal PuSH for item '.$item_id, LOGGER_DEBUG);
 
@@ -553,7 +548,7 @@ class Notifier {
                logger('notifier: calling hooks', LOGGER_DEBUG);
 
                if ($normal_mode) {
-                       Addon::callHooks('notifier_normal',$target_item);
+                       Addon::forkHooks($a->queue['priority'], 'notifier_normal', $target_item);
                }
 
                Addon::callHooks('notifier_end',$target_item);