underbbs/models/msg.go

51 lines
793 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
Author string
2024-05-10 04:14:40 +00:00
Protocol string
Adapter string
2024-05-10 04:14:40 +00:00
Content string
Attachments []Attachment
ReplyTo *string
Replies []string
ReplyCount int
Mentions []string
2024-05-10 04:14:40 +00:00
Created time.Time
Visibility string
Aux map[string]string
2024-05-10 04:14:40 +00:00
}
type Author struct {
Id string
Name string
ProfileData interface{}
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
ThumbSrc string
Desc string
CreatedAt time.Time
Size uint64
2024-05-10 04:14:40 +00:00
}
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
}