Skip to content

Commit

Permalink
Merge pull request #40 from xmtp/np/fix-notification-server
Browse files Browse the repository at this point in the history
Fix HMAC and Should Push logic
  • Loading branch information
nplasterer authored Mar 27, 2024
2 parents ed994b0 + 5e25a41 commit 213ed1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/subscriptions/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (s SubscriptionsService) GetSubscriptions(ctx context.Context, topic string
if err != nil {
return nil, err
}
s.logger.Info("Results", zap.Any("results", results))
// s.logger.Info("Results", zap.Any("results", results))
for _, result := range results {
out = append(out, transformResult(result))
}
Expand Down
14 changes: 9 additions & 5 deletions pkg/xmtp/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (l *Listener) startMessageWorkers() {
l.logger.Error("error processing envelope", zap.String("topic", msg.ContentTopic), zap.Error(err))
continue
}
l.logger.Info("processed a message", zap.String("topic", msg.ContentTopic))
// l.logger.Info("processed a message", zap.String("topic", msg.ContentTopic))
}
}()
}
Expand Down Expand Up @@ -175,6 +175,7 @@ func (l *Listener) processEnvelope(env *v1.Envelope) error {
zap.Any("message_context", request.MessageContext),
zap.Bool("subscription_has_hmac_key", request.Subscription.HmacKey != nil),
)
return nil
}
if err = l.deliver(request); err != nil {
l.logger.Error("error delivering request", zap.Error(err), zap.String("content_topic", env.ContentTopic))
Expand All @@ -185,12 +186,15 @@ func (l *Listener) processEnvelope(env *v1.Envelope) error {
}

func (l *Listener) shouldDeliver(messageContext interfaces.MessageContext, subscription interfaces.Subscription) bool {
if messageContext.ShouldPush != nil {
return *messageContext.ShouldPush
}
if subscription.HmacKey != nil && len(subscription.HmacKey.Key) > 0 {
isSender := messageContext.IsSender(subscription.HmacKey.Key)
return !isSender
if (isSender) {
return !isSender
}
}
if messageContext.ShouldPush != nil {
shouldPush := messageContext.ShouldPush
return *shouldPush
}
return true
}
Expand Down

0 comments on commit 213ed1e

Please sign in to comment.