all repos — underbbs @ c39c9f9412c817ee526926468d9b3d3dbe6d1663

decentralized social media client

models/msg.go (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package models

import (
	"encoding/json"
	"time"
)

type Datagram struct {
	Id       string
	Uri      string
	Protocol string
	Adapter  string
	Type     string
	Target   *string
}

type Message struct {
	Datagram
	Author      string
	Content     string
	Attachments []Attachment
	ReplyTo     *string
	Replies     []string
	ReplyCount  int
	Mentions    []string
	Created     time.Time
	Visibility  string
	Aux         map[string]string
}

type Author struct {
	Datagram
	Name        string
	ProfileData interface{}
	ProfilePic  string
	Messages    []Message
}

type Attachment struct {
	Src       string
	ThumbSrc  string
	Desc      string
	CreatedAt time.Time
	Size      uint64
}

type SocketData interface {
	ToDatagram() []byte
}

func (self Message) ToDatagram() []byte {
	data, err := json.Marshal(self)
	if err != nil {
		panic(err.Error())
	}
	return data
}