aboutsummaryrefslogtreecommitdiff
path: root/roomserver/acls/acls.go
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2023-11-22 15:38:04 +0100
committerGitHub <noreply@github.com>2023-11-22 15:38:04 +0100
commitb8f91485b47ac6e92a90988b394e8f3611735250 (patch)
tree5f84b6abb2b6fb8d5feed1b43a5ffe30c1ce0c89 /roomserver/acls/acls.go
parentc4528b2de8c36657039c3d3f541017ee8964c4ac (diff)
Update ACLs when received as outliers (#3008)
This should fix #3004 by making sure we also update our in-memory ACLs after joining a new room. Also makes use of more caching in `GetStateEvent` Bonus: Adds some tests, as I was about to use `GetBulkStateContent`, but turns out that `GetStateEvent` is basically doing the same, just that it only gets the `eventTypeNID`/`eventStateKeyNID` once and not for every call.
Diffstat (limited to 'roomserver/acls/acls.go')
-rw-r--r--roomserver/acls/acls.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/roomserver/acls/acls.go b/roomserver/acls/acls.go
index 601ce906..e247c755 100644
--- a/roomserver/acls/acls.go
+++ b/roomserver/acls/acls.go
@@ -29,6 +29,8 @@ import (
"github.com/sirupsen/logrus"
)
+const MRoomServerACL = "m.room.server_acl"
+
type ServerACLDatabase interface {
// GetKnownRooms returns a list of all rooms we know about.
GetKnownRooms(ctx context.Context) ([]string, error)
@@ -57,7 +59,7 @@ func NewServerACLs(db ServerACLDatabase) *ServerACLs {
// do then we'll process it into memory so that we have the regexes to
// hand.
for _, room := range rooms {
- state, err := db.GetStateEvent(ctx, room, "m.room.server_acl", "")
+ state, err := db.GetStateEvent(ctx, room, MRoomServerACL, "")
if err != nil {
logrus.WithError(err).Errorf("Failed to get server ACLs for room %q", room)
continue