package mloco

type Chat struct {
	ChatID int64  `bson:"chatId"`
	Type   int32  `bson:"type"`
	Name   string `bson:"name"`
	Active bool   `bson:"active"`
}

type ChatLog struct {
	LogID     int64  `bson:"logId"`
	ChatID    int64  `bson:"chatId"`
	AuthorID  int64  `bson:"authorId"`
	Message   string `bson:"message"`
	Type      int32  `bson:"type"`
	SendAt    int64  `bson:"sendAt"`
	PrevLogID int64  `bson:"prevLogId"`
}

func (l ChatLog) IsMedia() bool {
	return l.Type == int32(MsgTypePhoto) || l.Type == int32(MsgTypeVideo) ||
		l.Type == int32(MsgTypeAudio) || l.Type == int32(MsgTypeGIF) ||
		l.Type == int32(MsgTypeFile)
}

type Member struct {
	MemberID int64  `bson:"memberId"`
	Nickname string `bson:"nickname"`
	UserID   int64  `bson:"userId"`
}

type Attachment struct {
	URL      string `bson:"url" json:"url"`
	Key      string `bson:"k" json:"k"`
	Name     string `bson:"name" json:"name"`
	Width    int32  `bson:"width" json:"width"`
	Height   int32  `bson:"height" json:"height"`
	Type     string `bson:"type" json:"type"`
	Size     int64  `bson:"size" json:"size"`
}

type messageType int32

const (
	MsgTypeText  messageType = 1
	MsgTypePhoto messageType = 2
	MsgTypeVideo messageType = 3
	MsgTypeAudio messageType = 12
	MsgTypeGIF   messageType = 14
	MsgTypeFile  messageType = 26
)
