feat: add Reverb realtime messaging

This commit is contained in:
2026-03-21 12:51:59 +01:00
parent 60f78e8235
commit e8b5edf5d2
45 changed files with 3609 additions and 339 deletions

View File

@@ -23,14 +23,18 @@ class Conversation extends Model
use HasFactory;
protected $fillable = [
'uuid',
'type',
'title',
'created_by',
'last_message_id',
'last_message_at',
'is_active',
];
protected $casts = [
'last_message_at' => 'datetime',
'is_active' => 'boolean',
];
// ── Relationships ────────────────────────────────────────────────────────
@@ -81,6 +85,7 @@ class Conversation extends Model
{
return self::query()
->where('type', 'direct')
->where('is_active', true)
->whereHas('allParticipants', fn ($q) => $q->where('user_id', $userA)->whereNull('left_at'))
->whereHas('allParticipants', fn ($q) => $q->where('user_id', $userB)->whereNull('left_at'))
->whereRaw(
@@ -108,6 +113,11 @@ class Conversation extends Model
->whereNull('deleted_at')
->where('sender_id', '!=', $userId);
if ($participant->last_read_message_id) {
$query->where('id', '>', $participant->last_read_message_id);
return $query->count();
}
if ($participant->last_read_at) {
$query->where('created_at', '>', $participant->last_read_at);
}