Skip to content
Snippets Groups Projects
Commit f0340ef8 authored by Josh Brooks's avatar Josh Brooks
Browse files

Add groupReport marshal()

parent 7a8e1373
No related branches found
No related tags found
2 merge requests!69Hotfix/multiple send group chat,!67Release
......@@ -8,6 +8,8 @@
package bindings
import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
gc "gitlab.com/elixxir/client/groupChat"
gs "gitlab.com/elixxir/client/groupChat/groupStore"
......@@ -167,6 +169,12 @@ type NewGroupReport struct {
err string
}
type GroupReportDisk struct {
List []id.Round
GrpId []byte
Status int
}
// GetGroup returns the Group.
func (ngr *NewGroupReport) GetGroup() *Group {
return ngr.group
......@@ -193,6 +201,36 @@ func (ngr *NewGroupReport) GetError() string {
return ngr.err
}
func (ngr *NewGroupReport) Marshal() ([]byte, error) {
grpReportDisk := GroupReportDisk{
List: ngr.rounds,
GrpId: ngr.group.GetID()[:],
Status: ngr.GetStatus(),
}
return json.Marshal(&grpReportDisk)
}
func (ngr *NewGroupReport) Unmarshal(b []byte) error {
grpReportDisk := GroupReportDisk{}
if err := json.Unmarshal(b, &grpReportDisk); err != nil {
return errors.New(fmt.Sprintf("Failed to unmarshal group "+
"report: %s", err.Error()))
}
grpId, err := id.Unmarshal(grpReportDisk.GrpId)
if err != nil {
return errors.New(fmt.Sprintf("Failed to unmarshal group "+
"id: %s", err.Error()))
}
ngr.group.g.ID = grpId
ngr.rounds = grpReportDisk.List
ngr.status = gc.RequestStatus(grpReportDisk.Status)
return nil
}
////
// NewGroupReport Structure
////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment