Use ProtoEvent where needed instead of EventBuilder (#3075)

They are fundamentally different concepts, so should be represented as
such. Proto events are exchanged in /make_xxx calls over federation, and
made as "fledgling" events in /createRoom and general event sending.
*Building* events is a reasonably complex VERSION SPECIFIC process which
needs amongst other things, auth event providers, prev events, signing
keys, etc.

Requires https://github.com/matrix-org/gomatrixserverlib/pull/379
This commit is contained in:
kegsay 2023-05-04 11:17:42 +01:00 committed by GitHub
parent d5c11a3c86
commit 2b34f88fde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 152 additions and 119 deletions

View file

@ -113,15 +113,15 @@ func SendRedaction(
}
// create the new event and set all the fields we can
builder := gomatrixserverlib.EventBuilder{
proto := gomatrixserverlib.ProtoEvent{
Sender: device.UserID,
RoomID: roomID,
Type: spec.MRoomRedaction,
Redacts: eventID,
}
err := builder.SetContent(r)
err := proto.SetContent(r)
if err != nil {
util.GetLogger(req.Context()).WithError(err).Error("builder.SetContent failed")
util.GetLogger(req.Context()).WithError(err).Error("proto.SetContent failed")
return jsonerror.InternalServerError()
}
@ -131,7 +131,7 @@ func SendRedaction(
}
var queryRes roomserverAPI.QueryLatestEventsAndStateResponse
e, err := eventutil.QueryAndBuildEvent(req.Context(), &builder, cfg.Matrix, identity, time.Now(), rsAPI, &queryRes)
e, err := eventutil.QueryAndBuildEvent(req.Context(), &proto, cfg.Matrix, identity, time.Now(), rsAPI, &queryRes)
if err == eventutil.ErrRoomNoExists {
return util.JSONResponse{
Code: http.StatusNotFound,