aboutsummaryrefslogtreecommitdiff
path: root/roomserver/internal/query/query.go
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-06-06 08:56:06 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-06-06 08:56:06 +0100
commit02597f15f0b60dbea49f8540c87981f7967d5509 (patch)
tree29afcc40bfe020abb945f6facc74fa30c2d92184 /roomserver/internal/query/query.go
parent3e9c734da5151aac6b7073c0797d26cde529ced7 (diff)
Fix panic in `QueryRestrictedJoinAllowed`
Diffstat (limited to 'roomserver/internal/query/query.go')
-rw-r--r--roomserver/internal/query/query.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/roomserver/internal/query/query.go b/roomserver/internal/query/query.go
index 6d306fb0..da1b3253 100644
--- a/roomserver/internal/query/query.go
+++ b/roomserver/internal/query/query.go
@@ -778,11 +778,18 @@ func (r *Queryer) QueryRestrictedJoinAllowed(ctx context.Context, req *api.Query
} else if !allowRestrictedJoins {
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".
joinRulesEvent, err := r.DB.GetStateEvent(ctx, req.RoomID, gomatrixserverlib.MRoomJoinRules, "")
if err != nil {
return fmt.Errorf("r.DB.GetStateEvent: %w", err)
}
+ if joinRulesEvent == nil {
+ return nil
+ }
var joinRules gomatrixserverlib.JoinRuleContent
if err = json.Unmarshal(joinRulesEvent.Content(), &joinRules); err != nil {
return fmt.Errorf("json.Unmarshal: %w", err)
@@ -792,10 +799,6 @@ func (r *Queryer) QueryRestrictedJoinAllowed(ctx context.Context, req *api.Query
if !res.Restricted {
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
// but we don't specify an authorised via user, since the event auth
// will allow the join anyway.