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
No related branches found
No related tags found
1 merge request!67Release
...@@ -9,7 +9,6 @@ package bindings ...@@ -9,7 +9,6 @@ package bindings
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
gc "gitlab.com/elixxir/client/groupChat" gc "gitlab.com/elixxir/client/groupChat"
gs "gitlab.com/elixxir/client/groupChat/groupStore" gs "gitlab.com/elixxir/client/groupChat/groupStore"
"gitlab.com/elixxir/crypto/group" "gitlab.com/elixxir/crypto/group"
...@@ -191,6 +190,11 @@ func (g *Group) GetID() []byte { ...@@ -191,6 +190,11 @@ func (g *Group) GetID() []byte {
return g.g.ID.Bytes() 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. // 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. // The list is in order; the first contact is the leader/creator of the group.
// All subsequent members are ordered by their ID. // All subsequent members are ordered by their ID.
...@@ -295,9 +299,7 @@ func (gmr *GroupMessageReceive) GetTimestampNano() int64 { ...@@ -295,9 +299,7 @@ func (gmr *GroupMessageReceive) GetTimestampNano() int64 {
// GetTimestampMS returns the message timestamp in milliseconds. // GetTimestampMS returns the message timestamp in milliseconds.
func (gmr *GroupMessageReceive) GetTimestampMS() int64 { func (gmr *GroupMessageReceive) GetTimestampMS() int64 {
ts := uint64(gmr.Timestamp.UnixNano()) / uint64(time.Millisecond) ts := uint64(gmr.Timestamp.UnixNano()) / uint64(time.Millisecond)
tsInt64 := int64(ts) return int64(ts)
jww.INFO.Printf("TimestampMS: %d", tsInt64)
return tsInt64
} }
// GetRoundID returns the ID of the round the message was sent on. // GetRoundID returns the ID of the round the message was sent on.
...@@ -315,7 +317,5 @@ func (gmr *GroupMessageReceive) GetRoundTimestampNano() int64 { ...@@ -315,7 +317,5 @@ func (gmr *GroupMessageReceive) GetRoundTimestampNano() int64 {
// message was sent on. // message was sent on.
func (gmr *GroupMessageReceive) GetRoundTimestampMS() int64 { func (gmr *GroupMessageReceive) GetRoundTimestampMS() int64 {
ts := uint64(gmr.RoundTimestamp.UnixNano()) / uint64(time.Millisecond) ts := uint64(gmr.RoundTimestamp.UnixNano()) / uint64(time.Millisecond)
tsInt64 := int64(ts) return int64(ts)
jww.INFO.Printf("RoundTimestampMS: %d", tsInt64)
return tsInt64
} }
...@@ -154,7 +154,8 @@ func createGroup(name, msg []byte, filePath string, gm *groupChat.Manager) { ...@@ -154,7 +154,8 @@ func createGroup(name, msg []byte, filePath string, gm *groupChat.Manager) {
// Integration grabs the group ID from this line // Integration grabs the group ID from this line
jww.INFO.Printf("NewGroupID: b64:%s", grp.ID) 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, fmt.Printf("Created new group with name %q and message %q\n", grp.Name,
grp.InitMessage) grp.InitMessage)
} }
...@@ -168,13 +169,15 @@ func resendRequests(groupIdString string, gm *groupChat.Manager) { ...@@ -168,13 +169,15 @@ func resendRequests(groupIdString string, gm *groupChat.Manager) {
groupID, err) 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.") fmt.Println("Resending group requests to group.")
} }
// joinGroup joins a group when a request is received on the group request // joinGroup joins a group when a request is received on the group request
// channel. // 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.") jww.INFO.Print("Waiting for group request to be received.")
fmt.Println("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) { ...@@ -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 // messageWait waits for the given number of messages to be received on the
// groupChat.MessageReceive channel. // 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) 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) fmt.Printf("Waiting for %d group message(s) to be received.\n", numMessages)
...@@ -263,7 +267,8 @@ func showGroup(groupIdString string, gm *groupChat.Manager) { ...@@ -263,7 +267,8 @@ func showGroup(groupIdString string, gm *groupChat.Manager) {
} }
jww.INFO.Printf("Show group %#v", grp) 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. // ReadLines returns each line in a file as a string.
...@@ -272,7 +277,12 @@ func ReadLines(fileName string) []string { ...@@ -272,7 +277,12 @@ func ReadLines(fileName string) []string {
if err != nil { if err != nil {
jww.FATAL.Panicf(err.Error()) 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 var res []string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment