summaryrefslogtreecommitdiff
path: root/internal/vote/vote.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-06-13 00:42:47 +0300
committerPaul Buetow <paul@buetow.org>2023-06-13 00:42:47 +0300
commitfad6312fc02c71a42c3b28af0946e0833916d37f (patch)
tree66c64e9c81c47cb3272948692d70203f432aeab4 /internal/vote/vote.go
parent3096e71218f58588b8be2d11280b2b99383e1461 (diff)
use of vote ch in client
Diffstat (limited to 'internal/vote/vote.go')
-rw-r--r--internal/vote/vote.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/vote/vote.go b/internal/vote/vote.go
index 137beed..8ad5a37 100644
--- a/internal/vote/vote.go
+++ b/internal/vote/vote.go
@@ -26,16 +26,20 @@ func New(ids []string) (Vote, error) {
return v, nil
}
-func NewFromJSON(bytes []byte) (v Vote, err error) {
- if err = json.Unmarshal(bytes, &v); err != nil {
+func NewFromJSON(jsonStr string) (v Vote, err error) {
+ if err = json.Unmarshal([]byte(jsonStr), &v); err != nil {
return
}
v.ExpiresAt = time.Now().Add(Expiry)
return
}
-func (v Vote) ToJSON() ([]byte, error) {
- return json.Marshal(v)
+func (v Vote) ToJSON() (string, error) {
+ bytes, err := json.Marshal(v)
+ if err != nil {
+ return "", err
+ }
+ return string(bytes), nil
}
func (v Vote) Expired() bool {