]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Notifier.php
wrapping up 2019.12
[friendica.git] / src / Worker / Notifier.php
index 2b802c9e3caad5e9a4ae6c3a80d97a2754e22170..19bd51885667d24de462a575237a6e3bbd37b4b1 100644 (file)
@@ -51,6 +51,8 @@ class Notifier
 
                $delivery_contacts_stmt = null;
                $target_item = [];
+               $parent = [];
+               $thr_parent = [];
                $items = [];
                $delivery_queue_count = 0;
 
@@ -152,6 +154,9 @@ class Notifier
                        $fields = ['network', 'author-id', 'author-link', 'owner-id'];
                        $condition = ['uri' => $target_item["thr-parent"], 'uid' => $target_item["uid"]];
                        $thr_parent = Item::selectFirst($fields, $condition);
+                       if (empty($thr_parent)) {
+                               $thr_parent = $parent;
+                       }
 
                        Logger::log('GUID: ' . $target_item["guid"] . ': Parent is ' . $parent['network'] . '. Thread parent is ' . $thr_parent['network'], Logger::DEBUG);
 
@@ -276,10 +281,10 @@ class Notifier
                                /** @var ACLFormatter $aclFormatter */
                                $aclFormatter = BaseObject::getClass(ACLFormatter::class);
 
-                               $allow_people = $aclFormatter->expand($parent['allow_cid'] ?? '');
-                               $allow_groups = Group::expand($uid, $aclFormatter->expand($parent['allow_gid'] ?? ''),true);
-                               $deny_people  = $aclFormatter->expand($parent['deny_cid'] ?? '');
-                               $deny_groups  = Group::expand($uid, $aclFormatter->expand($parent['deny_gid'] ?? ''));
+                               $allow_people = $aclFormatter->expand($parent['allow_cid']);
+                               $allow_groups = Group::expand($uid, $aclFormatter->expand($parent['allow_gid']),true);
+                               $deny_people  = $aclFormatter->expand($parent['deny_cid']);
+                               $deny_groups  = Group::expand($uid, $aclFormatter->expand($parent['deny_gid']));
 
                                // if our parent is a public forum (forum_mode == 1), uplink to the origional author causing
                                // a delivery fork. private groups (forum_mode == 2) do not uplink
@@ -401,6 +406,7 @@ class Notifier
                                        "SELECT
                                                `batch`,
                                                ANY_VALUE(`id`) AS `id`,
+                                               ANY_VALUE(`url`) AS `url`,
                                                ANY_VALUE(`name`) AS `name`,
                                                ANY_VALUE(`network`) AS `network`,
                                                ANY_VALUE(`protocol`) AS `protocol`
@@ -500,7 +506,7 @@ class Notifier
                        }
 
                        if (self::skipDFRN($contact, $target_item, $parent, $thr_parent, $cmd)) {
-                               Logger::info('Contact can be delivered via AP, so skip delivery via legacy DFRN/Diaspora', ['target' => $target_id, 'url' => contact['url']]);
+                               Logger::info('Contact can be delivered via AP, so skip delivery via legacy DFRN/Diaspora', ['target' => $target_id, 'url' => $contact['url']]);
                                continue;
                        }
 
@@ -590,6 +596,10 @@ class Notifier
         */
        private static function skipDFRN($contact, $item, $parent, $thr_parent, $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;
@@ -615,6 +625,11 @@ class Notifier
                        return false;
                }
 
+               // We deliver reshares via AP whenever possible
+               if (ActivityPub\Transmitter::isAnnounce($item)) {
+                       return true;
+               }
+
                // Skip DFRN when the item will be (forcefully) delivered via AP
                if (Config::get('debug', 'total_ap_delivery') && ($contact['network'] == Protocol::DFRN) && !empty(APContact::getByURL($contact['url'], false))) {
                        return true;