mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-26 15:08:28 +00:00
Error on obvious problems with the make_join response instead of overwriting them
This commit is contained in:
parent
f3e83c1a07
commit
f21a585647
1 changed files with 18 additions and 11 deletions
|
@ -162,21 +162,28 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer(
|
|||
|
||||
// Set all the fields to be what they should be, this should be a no-op
|
||||
// but it's possible that the remote server returned us something "odd"
|
||||
respMakeJoin.JoinEvent.Type = gomatrixserverlib.MRoomMember
|
||||
respMakeJoin.JoinEvent.Sender = userID
|
||||
respMakeJoin.JoinEvent.StateKey = &userID
|
||||
respMakeJoin.JoinEvent.RoomID = roomID
|
||||
respMakeJoin.JoinEvent.Redacts = ""
|
||||
if content == nil {
|
||||
content = map[string]interface{}{}
|
||||
switch {
|
||||
case respMakeJoin.JoinEvent.Type != gomatrixserverlib.MRoomMember:
|
||||
fallthrough
|
||||
case respMakeJoin.JoinEvent.Sender != userID:
|
||||
fallthrough
|
||||
case respMakeJoin.JoinEvent.StateKey == nil:
|
||||
fallthrough
|
||||
case *respMakeJoin.JoinEvent.StateKey != userID:
|
||||
fallthrough
|
||||
case respMakeJoin.JoinEvent.RoomID != roomID:
|
||||
fallthrough
|
||||
case respMakeJoin.JoinEvent.Redacts != "":
|
||||
fallthrough
|
||||
case len(respMakeJoin.JoinEvent.Content) == 0:
|
||||
return fmt.Errorf("respMakeJoin.JoinEvent contains invalid values")
|
||||
}
|
||||
if err = json.Unmarshal(respMakeJoin.JoinEvent.Content, &content); err != nil {
|
||||
return fmt.Errorf("json.Unmarshal: %w", err)
|
||||
}
|
||||
content["membership"] = "join"
|
||||
if err = respMakeJoin.JoinEvent.SetContent(content); err != nil {
|
||||
return fmt.Errorf("respMakeJoin.JoinEvent.SetContent: %w", err)
|
||||
}
|
||||
if err = respMakeJoin.JoinEvent.SetUnsigned(struct{}{}); err != nil {
|
||||
return fmt.Errorf("respMakeJoin.JoinEvent.SetUnsigned: %w", err)
|
||||
}
|
||||
|
||||
// Work out if we support the room version that has been supplied in
|
||||
// the make_join response.
|
||||
|
|
Loading…
Reference in a new issue