From cc688a9a386f48e38687a697b50f9be7d2b06fb0 Mon Sep 17 00:00:00 2001 From: S7evinK <2353100+S7evinK@users.noreply.github.com> Date: Wed, 9 Feb 2022 15:46:52 +0100 Subject: [PATCH] Avoid unnecessary logs and marshaling (#2167) Co-authored-by: kegsay --- federationapi/consumers/eduserver.go | 2 +- federationapi/consumers/keychange.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/federationapi/consumers/eduserver.go b/federationapi/consumers/eduserver.go index 22fedbeb4..1f81fa258 100644 --- a/federationapi/consumers/eduserver.go +++ b/federationapi/consumers/eduserver.go @@ -134,7 +134,7 @@ func (t *OutputEDUConsumer) onSendToDeviceEvent(ctx context.Context, msg *nats.M return true } - log.Infof("Sending send-to-device message into %q destination queue", destServerName) + log.Debugf("Sending send-to-device message into %q destination queue", destServerName) if err := t.queues.SendEDU(edu, t.ServerName, []gomatrixserverlib.ServerName{destServerName}); err != nil { log.WithError(err).Error("failed to send EDU") return false diff --git a/federationapi/consumers/keychange.go b/federationapi/consumers/keychange.go index 1ec9f4c18..22dbc32da 100644 --- a/federationapi/consumers/keychange.go +++ b/federationapi/consumers/keychange.go @@ -127,6 +127,9 @@ func (t *KeyChangeConsumer) onDeviceKeyMessage(m api.DeviceMessage) bool { return true } + if len(destinations) == 0 { + return true + } // Pack the EDU and marshal it edu := &gomatrixserverlib.EDU{ Type: gomatrixserverlib.MDeviceListUpdate, @@ -146,7 +149,7 @@ func (t *KeyChangeConsumer) onDeviceKeyMessage(m api.DeviceMessage) bool { return true } - logger.Infof("Sending device list update message to %q", destinations) + logger.Debugf("Sending device list update message to %q", destinations) err = t.queues.SendEDU(edu, t.serverName, destinations) return err == nil } @@ -181,6 +184,10 @@ func (t *KeyChangeConsumer) onCrossSigningMessage(m api.DeviceMessage) bool { return true } + if len(destinations) == 0 { + return true + } + // Pack the EDU and marshal it edu := &gomatrixserverlib.EDU{ Type: eduserverAPI.MSigningKeyUpdate, @@ -191,7 +198,7 @@ func (t *KeyChangeConsumer) onCrossSigningMessage(m api.DeviceMessage) bool { return true } - logger.Infof("Sending cross-signing update message to %q", destinations) + logger.Debugf("Sending cross-signing update message to %q", destinations) err = t.queues.SendEDU(edu, t.serverName, destinations) return err == nil }