From 088e5a6d478f974a01dc5538963d18892109c8ce Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Fri, 16 Jun 2023 18:22:07 +0000
Subject: [PATCH] debug notifications set command

---
 notifications/notifications.go | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/notifications/notifications.go b/notifications/notifications.go
index 82ba2f741..43538c83f 100644
--- a/notifications/notifications.go
+++ b/notifications/notifications.go
@@ -4,13 +4,15 @@ import (
 	"bytes"
 	"encoding/json"
 	"errors"
+	"time"
+
+	jww "github.com/spf13/jwalterweatherman"
 	"gitlab.com/elixxir/client/v4/collective/versioned"
 	pb "gitlab.com/elixxir/comms/mixmessages"
 	notifCrypto "gitlab.com/elixxir/crypto/notifications"
 	"gitlab.com/xx_network/primitives/id"
 	"gitlab.com/xx_network/primitives/id/ephemeral"
 	"gitlab.com/xx_network/primitives/netTime"
-	"time"
 )
 
 func (m *manager) Set(toBeNotifiedOn *id.ID, group string, metadata []byte,
@@ -19,9 +21,13 @@ func (m *manager) Set(toBeNotifiedOn *id.ID, group string, metadata []byte,
 		return err
 	}
 
+	jww.INFO.Printf("Notifications dummy locking SET")
+
 	m.mux.Lock()
 	defer m.mux.Unlock()
 
+	jww.INFO.Printf("Notifications dummy locked SET")
+
 	currentReg, exists := m.notifications[*toBeNotifiedOn]
 	if exists {
 		if currentReg.Group != group {
@@ -34,12 +40,18 @@ func (m *manager) Set(toBeNotifiedOn *id.ID, group string, metadata []byte,
 		}
 	}
 
+	jww.INFO.Printf("Notifications dummy currentReg")
+
 	// register with remote
 	if status == Push && (!exists || exists && currentReg.Status != Push) {
+		jww.INFO.Printf("Notifications dummy PUSH")
+
 		if err := m.registerNotification([]*id.ID{toBeNotifiedOn}); err != nil {
 			return err
 		}
 	} else if status != Push {
+		jww.INFO.Printf("Notifications dummy !PUSH")
+
 		if err := m.unregisterNotification([]*id.ID{toBeNotifiedOn}); err != nil {
 			return err
 		}
@@ -54,15 +66,20 @@ func (m *manager) Set(toBeNotifiedOn *id.ID, group string, metadata []byte,
 			Status:   status,
 		},
 	}
+	jww.INFO.Printf("Notifications dummy storeRegistration")
 
 	err := m.storeRegistration(toBeNotifiedOn, reg, ts)
 	if err != nil {
 		return err
 	}
 
+	jww.INFO.Printf("Notifications dummy upsert")
+
 	// update in ram storage
 	m.upsertNotificationUnsafeRAM(toBeNotifiedOn, reg)
 
+	jww.INFO.Printf("Notifications dummy CALLBACKS")
+
 	// call the callback if it exists to notify that an update exists
 	if cb, cbExists := m.callbacks[group]; cbExists {
 		// can be nil if the last element was deleted
-- 
GitLab