- Add migrations 109-112: read_receipts, delivered_status, message_reactions, messages extra columns - Create ReadReceipt, DeliveredStatus, MessageReaction GORM models - Update Message model with EditedAt, Status, IsPinned, Metadata fields - Enrich ChatMessageRepository with cursor pagination, search, soft delete - Create ReadReceiptRepository, DeliveredStatusRepository, ReactionRepository - Create ChatPubSubService with Redis PubSub and in-memory fallback
24 lines
626 B
Go
24 lines
626 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type ReadReceipt struct {
|
|
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
|
|
UserID uuid.UUID `gorm:"type:uuid;not null;uniqueIndex:uq_read_receipts_user_message" json:"user_id"`
|
|
MessageID uuid.UUID `gorm:"type:uuid;not null;uniqueIndex:uq_read_receipts_user_message" json:"message_id"`
|
|
ReadAt time.Time `gorm:"autoCreateTime" json:"read_at"`
|
|
}
|
|
|
|
func (r *ReadReceipt) BeforeCreate(tx *gorm.DB) error {
|
|
if r.ID == uuid.Nil {
|
|
r.ID = uuid.New()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (ReadReceipt) TableName() string { return "read_receipts" }
|