mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-06 22:43:10 -06:00
Fix further issues
This commit is contained in:
parent
ca8774fed5
commit
7c193bd695
|
|
@ -31,7 +31,6 @@ import (
|
||||||
"github.com/matrix-org/dendrite/federationapi/statistics"
|
"github.com/matrix-org/dendrite/federationapi/statistics"
|
||||||
"github.com/matrix-org/dendrite/federationapi/storage"
|
"github.com/matrix-org/dendrite/federationapi/storage"
|
||||||
"github.com/matrix-org/dendrite/federationapi/storage/shared/receipt"
|
"github.com/matrix-org/dendrite/federationapi/storage/shared/receipt"
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/types"
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
"github.com/matrix-org/dendrite/setup/process"
|
"github.com/matrix-org/dendrite/setup/process"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,5 @@
|
||||||
package pushrules
|
package pushrules
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/matrix-org/dendrite/roomserver/acls"
|
|
||||||
)
|
|
||||||
|
|
||||||
func defaultOverrideRules(userID string) []*Rule {
|
func defaultOverrideRules(userID string) []*Rule {
|
||||||
return []*Rule{
|
return []*Rule{
|
||||||
&mRuleMasterDefinition,
|
&mRuleMasterDefinition,
|
||||||
|
|
@ -113,7 +109,7 @@ var (
|
||||||
{
|
{
|
||||||
Kind: EventMatchCondition,
|
Kind: EventMatchCondition,
|
||||||
Key: "type",
|
Key: "type",
|
||||||
Pattern: pointer(acls.MRoomServerACL),
|
Pattern: pointer("m.room.server_acl"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Kind: EventMatchCondition,
|
Kind: EventMatchCondition,
|
||||||
|
|
|
||||||
|
|
@ -495,19 +495,19 @@ func (r *Inputer) processRoomEvent(
|
||||||
// If this is a membership event, it is possible we newly joined a federated room and eventually
|
// 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
|
// missed to update our m.room.server_acl - the following ensures we set the ACLs
|
||||||
// TODO: This probably performs badly in benchmarks
|
// TODO: This probably performs badly in benchmarks
|
||||||
if event.Type() == gomatrixserverlib.MRoomMember {
|
if event.Type() == spec.MRoomMember {
|
||||||
membership, _ := event.Membership()
|
membership, _ := event.Membership()
|
||||||
if membership == gomatrixserverlib.Join {
|
if membership == spec.Join {
|
||||||
_, serverName, _ := gomatrixserverlib.SplitID('@', *event.StateKey())
|
_, serverName, _ := gomatrixserverlib.SplitID('@', *event.StateKey())
|
||||||
// only handle local membership events
|
// only handle local membership events
|
||||||
if r.Cfg.Matrix.IsLocalServerName(serverName) {
|
if r.Cfg.Matrix.IsLocalServerName(serverName) {
|
||||||
var aclEvent *gomatrixserverlib.HeaderedEvent
|
var aclEvent *types.HeaderedEvent
|
||||||
aclEvent, err = r.DB.GetStateEvent(ctx, event.RoomID(), acls.MRoomServerACL, "")
|
aclEvent, err = r.DB.GetStateEvent(ctx, event.RoomID().String(), acls.MRoomServerACL, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("failed to get server ACLs")
|
logrus.WithError(err).Error("failed to get server ACLs")
|
||||||
}
|
}
|
||||||
if aclEvent != nil {
|
if aclEvent != nil {
|
||||||
r.ACLs.OnServerACLUpdate(aclEvent.Event)
|
r.ACLs.OnServerACLUpdate(aclEvent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@ package tables
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/roomserver/types"
|
||||||
"github.com/matrix-org/dendrite/test"
|
"github.com/matrix-org/dendrite/test"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib/spec"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -14,7 +15,7 @@ func TestExtractContentValue(t *testing.T) {
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
event *gomatrixserverlib.HeaderedEvent
|
event *types.HeaderedEvent
|
||||||
want string
|
want string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
|
@ -24,37 +25,37 @@ func TestExtractContentValue(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "returns the alias for canonical alias events",
|
name: "returns the alias for canonical alias events",
|
||||||
event: room.CreateEvent(t, alice, gomatrixserverlib.MRoomCanonicalAlias, map[string]string{"alias": "#test:test"}),
|
event: room.CreateEvent(t, alice, spec.MRoomCanonicalAlias, map[string]string{"alias": "#test:test"}),
|
||||||
want: "#test:test",
|
want: "#test:test",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "returns the history_visibility for history visibility events",
|
name: "returns the history_visibility for history visibility events",
|
||||||
event: room.CreateEvent(t, alice, gomatrixserverlib.MRoomHistoryVisibility, map[string]string{"history_visibility": "shared"}),
|
event: room.CreateEvent(t, alice, spec.MRoomHistoryVisibility, map[string]string{"history_visibility": "shared"}),
|
||||||
want: "shared",
|
want: "shared",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "returns the join rules for join_rules events",
|
name: "returns the join rules for join_rules events",
|
||||||
event: room.CreateEvent(t, alice, gomatrixserverlib.MRoomJoinRules, map[string]string{"join_rule": "public"}),
|
event: room.CreateEvent(t, alice, spec.MRoomJoinRules, map[string]string{"join_rule": "public"}),
|
||||||
want: "public",
|
want: "public",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "returns the membership for room_member events",
|
name: "returns the membership for room_member events",
|
||||||
event: room.CreateEvent(t, alice, gomatrixserverlib.MRoomMember, map[string]string{"membership": "join"}, test.WithStateKey(alice.ID)),
|
event: room.CreateEvent(t, alice, spec.MRoomMember, map[string]string{"membership": "join"}, test.WithStateKey(alice.ID)),
|
||||||
want: "join",
|
want: "join",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "returns the room name for room_name events",
|
name: "returns the room name for room_name events",
|
||||||
event: room.CreateEvent(t, alice, gomatrixserverlib.MRoomName, map[string]string{"name": "testing"}, test.WithStateKey(alice.ID)),
|
event: room.CreateEvent(t, alice, spec.MRoomName, map[string]string{"name": "testing"}, test.WithStateKey(alice.ID)),
|
||||||
want: "testing",
|
want: "testing",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "returns the room avatar for avatar events",
|
name: "returns the room avatar for avatar events",
|
||||||
event: room.CreateEvent(t, alice, gomatrixserverlib.MRoomAvatar, map[string]string{"url": "mxc://testing"}, test.WithStateKey(alice.ID)),
|
event: room.CreateEvent(t, alice, spec.MRoomAvatar, map[string]string{"url": "mxc://testing"}, test.WithStateKey(alice.ID)),
|
||||||
want: "mxc://testing",
|
want: "mxc://testing",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "returns the room topic for topic events",
|
name: "returns the room topic for topic events",
|
||||||
event: room.CreateEvent(t, alice, gomatrixserverlib.MRoomTopic, map[string]string{"topic": "testing"}, test.WithStateKey(alice.ID)),
|
event: room.CreateEvent(t, alice, spec.MRoomTopic, map[string]string{"topic": "testing"}, test.WithStateKey(alice.ID)),
|
||||||
want: "testing",
|
want: "testing",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue