underbbs/models/msg.go

47 lines
727 B
Go

package models
import (
"encoding/json"
"time"
)
type Message struct {
Uri string
Author Author
Protocol string
Adapter string
Content string
Attachments []Attachment
ReplyTo *string
Replies []*string
Mentions []Author
Created time.Time
Aux map[string]string
}
type Author struct {
Id string
Name string
ProfileData interface{}
Messages []Message
ProfileUri string
ProfilePic string
}
type Attachment struct {
Src string
Data []uint8
Desc string
}
type SocketData interface {
ToDatagram() []byte
}
func (self Message) ToDatagram() []byte {
data, err := json.Marshal(self)
if err != nil {
panic(err.Error())
}
return data
}