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
|
package model
import (
"fmt"
"strconv"
"strings"
"time"
)
type Message struct {
ID string
RepTo string
EchoArea string
Date time.Time
From string
Addr string
MsgTo string
Subject string
Message string
}
func (m *Message) Bundle() string {
tags := "ii/ok"
if m.RepTo != "" {
tags = "ii/ok/repto/" + m.RepTo
}
lines := []string{
tags,
m.EchoArea,
strconv.Itoa(int(m.Date.Unix())),
m.From,
m.Addr,
string(m.MsgTo),
m.Subject,
"",
m.Message,
}
return strings.Join(lines, "\n")
}
func (m *Message) PointMessage() string {
lines := []string{
m.EchoArea,
string(m.MsgTo),
m.Subject,
"",
}
if m.RepTo != "" {
lines = append(lines, fmt.Sprintf("@repto:%s", m.RepTo))
}
lines = append(lines, m.Message)
return strings.Join(lines, "\n")
}
|