mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
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.
This commit is contained in:
parent
c4528b2de8
commit
b8f91485b4
11 changed files with 155 additions and 63 deletions
|
@ -33,6 +33,7 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/matrix-org/dendrite/roomserver/acls"
|
||||
"github.com/matrix-org/dendrite/roomserver/internal/helpers"
|
||||
|
||||
userAPI "github.com/matrix-org/dendrite/userapi/api"
|
||||
|
@ -491,6 +492,27 @@ func (r *Inputer) processRoomEvent(
|
|||
}
|
||||
}
|
||||
|
||||
// If this is a membership event, it is possible we newly joined a federated room and eventually
|
||||
// missed to update our m.room.server_acl - the following ensures we set the ACLs
|
||||
// TODO: This probably performs badly in benchmarks
|
||||
if event.Type() == spec.MRoomMember {
|
||||
membership, _ := event.Membership()
|
||||
if membership == spec.Join {
|
||||
_, serverName, _ := gomatrixserverlib.SplitID('@', *event.StateKey())
|
||||
// only handle local membership events
|
||||
if r.Cfg.Matrix.IsLocalServerName(serverName) {
|
||||
var aclEvent *types.HeaderedEvent
|
||||
aclEvent, err = r.DB.GetStateEvent(ctx, event.RoomID().String(), acls.MRoomServerACL, "")
|
||||
if err != nil {
|
||||
logrus.WithError(err).Error("failed to get server ACLs")
|
||||
}
|
||||
if aclEvent != nil {
|
||||
r.ACLs.OnServerACLUpdate(aclEvent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle remote room upgrades, e.g. remove published room
|
||||
if event.Type() == "m.room.tombstone" && event.StateKeyEquals("") && !r.Cfg.Matrix.IsLocalServerName(senderDomain) {
|
||||
if err = r.handleRemoteRoomUpgrade(ctx, event); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue