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