[COMPONENT][Posting] When a group is mentioned, add that note to the group inbox

This commit is contained in:
Hugo Sales 2021-12-21 12:43:28 +00:00
parent d6d5926b6e
commit 85735222cb
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -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;