65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package models
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
type Datagram struct {
|
|
Id string `json:"id"`
|
|
Uri string `json:"uri"`
|
|
Protocol string `json:"protocol"`
|
|
Adapter string `json:"adapter"`
|
|
Type string `json:"type"`
|
|
Target *string `json:"target,omitempty"`
|
|
Created int64 `json:"created"`
|
|
Updated *int64 `json:"updated,omitempty"`
|
|
}
|
|
|
|
type Message struct {
|
|
Datagram
|
|
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"`
|
|
RenoteId *string `json:"renoteId,omitempty"`
|
|
}
|
|
|
|
type Author struct {
|
|
Datagram
|
|
Name string `json:"name"`
|
|
ProfileData interface{} `json:"profileData"`
|
|
ProfilePic string `json:"profilePic"`
|
|
Messages []string `json:"messages,omitempty"`
|
|
}
|
|
|
|
type Attachment struct {
|
|
Src string `json:"src"`
|
|
ThumbSrc string `json:"thumbSrc"`
|
|
Desc string `json:"desc"`
|
|
Created int64 `json:"created"`
|
|
Size uint64 `json:"size"`
|
|
}
|
|
|
|
type SocketData interface {
|
|
ToDatagram() []byte
|
|
}
|
|
|
|
func (self Message) ToDatagram() []byte {
|
|
data, err := json.Marshal(self)
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
return data
|
|
}
|
|
|
|
func (self Author) ToDatagram() []byte {
|
|
data, err := json.Marshal(self)
|
|
if err != nil {
|
|
panic(err.Error())
|
|
}
|
|
return data
|
|
}
|