mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 19:51:39 +00:00
Fix panic in QueryRestrictedJoinAllowed
This commit is contained in:
parent
3e9c734da5
commit
02597f15f0
@ -778,11 +778,18 @@ func (r *Queryer) QueryRestrictedJoinAllowed(ctx context.Context, req *api.Query
|
|||||||
} else if !allowRestrictedJoins {
|
} else if !allowRestrictedJoins {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// Start off by populating the "resident" flag in the response. If we
|
||||||
|
// come across any rooms in the request that are missing, we will unset
|
||||||
|
// the flag.
|
||||||
|
res.Resident = true
|
||||||
// Get the join rules to work out if the join rule is "restricted".
|
// Get the join rules to work out if the join rule is "restricted".
|
||||||
joinRulesEvent, err := r.DB.GetStateEvent(ctx, req.RoomID, gomatrixserverlib.MRoomJoinRules, "")
|
joinRulesEvent, err := r.DB.GetStateEvent(ctx, req.RoomID, gomatrixserverlib.MRoomJoinRules, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("r.DB.GetStateEvent: %w", err)
|
return fmt.Errorf("r.DB.GetStateEvent: %w", err)
|
||||||
}
|
}
|
||||||
|
if joinRulesEvent == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
var joinRules gomatrixserverlib.JoinRuleContent
|
var joinRules gomatrixserverlib.JoinRuleContent
|
||||||
if err = json.Unmarshal(joinRulesEvent.Content(), &joinRules); err != nil {
|
if err = json.Unmarshal(joinRulesEvent.Content(), &joinRules); err != nil {
|
||||||
return fmt.Errorf("json.Unmarshal: %w", err)
|
return fmt.Errorf("json.Unmarshal: %w", err)
|
||||||
@ -792,10 +799,6 @@ func (r *Queryer) QueryRestrictedJoinAllowed(ctx context.Context, req *api.Query
|
|||||||
if !res.Restricted {
|
if !res.Restricted {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Start off by populating the "resident" flag in the response. If we
|
|
||||||
// come across any rooms in the request that are missing, we will unset
|
|
||||||
// the flag.
|
|
||||||
res.Resident = true
|
|
||||||
// If the user is already invited to the room then the join is allowed
|
// If the user is already invited to the room then the join is allowed
|
||||||
// but we don't specify an authorised via user, since the event auth
|
// but we don't specify an authorised via user, since the event auth
|
||||||
// will allow the join anyway.
|
// will allow the join anyway.
|
||||||
|
Loading…
Reference in New Issue
Block a user