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
|
|
|
)
|
|
|
|
|
2024-06-30 00:18:31 +00:00
|
|
|
type Datagram struct {
|
2024-07-07 20:54:33 +00:00
|
|
|
Id string `json:"id"`
|
|
|
|
Uri string `json:"uri"`
|
|
|
|
Protocol string `json:"protocol"`
|
|
|
|
Adapter string `json:"adapter"`
|
|
|
|
Type string `json:"type"`
|
2024-07-05 01:27:29 +00:00
|
|
|
Target *string `json:"target,omitempty"`
|
2024-08-03 16:52:33 +00:00
|
|
|
Created int64 `json:"created"`
|
|
|
|
Updated *int64 `json:"updated,omitempty"`
|
2024-06-30 00:18:31 +00:00
|
|
|
}
|
|
|
|
|
2024-05-10 04:14:40 +00:00
|
|
|
type Message struct {
|
2024-06-30 00:18:31 +00:00
|
|
|
Datagram
|
2024-07-07 20:54:33 +00:00
|
|
|
Author string `json:"author"`
|
|
|
|
Content string `json:"content"`
|
|
|
|
Attachments []Attachment `json:"attachments"`
|
|
|
|
ReplyTo *string `json:"replyTo"`
|
|
|
|
Replies []string `json:"replies"`
|
|
|
|
ReplyCount int `json:"replyCount"`
|
|
|
|
Mentions []string `json:"mentions"`
|
|
|
|
Visibility string `json:"visibility"`
|
2024-05-10 04:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Author struct {
|
2024-06-30 00:18:31 +00:00
|
|
|
Datagram
|
2024-07-07 20:54:33 +00:00
|
|
|
Name string `json:"name"`
|
2024-07-05 01:27:29 +00:00
|
|
|
ProfileData interface{} `json:"profileData"`
|
2024-07-07 20:54:33 +00:00
|
|
|
ProfilePic string `json:"profilePic"`
|
|
|
|
Messages []string `json:"messages,omitempty"`
|
2024-05-10 04:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Attachment struct {
|
2024-08-03 16:52:33 +00:00
|
|
|
Src string `json:"src"`
|
|
|
|
ThumbSrc string `json:"thumbSrc"`
|
|
|
|
Desc string `json:"desc"`
|
|
|
|
Created int64 `json:"created"`
|
|
|
|
Size uint64 `json:"size"`
|
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
|
|
|
|
}
|
2024-07-07 03:13:18 +00:00
|
|
|
|
|
|
|
func (self Author) ToDatagram() []byte {
|
|
|
|
data, err := json.Marshal(self)
|
|
|
|
if err != nil {
|
|
|
|
panic(err.Error())
|
|
|
|
}
|
|
|
|
return data
|
|
|
|
}
|