package model

import (
	"time"

	"github.com/rs/zerolog"
)

type Message struct {
	Text   string  `json:"text"`
	Guid   string  `json:"guid"`
	Sender *string `json:"sender,omitempty"` // Optional: nil means from "me"
	Date   Date    `json:"date"`

	// Map of attachment GUID to attachment metadata
	AttachmentGUIDs    []string                    `json:"fileTransferGUIDs,omitempty"`
	AttachmentMetadata *map[string]AttributionInfo `json:"attachmentMetadata,omitempty"` // Optional
}

type AttributionInfo struct {
	ThumbnailWidth  int `json:"pgensw"`
	ThumbnailHeight int `json:"pgensh"`
}

func (c Message) MarshalZerologObject(e *zerolog.Event) {
	e.Str("guid", c.Guid)
	e.Str("text", c.Text)
	e.Time("date", time.Time(c.Date))

	if c.Sender != nil {
		e.Str("sender", *c.Sender)
	} else {
		e.Str("sender", "(Me)")
	}
}
