decrypt.mx raw
1 package main
2
3 import (
4 "smesh.lol/web/common/helpers"
5 )
6
7 // DMRecord represents a decrypted DM.
8 type DMRecord struct {
9 ID string
10 Peer string
11 From string
12 Content string
13 CreatedAt int64
14 Protocol string
15 EventID string
16 }
17
18 func (r *DMRecord) ToJSON() string {
19 return "{" +
20 "\"id\":" + jstr(r.ID) +
21 ",\"peer\":" + jstr(r.Peer) +
22 ",\"from\":" + jstr(r.From) +
23 ",\"content\":" + jstr(r.Content) +
24 ",\"created_at\":" + helpers.Itoa(r.CreatedAt) +
25 ",\"protocol\":" + jstr(r.Protocol) +
26 ",\"eventId\":" + jstr(r.EventID) +
27 "}"
28 }
29
30 func makeDMRecord(peer, from, content string, createdAt int64, protocol, eventID string) *DMRecord {
31 return &DMRecord{
32 ID: eventID,
33 Peer: peer,
34 From: from,
35 Content: content,
36 CreatedAt: createdAt,
37 Protocol: protocol,
38 EventID: eventID,
39 }
40 }
41