Skip to content
Snippets Groups Projects
Commit c63bff68 authored by Jono Wenger's avatar Jono Wenger
Browse files

Add GetInitMessage to group bindings

parent c99fcead
Branches
Tags
1 merge request!67Release
......@@ -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)
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment