mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-08 07:23:10 -06:00
Add MRoomServerACL constant
This commit is contained in:
parent
f5fd6b140f
commit
49abf619bc
|
|
@ -1,5 +1,9 @@
|
|||
package pushrules
|
||||
|
||||
import (
|
||||
"github.com/matrix-org/dendrite/roomserver/acls"
|
||||
)
|
||||
|
||||
func defaultOverrideRules(userID string) []*Rule {
|
||||
return []*Rule{
|
||||
&mRuleMasterDefinition,
|
||||
|
|
@ -108,7 +112,7 @@ var (
|
|||
{
|
||||
Kind: EventMatchCondition,
|
||||
Key: "type",
|
||||
Pattern: pointer("m.room.server_acl"),
|
||||
Pattern: pointer(acls.MRoomServerACL),
|
||||
},
|
||||
{
|
||||
Kind: EventMatchCondition,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,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)
|
||||
|
|
@ -55,7 +57,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
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/matrix-org/dendrite/roomserver/acls"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
|
|
@ -552,7 +553,7 @@ func (r *Inputer) processStateBefore(
|
|||
// We also query the m.room.server_acl, if any, so we can correctly set
|
||||
// them after joining a room.
|
||||
tuplesNeeded = append(tuplesNeeded, gomatrixserverlib.StateKeyTuple{
|
||||
EventType: "m.room.server_acl",
|
||||
EventType: acls.MRoomServerACL,
|
||||
StateKey: "",
|
||||
})
|
||||
stateBeforeReq := &api.QueryStateAfterEventsRequest{
|
||||
|
|
@ -585,7 +586,7 @@ func (r *Inputer) processStateBefore(
|
|||
// Work out what the history visibility/ACLs was at the time of the
|
||||
// event.
|
||||
for _, event := range stateBeforeEvent {
|
||||
if event.Type() == "m.room.server_acl" && event.StateKeyEquals("") {
|
||||
if input.Kind == api.KindNew && event.Type() == acls.MRoomServerACL && event.StateKeyEquals("") {
|
||||
r.ACLs.OnServerACLUpdate(event)
|
||||
}
|
||||
if event.Type() != gomatrixserverlib.MRoomHistoryVisibility || !event.StateKeyEquals("") {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func (r *RoomEventProducer) ProduceRoomEvents(roomID string, updates []api.Outpu
|
|||
}
|
||||
}
|
||||
|
||||
if eventType == "m.room.server_acl" && update.NewRoomEvent.Event.StateKeyEquals("") {
|
||||
if eventType == acls.MRoomServerACL && update.NewRoomEvent.Event.StateKeyEquals("") {
|
||||
ev := update.NewRoomEvent.Event.Unwrap()
|
||||
defer r.ACLs.OnServerACLUpdate(ev)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ func TestNewServerACLs(t *testing.T) {
|
|||
alice := test.NewUser(t)
|
||||
roomWithACL := test.NewRoom(t, alice)
|
||||
|
||||
roomWithACL.CreateAndInsert(t, alice, "m.room.server_acl", acls.ServerACL{
|
||||
roomWithACL.CreateAndInsert(t, alice, acls.MRoomServerACL, acls.ServerACL{
|
||||
Allowed: []string{"*"},
|
||||
Denied: []string{"localhost"},
|
||||
AllowIPLiterals: false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue