From 4fcae18289aecfd9bd4abd2df15381eaf64403ca Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 1 Sep 2018 03:23:12 +0000 Subject: [PATCH] Issue 5262: Comments to a forum post aren't distributed via push --- src/Worker/Notifier.php | 43 ++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 401178ec26..6d2733b8ee 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -217,24 +217,16 @@ class Notifier } // Special treatment for forum posts - if (($target_item['author-id'] != $target_item['owner-id']) && - ($owner['id'] != $target_item['contact-id']) && - ($target_item['uri'] === $target_item['parent-uri'])) { - - $fields = ['forum', 'prv']; - $condition = ['id' => $target_item['contact-id']]; - $contact = DBA::selectFirst('contact', $fields, $condition); - if (!DBA::isResult($contact)) { - // Should never happen - return false; - } + if (self::isForumPost($target_item, $owner)) { + $relay_to_owner = true; + $direct_forum_delivery = true; + } - // Is the post from a forum? - if ($contact['forum'] || $contact['prv']) { - $relay_to_owner = true; - $direct_forum_delivery = true; - } + // Avoid that comments in a forum thread are sent to OStatus + if (self::isForumPost($parent, $owner)) { + $direct_forum_delivery = true; } + if ($relay_to_owner) { // local followup to remote post $followup = true; @@ -504,4 +496,23 @@ class Notifier return; } + + private static function isForumPost($item, $owner) { + if (($item['author-id'] == $item['owner-id']) || + ($owner['id'] == $item['contact-id']) || + ($item['uri'] != $item['parent-uri'])) { + return false; + } + + $fields = ['forum', 'prv']; + $condition = ['id' => $item['contact-id']]; + $contact = DBA::selectFirst('contact', $fields, $condition); + if (!DBA::isResult($contact)) { + // Should never happen + return false; + } + + // Is the post from a forum? + return ($contact['forum'] || $contact['prv']); + } } -- 2.39.5