From c63bff680a6f1aee5cdb3f160fb8148575b987e0 Mon Sep 17 00:00:00 2001 From: Jono Wenger <jono@elixxir.io> Date: Tue, 19 Oct 2021 14:10:49 -0700 Subject: [PATCH] Add GetInitMessage to group bindings --- bindings/group.go | 14 +++++++------- cmd/group.go | 22 ++++++++++++++++------ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/bindings/group.go b/bindings/group.go index 335b062dc..343bbe775 100644 --- a/bindings/group.go +++ b/bindings/group.go @@ -9,7 +9,6 @@ package bindings import ( "github.com/pkg/errors" - jww "github.com/spf13/jwalterweatherman" gc "gitlab.com/elixxir/client/groupChat" gs "gitlab.com/elixxir/client/groupChat/groupStore" "gitlab.com/elixxir/crypto/group" @@ -191,6 +190,11 @@ func (g *Group) GetID() []byte { return g.g.ID.Bytes() } +// GetInitMessage returns initial message sent with the group request. +func (g *Group) GetInitMessage() []byte { + return g.g.InitMessage +} + // GetMembership returns a list of contacts, one for each member in the group. // The list is in order; the first contact is the leader/creator of the group. // All subsequent members are ordered by their ID. @@ -295,9 +299,7 @@ func (gmr *GroupMessageReceive) GetTimestampNano() int64 { // GetTimestampMS returns the message timestamp in milliseconds. func (gmr *GroupMessageReceive) GetTimestampMS() int64 { ts := uint64(gmr.Timestamp.UnixNano()) / uint64(time.Millisecond) - tsInt64 := int64(ts) - jww.INFO.Printf("TimestampMS: %d", tsInt64) - return tsInt64 + return int64(ts) } // GetRoundID returns the ID of the round the message was sent on. @@ -315,7 +317,5 @@ func (gmr *GroupMessageReceive) GetRoundTimestampNano() int64 { // message was sent on. func (gmr *GroupMessageReceive) GetRoundTimestampMS() int64 { ts := uint64(gmr.RoundTimestamp.UnixNano()) / uint64(time.Millisecond) - tsInt64 := int64(ts) - jww.INFO.Printf("RoundTimestampMS: %d", tsInt64) - return tsInt64 + return int64(ts) } diff --git a/cmd/group.go b/cmd/group.go index f1e4508a7..ca457c65b 100644 --- a/cmd/group.go +++ b/cmd/group.go @@ -154,7 +154,8 @@ func createGroup(name, msg []byte, filePath string, gm *groupChat.Manager) { // Integration grabs the group ID from this line jww.INFO.Printf("NewGroupID: b64:%s", grp.ID) - jww.INFO.Printf("Created Group: Requests:%s on rounds %#v, %v", status, rids, grp) + jww.INFO.Printf("Created Group: Requests:%s on rounds %#v, %v", + status, rids, grp) fmt.Printf("Created new group with name %q and message %q\n", grp.Name, grp.InitMessage) } @@ -168,13 +169,15 @@ func resendRequests(groupIdString string, gm *groupChat.Manager) { groupID, err) } - jww.INFO.Printf("Resending requests to group %s: %v, %s", groupID, rids, status) + jww.INFO.Printf("Resending requests to group %s: %v, %s", + groupID, rids, status) fmt.Println("Resending group requests to group.") } // joinGroup joins a group when a request is received on the group request // channel. -func joinGroup(reqChan chan groupStore.Group, timeout time.Duration, gm *groupChat.Manager) { +func joinGroup(reqChan chan groupStore.Group, timeout time.Duration, + gm *groupChat.Manager) { jww.INFO.Print("Waiting for group request to be received.") fmt.Println("Waiting for group request to be received.") @@ -226,7 +229,8 @@ func sendGroup(groupIdString string, msg []byte, gm *groupChat.Manager) { // messageWait waits for the given number of messages to be received on the // groupChat.MessageReceive channel. -func messageWait(numMessages uint, timeout time.Duration, recChan chan groupChat.MessageReceive) { +func messageWait(numMessages uint, timeout time.Duration, + recChan chan groupChat.MessageReceive) { jww.INFO.Printf("Waiting for %d group message(s) to be received.", numMessages) fmt.Printf("Waiting for %d group message(s) to be received.\n", numMessages) @@ -263,7 +267,8 @@ func showGroup(groupIdString string, gm *groupChat.Manager) { } jww.INFO.Printf("Show group %#v", grp) - fmt.Printf("Got group with name %q and message %q\n", grp.Name, grp.InitMessage) + fmt.Printf("Got group with name %q and message %q\n", + grp.Name, grp.InitMessage) } // ReadLines returns each line in a file as a string. @@ -272,7 +277,12 @@ func ReadLines(fileName string) []string { if err != nil { jww.FATAL.Panicf(err.Error()) } - defer file.Close() + defer func(file *os.File) { + err = file.Close() + if err != nil { + jww.FATAL.Panicf("Failed to close file: %+v", err) + } + }(file) var res []string -- GitLab