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
|
2024-06-08 20:40:14 +00:00
|
|
|
Adapter string
|
2024-05-10 04:14:40 +00:00
|
|
|
Content string
|
|
|
|
Attachments []Attachment
|
2024-06-08 20:40:14 +00:00
|
|
|
ReplyTo *string
|
|
|
|
Replies []*string
|
2024-05-10 04:14:40 +00:00
|
|
|
Mentions []Author
|
|
|
|
Created time.Time
|
2024-06-08 20:40:14 +00:00
|
|
|
Aux map[string]string
|
2024-05-10 04:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|