- 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
660 B
Go
24 lines
660 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type DeliveredStatus struct {
|
|
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
|
|
UserID uuid.UUID `gorm:"type:uuid;not null;uniqueIndex:uq_delivered_status_user_message" json:"user_id"`
|
|
MessageID uuid.UUID `gorm:"type:uuid;not null;uniqueIndex:uq_delivered_status_user_message" json:"message_id"`
|
|
DeliveredAt time.Time `gorm:"autoCreateTime" json:"delivered_at"`
|
|
}
|
|
|
|
func (d *DeliveredStatus) BeforeCreate(tx *gorm.DB) error {
|
|
if d.ID == uuid.Nil {
|
|
d.ID = uuid.New()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (DeliveredStatus) TableName() string { return "delivered_status" }
|