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

@ -180,14 +180,14 @@ func (r *Joiner) performJoinRoomByID(
if err != nil {
return "", "", rsAPI.ErrInvalidID{Err: fmt.Errorf("user ID %q is invalid: %w", userID, err)}
}
eb := gomatrixserverlib.EventBuilder{
proto := gomatrixserverlib.ProtoEvent{
Type: spec.MRoomMember,
Sender: userID,
StateKey: &userID,
RoomID: req.RoomIDOrAlias,
Redacts: "",
}
if err = eb.SetUnsigned(struct{}{}); err != nil {
if err = proto.SetUnsigned(struct{}{}); err != nil {
return "", "", fmt.Errorf("eb.SetUnsigned: %w", err)
}
@ -203,7 +203,7 @@ func (r *Joiner) performJoinRoomByID(
} else if authorisedVia != "" {
req.Content["join_authorised_via_users_server"] = authorisedVia
}
if err = eb.SetContent(req.Content); err != nil {
if err = proto.SetContent(req.Content); err != nil {
return "", "", fmt.Errorf("eb.SetContent: %w", err)
}
@ -284,7 +284,7 @@ func (r *Joiner) performJoinRoomByID(
if err != nil {
return "", "", fmt.Errorf("error joining local room: %q", err)
}
event, err := eventutil.QueryAndBuildEvent(ctx, &eb, r.Cfg.Matrix, identity, time.Now(), r.RSAPI, &buildRes)
event, err := eventutil.QueryAndBuildEvent(ctx, &proto, r.Cfg.Matrix, identity, time.Now(), r.RSAPI, &buildRes)
switch err {
case nil: