2025-12-03 19:29:37 +00:00
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ChatMessage struct {
|
|
|
|
|
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
|
2025-12-08 18:57:54 +00:00
|
|
|
ConversationID uuid.UUID `gorm:"column:room_id;type:uuid;not null" json:"conversation_id"`
|
2025-12-03 19:29:37 +00:00
|
|
|
SenderID uuid.UUID `gorm:"type:uuid;not null" json:"sender_id"`
|
|
|
|
|
Content string `gorm:"type:text;not null" json:"content"`
|
|
|
|
|
MessageType string `gorm:"type:varchar(50);not null" json:"message_type"` // text, image, audio, etc.
|
|
|
|
|
ParentMessageID *uuid.UUID `gorm:"type:uuid" json:"parent_message_id,omitempty"`
|
|
|
|
|
ReplyToID *uuid.UUID `gorm:"type:uuid" json:"reply_to_id,omitempty"`
|
|
|
|
|
IsPinned bool `gorm:"default:false;not null" json:"is_pinned"`
|
|
|
|
|
IsEdited bool `gorm:"default:false;not null" json:"is_edited"`
|
|
|
|
|
IsDeleted bool `gorm:"default:false;not null" json:"is_deleted"`
|
|
|
|
|
EditedAt *time.Time `json:"edited_at,omitempty"`
|
|
|
|
|
Status string `gorm:"type:varchar(50);not null" json:"status"` // sent, delivered, read
|
|
|
|
|
Metadata []byte `gorm:"type:jsonb" json:"metadata,omitempty"` // JSONB for additional data
|
|
|
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
|
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ChatMessage) TableName() string {
|
|
|
|
|
return "messages" // Rust uses 'messages' table
|
|
|
|
|
}
|