From 1343a409f2dd26ff2ea7ef3e8611cbbdd54d85df Mon Sep 17 00:00:00 2001
From: joshemb <josh@elixxir.io>
Date: Tue, 20 Sep 2022 09:56:48 -0700
Subject: [PATCH] Add debugs

---
 groupChat/receive.go | 12 ++++++++++++
 groupChat/send.go    | 38 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/groupChat/receive.go b/groupChat/receive.go
index 004f7f370..68101f8a2 100644
--- a/groupChat/receive.go
+++ b/groupChat/receive.go
@@ -8,6 +8,8 @@
 package groupChat
 
 import (
+	"encoding/base64"
+	"encoding/json"
 	"fmt"
 	"gitlab.com/xx_network/primitives/netTime"
 	"time"
@@ -113,6 +115,16 @@ func decryptMessage(g gs.Group, fingerprint format.Fingerprint,
 		return MessageReceive{}, errors.Errorf(unmarshalSenderIdErr, err)
 	}
 
+	mar, _ := json.Marshal(NewPublicInternalMessage_DeleteThis(intlMsg))
+
+	jww.INFO.Printf("GROUP MSG ID DEBUG (decryptMsg): "+
+		"senders group ID: %s, "+
+		"internalMessage: %s"+
+		"internalMessage: %s",
+		g.ID,
+		base64.StdEncoding.EncodeToString(intlMsg.Marshal()),
+		string(mar))
+
 	return MessageReceive{
 		ID:        group.NewMessageID(g.ID, intlMsg.Marshal()),
 		Payload:   intlMsg.GetPayload(),
diff --git a/groupChat/send.go b/groupChat/send.go
index 8407439f5..b4cfb1083 100644
--- a/groupChat/send.go
+++ b/groupChat/send.go
@@ -8,6 +8,8 @@
 package groupChat
 
 import (
+	"encoding/base64"
+	"encoding/json"
 	"github.com/pkg/errors"
 	jww "github.com/spf13/jwalterweatherman"
 	"gitlab.com/elixxir/client/cmix"
@@ -176,6 +178,27 @@ func newCmixMsg(g gs.Group, tag string, msg []byte, timestamp time.Time,
 	return cmixMsg, nil
 }
 
+// PublicInternalMessage_DeleteThis so internalMsg could be json marshalled for legibility
+// in a debug ticket.
+type PublicInternalMessage_DeleteThis struct {
+	Data      []byte // Serial of all the parts of the message
+	Timestamp []byte // 64-bit Unix time timestamp stored in nanoseconds
+	SenderID  []byte // 264-bit sender ID
+	Size      []byte // Size of the payload
+	Payload   []byte // Message contents
+
+}
+
+func NewPublicInternalMessage_DeleteThis(msg internalMsg) *PublicInternalMessage_DeleteThis {
+	return &PublicInternalMessage_DeleteThis{
+		Data:      msg.data,
+		Timestamp: msg.timestamp,
+		SenderID:  msg.senderID,
+		Size:      msg.size,
+		Payload:   msg.payload,
+	}
+}
+
 // getGroupMessageId builds the group message ID.
 func getGroupMessageId(grp *cyclic.Group, groupId, senderId *id.ID,
 	timestamp time.Time, msg []byte) (group.MessageID, error) {
@@ -185,8 +208,19 @@ func getGroupMessageId(grp *cyclic.Group, groupId, senderId *id.ID,
 		return group.MessageID{}, errors.WithMessage(err,
 			"Failed to make message parts for message ID")
 	}
-	return group.NewMessageID(groupId,
-		setInternalPayload(intlMsg, timestamp, senderId, msg)), nil
+
+	intlMsgMarshal := setInternalPayload(intlMsg, timestamp, senderId, msg)
+
+	mar, _ := json.Marshal(NewPublicInternalMessage_DeleteThis(intlMsg))
+	jww.INFO.Printf("GROUP MSG ID DEBUG (getGroupMsgId): "+
+		"senders group ID: %s, "+
+		"internalMessage: %s"+
+		"internalMessage: %s",
+		groupId,
+		base64.StdEncoding.EncodeToString(intlMsgMarshal),
+		string(mar))
+
+	return group.NewMessageID(groupId, intlMsgMarshal), nil
 }
 
 // newMessageParts generates a public payload message and the internal payload
-- 
GitLab