all repos — underbbs @ c2aa71512e0b077ec8a89bf72509c58917142b7e

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
package models

import (
	"encoding/json"
	"time"
)

type Message struct {
	Uri         string
	Author      Author
	Protocol    string
	Adapter     string
	Content     string
	Attachments []Attachment
	ReplyTo     *string
	Replies     []*string
	Mentions    []Author
	Created     time.Time
	Aux         map[string]string
}

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

type Attachment struct {
	Src  string
	Data []uint8
	Desc string
}

type SocketData interface {
	ToDatagram() []byte
}

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