From 85735222cbe7cee5260fb0f71cf6541e36363b39 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Tue, 21 Dec 2021 12:43:28 +0000 Subject: [PATCH] [COMPONENT][Posting] When a group is mentioned, add that note to the group inbox --- components/Posting/Posting.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/Posting/Posting.php b/components/Posting/Posting.php index c9e6099b86..d2f68e48fc 100644 --- a/components/Posting/Posting.php +++ b/components/Posting/Posting.php @@ -34,6 +34,7 @@ use App\Core\Router\Router; use App\Core\Security; use App\Entity\Activity; use App\Entity\Actor; +use App\Entity\GroupInbox; use App\Entity\Language; use App\Entity\Note; use App\Util\Common; @@ -229,17 +230,23 @@ class Posting extends Component ]); DB::persist($activity); - DB::flush(); - $mentioned = []; foreach ($mentions as $mention) { foreach ($mention['mentioned'] as $m) { if (!\is_null($m)) { $mentioned[] = $m->getId(); + + if ($m->isGroup()) { + DB::persist(GroupInbox::create([ + 'group_id' => $m->getId(), + 'activity_id' => $activity->getId(), + ])); + } } } } + DB::flush(); Event::handle('NewNotification', [$actor, $activity, ['object' => $mentioned], "{$actor->getNickname()} created note {$note->getUrl()}"]); return $note;