From 39dffd8b700a5d1191cfd39b7da5994ee6e4d40f Mon Sep 17 00:00:00 2001
From: Pablo Lopez
Date: Mon, 24 Jun 2024 10:16:05 +0300
Subject: [PATCH] fix_: logging cli join group, small logging issue missing id,
init online state to current state (#5407)
---
cmd/status-cli/serve.go | 13 +++++++++++++
protocol/messenger.go | 8 +++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/cmd/status-cli/serve.go b/cmd/status-cli/serve.go
index 59ccfcf39..e32e9a56f 100644
--- a/cmd/status-cli/serve.go
+++ b/cmd/status-cli/serve.go
@@ -68,6 +68,13 @@ func serve(cCtx *cli.Context) error {
}
}
}
+ case "local-notifications":
+ var ev LocalNotification
+ if err := json.Unmarshal(evt.Event, &ev); err != nil {
+ logger.Error("unmarshaling local notification event", zap.Error(err), zap.Any("event", evt.Event))
+ return
+ }
+ logger.Infof("local notification: %v, title: %v, id: %v", ev.Category, ev.Title, ev.ID)
default:
logger.Debugf("received event type '%v'\t%v", evt.Type, string(evt.Event))
}
@@ -109,6 +116,12 @@ type EventNewMessages struct {
Messages []*common.Message `json:"messages"`
}
+type LocalNotification struct {
+ ID string `json:"id"`
+ Title string `json:"title"`
+ Category string `json:"category"`
+}
+
func waitForSigExit() {
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
diff --git a/protocol/messenger.go b/protocol/messenger.go
index 2d4f4ab10..a764470ee 100644
--- a/protocol/messenger.go
+++ b/protocol/messenger.go
@@ -1458,7 +1458,7 @@ func (m *Messenger) handleENSVerificationSubscription(c chan []*ens.Verification
// watchConnectionChange checks the connection status and call handleConnectionChange when this changes
func (m *Messenger) watchConnectionChange() {
- state := false
+ state := m.Online()
processNewState := func(newState bool) {
if state == newState {
@@ -1495,11 +1495,9 @@ func (m *Messenger) watchConnectionChange() {
}
m.logger.Debug("watching connection changes")
- m.Online()
m.handleConnectionChange(state)
waku, err := m.node.GetWakuV2(nil)
-
if err != nil {
// No waku v2, we can't watch connection changes
// Instead we will poll the connection status.
@@ -3889,7 +3887,7 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
for _, msg := range statusMessages {
logger := logger.With(zap.String("message-id", msg.ApplicationLayer.ID.String()))
- logger.Info("processing message")
+
publicKey := msg.SigPubKey()
m.handleInstallations(msg.EncryptionLayer.Installations)
@@ -3901,7 +3899,7 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
senderID := contactIDFromPublicKey(publicKey)
ownID := contactIDFromPublicKey(m.IdentityPublicKey())
- m.logger.Info("processing message", zap.Any("type", msg.ApplicationLayer.Type), zap.String("senderID", senderID))
+ logger.Info("processing message", zap.Any("type", msg.ApplicationLayer.Type), zap.String("senderID", senderID))
if senderID == ownID {
// Skip own messages of certain types