summaryrefslogtreecommitdiff
path: root/entry.go
diff options
context:
space:
mode:
Diffstat (limited to 'entry.go')
-rw-r--r--entry.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/entry.go b/entry.go
new file mode 100644
index 0000000..1615392
--- /dev/null
+++ b/entry.go
@@ -0,0 +1,29 @@
+package main
+
+import (
+ "encoding/json"
+ "fmt"
+)
+
+type shared struct {
+ Name string `json:"id"`
+ Is bool `json:"is,omitempty"`
+}
+
+type entry struct {
+ Body string `json:"body"`
+ Shared []shared `json:"shared,omitempty"`
+ Epoch int `json:"epoch,omitempty"`
+}
+
+func newEntry(data []byte) (entry, error) {
+ var entry entry
+ if err := json.Unmarshal(data, &entry); err != nil {
+ return entry, fmt.Errorf("unable to deserialise payload: %w", err)
+ }
+ return entry, nil
+}
+
+func (e entry) serialize() ([]byte, error) {
+ return json.Marshal(e)
+}