underbbs/models/msg.go

47 lines
703 B
Go
Raw Normal View History

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