veza/veza-backend-api/internal/models/chat_message.go
senke a1000ce7fb style(backend): gofmt -w on 85 files (whitespace only)
backend-ci.yml's `test -z "$(gofmt -l .)"` strict gate (added in
13c21ac11) failed on a backlog of unformatted files. None of the
85 files in this commit had been edited since the gate was added
because no push touched veza-backend-api/** in between, so the
gate never fired until today's CI fixes triggered it.

The diff is exclusively whitespace alignment in struct literals
and trailing-space comments. `go build ./...` and the full test
suite (with VEZA_SKIP_INTEGRATION=1 -short) pass identically.
2026-04-14 12:22:14 +02:00

31 lines
1.6 KiB
Go

package models
import (
"time"
"github.com/google/uuid"
)
type ChatMessage struct {
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
ConversationID uuid.UUID `gorm:"column:room_id;type:uuid;not null" json:"conversation_id"`
SenderID uuid.UUID `gorm:"type:uuid;not null" json:"sender_id"`
Sender *User `gorm:"foreignKey:SenderID" json:"-"` // v0.9.7: for history sender_username
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:"-" json:"parent_message_id,omitempty"` // Not persisted; use ReplyToID for DB
ReplyToID *uuid.UUID `gorm:"column:reply_to_id;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
ContentTsv *string `gorm:"type:tsvector;->" json:"-"`
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
}