From 75cfec95e2a1d8167654397bfde1771dbe22f532 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Fri, 21 Jan 2022 13:44:27 +0000 Subject: [PATCH] Send create room events as new --- clientapi/routing/createroom.go | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/clientapi/routing/createroom.go b/clientapi/routing/createroom.go index a057aad91..2e3fc4b1e 100644 --- a/clientapi/routing/createroom.go +++ b/clientapi/routing/createroom.go @@ -452,21 +452,18 @@ func createRoom( return jsonerror.InternalServerError() } - accumulated := gomatrixserverlib.UnwrapEventHeaders(builtEvents) - if err = roomserverAPI.SendEventWithState( - req.Context(), - rsAPI, - roomserverAPI.KindNew, - &gomatrixserverlib.RespState{ - StateEvents: accumulated, - AuthEvents: accumulated, - }, - ev.Headered(roomVersion), - cfg.Matrix.ServerName, - nil, - false, - ); err != nil { - util.GetLogger(req.Context()).WithError(err).Error("SendEventWithState failed") + inputs := make([]roomserverAPI.InputRoomEvent, 0, len(builtEvents)) + for _, event := range builtEvents { + inputs = append(inputs, roomserverAPI.InputRoomEvent{ + Kind: roomserverAPI.KindNew, + Event: event, + Origin: cfg.Matrix.ServerName, + AuthEventIDs: event.AuthEventIDs(), + SendAsServer: roomserverAPI.DoNotSendToOtherServers, + }) + } + if err = roomserverAPI.SendInputRoomEvents(req.Context(), rsAPI, inputs, false); err != nil { + util.GetLogger(req.Context()).WithError(err).Error("roomserverAPI.SendInputRoomEvents failed") return jsonerror.InternalServerError() } }