mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 22:03:10 -06:00
Use gjson to look for room_id in EDU
This commit is contained in:
parent
0d7404e47e
commit
183136d284
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
"github.com/matrix-org/dendrite/roomserver/api"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OutgoingQueues is a collection of queues for sending transactions to other
|
// 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
|
// (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
|
// bother sending them to servers that are prohibited by the server
|
||||||
// ACLs.
|
// ACLs.
|
||||||
var header struct {
|
if result := gjson.GetBytes(e.Content, "room_id"); result.Exists() {
|
||||||
RoomID string `json:"room_id"`
|
|
||||||
}
|
|
||||||
if err := json.Unmarshal(e.Content, &header); err == nil {
|
|
||||||
for destination := range destmap {
|
for destination := range destmap {
|
||||||
if stateapi.IsServerBannedFromRoom(
|
if stateapi.IsServerBannedFromRoom(
|
||||||
context.TODO(),
|
context.TODO(),
|
||||||
oqs.stateAPI,
|
oqs.stateAPI,
|
||||||
header.RoomID,
|
result.Str,
|
||||||
destination,
|
destination,
|
||||||
) {
|
) {
|
||||||
delete(destmap, destination)
|
delete(destmap, destination)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue