mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 23:48:27 +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
|
// 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"
|
// but it's possible that the remote server returned us something "odd"
|
||||||
respMakeJoin.JoinEvent.Type = gomatrixserverlib.MRoomMember
|
switch {
|
||||||
respMakeJoin.JoinEvent.Sender = userID
|
case respMakeJoin.JoinEvent.Type != gomatrixserverlib.MRoomMember:
|
||||||
respMakeJoin.JoinEvent.StateKey = &userID
|
fallthrough
|
||||||
respMakeJoin.JoinEvent.RoomID = roomID
|
case respMakeJoin.JoinEvent.Sender != userID:
|
||||||
respMakeJoin.JoinEvent.Redacts = ""
|
fallthrough
|
||||||
if content == nil {
|
case respMakeJoin.JoinEvent.StateKey == nil:
|
||||||
content = map[string]interface{}{}
|
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 {
|
if err = respMakeJoin.JoinEvent.SetContent(content); err != nil {
|
||||||
return fmt.Errorf("respMakeJoin.JoinEvent.SetContent: %w", err)
|
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
|
// Work out if we support the room version that has been supplied in
|
||||||
// the make_join response.
|
// the make_join response.
|
||||||
|
|
Loading…
Reference in a new issue