diff options
author | devonh <devon.dmytro@gmail.com> | 2023-04-14 15:03:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 15:03:07 +0000 |
commit | f66862958d1fca18cedf65999bb86273e81ad28f (patch) | |
tree | 1bd87856e7787c867b119cc77f32d57b8ffacbca /clientapi | |
parent | 914e6145a5735b3037e18a70fe9d95bc72580389 (diff) |
Remove event building duplication & push to GMSL (#3056)
Removes event building duplication and moves the funcionality into GMSL
since all the sub-steps are already there.
Diffstat (limited to 'clientapi')
-rw-r--r-- | clientapi/routing/createroom.go | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/clientapi/routing/createroom.go b/clientapi/routing/createroom.go index a0d80903..c2a43213 100644 --- a/clientapi/routing/createroom.go +++ b/clientapi/routing/createroom.go @@ -448,7 +448,7 @@ func createRoom( builder.PrevEvents = []gomatrixserverlib.EventReference{builtEvents[i-1].EventReference()} } var ev *gomatrixserverlib.Event - ev, err = buildEvent(&builder, userDomain, &authEvents, cfg, evTime, roomVersion) + ev, err = builder.AddAuthEventsAndBuild(userDomain, &authEvents, evTime, roomVersion, cfg.Matrix.KeyID, cfg.Matrix.PrivateKey) if err != nil { util.GetLogger(ctx).WithError(err).Error("buildEvent failed") return jsonerror.InternalServerError() @@ -599,31 +599,3 @@ func createRoom( JSON: response, } } - -// buildEvent fills out auth_events for the builder then builds the event -func buildEvent( - builder *gomatrixserverlib.EventBuilder, - serverName gomatrixserverlib.ServerName, - provider gomatrixserverlib.AuthEventProvider, - cfg *config.ClientAPI, - evTime time.Time, - roomVersion gomatrixserverlib.RoomVersion, -) (*gomatrixserverlib.Event, error) { - eventsNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(builder) - if err != nil { - return nil, err - } - refs, err := eventsNeeded.AuthEventReferences(provider) - if err != nil { - return nil, err - } - builder.AuthEvents = refs - event, err := builder.Build( - evTime, serverName, cfg.Matrix.KeyID, - cfg.Matrix.PrivateKey, roomVersion, - ) - if err != nil { - return nil, fmt.Errorf("cannot build event %s : Builder failed to build. %w", builder.Type, err) - } - return event, nil -} |