Add support for MSC4163 (#3470)

Ignore typing and receipt events from ACL'd servers as per MSC4163
This commit is contained in:
Till 2025-01-16 22:47:04 +01:00 committed by GitHub
parent 7f4ba1f6eb
commit 829ecafdc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -216,13 +216,17 @@ func (t *TxnReq) processEDUs(ctx context.Context) {
util.GetLogger(ctx).WithError(err).Debug("Failed to unmarshal typing event") util.GetLogger(ctx).WithError(err).Debug("Failed to unmarshal typing event")
continue continue
} }
if _, serverName, err := gomatrixserverlib.SplitID('@', typingPayload.UserID); err != nil { _, serverName, err := gomatrixserverlib.SplitID('@', typingPayload.UserID)
if err != nil {
continue continue
} else if serverName == t.ourServerName { } else if serverName == t.ourServerName {
continue continue
} else if serverName != t.Origin { } else if serverName != t.Origin {
continue continue
} }
if api.IsServerBannedFromRoom(ctx, t.rsAPI, typingPayload.RoomID, serverName) {
continue
}
if err := t.producer.SendTyping(ctx, typingPayload.UserID, typingPayload.RoomID, typingPayload.Typing, 30*1000); err != nil { if err := t.producer.SendTyping(ctx, typingPayload.UserID, typingPayload.RoomID, typingPayload.Typing, 30*1000); err != nil {
util.GetLogger(ctx).WithError(err).Error("Failed to send typing event to JetStream") util.GetLogger(ctx).WithError(err).Error("Failed to send typing event to JetStream")
} }
@ -278,6 +282,9 @@ func (t *TxnReq) processEDUs(ctx context.Context) {
util.GetLogger(ctx).Debugf("Dropping receipt event where sender domain (%q) doesn't match origin (%q)", domain, t.Origin) util.GetLogger(ctx).Debugf("Dropping receipt event where sender domain (%q) doesn't match origin (%q)", domain, t.Origin)
continue continue
} }
if api.IsServerBannedFromRoom(ctx, t.rsAPI, roomID, domain) {
continue
}
if err := t.processReceiptEvent(ctx, userID, roomID, "m.read", mread.Data.TS, mread.EventIDs); err != nil { if err := t.processReceiptEvent(ctx, userID, roomID, "m.read", mread.Data.TS, mread.EventIDs); err != nil {
util.GetLogger(ctx).WithError(err).WithFields(logrus.Fields{ util.GetLogger(ctx).WithError(err).WithFields(logrus.Fields{
"sender": t.Origin, "sender": t.Origin,