From 7ef531ac3dfed0e3b52ef23debc588081a30e653 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 14 Oct 2020 16:16:48 +0100 Subject: [PATCH] Ignore typing notifications where the sender doesn't match the origin --- federationapi/routing/send.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/federationapi/routing/send.go b/federationapi/routing/send.go index fa2a7bbb6..c275c9982 100644 --- a/federationapi/routing/send.go +++ b/federationapi/routing/send.go @@ -289,6 +289,15 @@ func (t *txnReq) processEDUs(ctx context.Context) { util.GetLogger(ctx).WithError(err).Error("Failed to unmarshal typing event") continue } + _, domain, err := gomatrixserverlib.SplitID('@', typingPayload.UserID) + if err != nil { + util.GetLogger(ctx).WithError(err).Error("Failed to split domain from typing event sender") + continue + } + if domain != t.Origin { + util.GetLogger(ctx).Warnf("Dropping typing event where sender domain (%d) doesn't match origin (%d)", domain, t.Origin) + continue + } if err := eduserverAPI.SendTyping(ctx, t.eduAPI, typingPayload.UserID, typingPayload.RoomID, typingPayload.Typing, 30*1000); err != nil { util.GetLogger(ctx).WithError(err).Error("Failed to send typing event to edu server") }