-
Notifications
You must be signed in to change notification settings - Fork 55
Move /send_leave
to GMSL
#387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
bc7260c
9e1377a
2640a7e
645785d
b7a785d
5d099f9
540062a
1f82150
717c829
e3b02c9
2369def
498c486
185a49a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,12 +106,11 @@ type CurrentStateQuerier interface { | |
CurrentStateEvent(ctx context.Context, roomID spec.RoomID, eventType string, stateKey string) (PDU, error) | ||
} | ||
|
||
// HandleSendLeave handles requests to `/send_leave | ||
// Returns the parsed event and an error. | ||
func HandleSendLeave(ctx context.Context, | ||
requestContent []byte, | ||
// handleSendLeave handles requests to `/send_leave | ||
// Returns the parsed event or an error. | ||
func handleSendLeave(ctx context.Context, | ||
event PDU, | ||
|
||
origin spec.ServerName, | ||
roomVersion RoomVersion, | ||
eventID, roomID string, | ||
querier CurrentStateQuerier, | ||
verifier JSONVerifier, | ||
|
@@ -122,21 +121,6 @@ func HandleSendLeave(ctx context.Context, | |
return nil, err | ||
} | ||
|
||
verImpl, err := GetRoomVersion(roomVersion) | ||
if err != nil { | ||
return nil, spec.UnsupportedRoomVersion(fmt.Sprintf("QueryRoomVersionForRoom returned unknown version: %s", roomVersion)) | ||
} | ||
|
||
// Decode the event JSON from the request. | ||
event, err := verImpl.NewEventFromUntrustedJSON(requestContent) | ||
switch err.(type) { | ||
case BadJSONError: | ||
return nil, spec.BadJSON(err.Error()) | ||
case nil: | ||
default: | ||
return nil, spec.NotJSON("The request body could not be decoded into valid JSON. " + err.Error()) | ||
} | ||
|
||
// Check that the room ID is correct. | ||
if (event.RoomID()) != roomID { | ||
return nil, spec.BadJSON("The room ID in the request path must match the room ID in the leave event JSON") | ||
|
@@ -190,14 +174,15 @@ func HandleSendLeave(ctx context.Context, | |
} | ||
|
||
// Check that the event is signed by the server sending the request. | ||
redacted, err := verImpl.RedactEventJSON(event.JSON()) | ||
resultEvent := event | ||
event.Redact() | ||
if err != nil { | ||
util.GetLogger(ctx).WithError(err).Errorf("unable to redact event") | ||
return nil, spec.BadJSON("The event JSON could not be redacted") | ||
} | ||
verifyRequests := []VerifyJSONRequest{{ | ||
ServerName: sender.Domain(), | ||
Message: redacted, | ||
Message: event.JSON(), | ||
AtTS: event.OriginServerTS(), | ||
StrictValidityChecking: true, | ||
}} | ||
|
@@ -220,5 +205,5 @@ func HandleSendLeave(ctx context.Context, | |
return nil, spec.BadJSON("The membership in the event content must be set to leave") | ||
} | ||
|
||
return event, nil | ||
return resultEvent, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is problematic if
v != event.Version()
.