This commit is contained in:
Till Faelligen 2022-11-11 07:44:42 +01:00
parent 2ae80497d2
commit 4b34c1bf0f
No known key found for this signature in database
GPG key ID: ACCDC9606D472758
2 changed files with 5 additions and 3 deletions

View file

@ -22,9 +22,10 @@ import (
"encoding/json"
"errors"
"fmt"
"time"
userAPI "github.com/matrix-org/dendrite/userapi/api"
"github.com/tidwall/gjson"
"time"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"

View file

@ -273,8 +273,9 @@ func (r *Joiner) performJoinRoomByID(
// If a guest is trying to join a room, check that the room has a m.room.guest_access event
if req.IsGuest {
var guestAccessEvent *gomatrixserverlib.HeaderedEvent
guestAccess := "forbidden"
guestAccessEvent, err := r.DB.GetStateEvent(ctx, req.RoomIDOrAlias, gomatrixserverlib.MRoomGuestAccess, "")
guestAccessEvent, err = r.DB.GetStateEvent(ctx, req.RoomIDOrAlias, gomatrixserverlib.MRoomGuestAccess, "")
if err == nil && guestAccessEvent != nil {
guestAccess = gjson.GetBytes(guestAccessEvent.Content(), "guest_access").String()
}
@ -284,7 +285,7 @@ func (r *Joiner) performJoinRoomByID(
if guestAccess != "can_join" {
return "", "", &rsAPI.PerformError{
Code: rsAPI.PerformErrorNotAllowed,
Msg: fmt.Sprintf("Guest access is forbidden"),
Msg: "Guest access is forbidden",
}
}
}