diff --git a/app/Jobs/ProcessMassPM.php b/app/Jobs/ProcessMassPM.php index 67980bde7c..097192be2f 100644 --- a/app/Jobs/ProcessMassPM.php +++ b/app/Jobs/ProcessMassPM.php @@ -18,7 +18,6 @@ use App\Models\Conversation; use App\Models\PrivateMessage; -use App\Models\User; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -46,13 +45,7 @@ public function handle(): void { $conversation = Conversation::create(['subject' => $this->subject]); - if ($this->senderId !== User::SYSTEM_USER_ID) { - $conversation->users()->sync([$this->senderId => ['read' => true]]); - } - - if ($this->receiverId !== User::SYSTEM_USER_ID) { - $conversation->users()->sync([$this->receiverId]); - } + $conversation->users()->sync([$this->senderId => ['read' => true], $this->receiverId]); PrivateMessage::create([ 'conversation_id' => $conversation->id, diff --git a/app/Models/User.php b/app/Models/User.php index e2abf44130..f754c749cb 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -948,7 +948,7 @@ public function sendSystemNotification(string $subject, string $message): void { $conversation = Conversation::create(['subject' => $subject]); - $conversation->users()->sync([$this->id]); + $conversation->users()->sync([User::SYSTEM_USER_ID => ['read' => true], $this->id]); PrivateMessage::create([ 'conversation_id' => $conversation->id, @@ -961,7 +961,7 @@ public static function sendSystemNotificationTo(int $userId, string $subject, st { $conversation = Conversation::create(['subject' => $subject]); - $conversation->users()->sync([$userId]); + $conversation->users()->sync([User::SYSTEM_USER_ID => ['read' => true], $userId]); PrivateMessage::create([ 'conversation_id' => $conversation->id,