From 183136d2843bc1dc16d98ee2c50bf2cbf0a74ce4 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Thu, 13 Aug 2020 13:58:14 +0100 Subject: [PATCH] Use gjson to look for room_id in EDU --- federationsender/queue/queue.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/federationsender/queue/queue.go b/federationsender/queue/queue.go index d685520f2..6d856fe2d 100644 --- a/federationsender/queue/queue.go +++ b/federationsender/queue/queue.go @@ -27,6 +27,7 @@ import ( "github.com/matrix-org/dendrite/roomserver/api" "github.com/matrix-org/gomatrixserverlib" log "github.com/sirupsen/logrus" + "github.com/tidwall/gjson" ) // OutgoingQueues is a collection of queues for sending transactions to other @@ -248,15 +249,12 @@ func (oqs *OutgoingQueues) SendEDU( // (e.g. typing notifications) then we should try to make sure we don't // bother sending them to servers that are prohibited by the server // ACLs. - var header struct { - RoomID string `json:"room_id"` - } - if err := json.Unmarshal(e.Content, &header); err == nil { + if result := gjson.GetBytes(e.Content, "room_id"); result.Exists() { for destination := range destmap { if stateapi.IsServerBannedFromRoom( context.TODO(), oqs.stateAPI, - header.RoomID, + result.Str, destination, ) { delete(destmap, destination)