From 7c193bd695cfa7aaa5f2bdf0877043eb9df65924 Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:11:40 +0100 Subject: [PATCH] Fix further issues --- federationapi/queue/destinationqueue.go | 1 - internal/pushrules/default_override.go | 6 +----- roomserver/internal/input/input_events.go | 10 +++++----- roomserver/storage/tables/interface_test.go | 19 ++++++++++--------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/federationapi/queue/destinationqueue.go b/federationapi/queue/destinationqueue.go index 9bfafbea6..f51e849fa 100644 --- a/federationapi/queue/destinationqueue.go +++ b/federationapi/queue/destinationqueue.go @@ -31,7 +31,6 @@ import ( "github.com/matrix-org/dendrite/federationapi/statistics" "github.com/matrix-org/dendrite/federationapi/storage" "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/setup/process" ) diff --git a/internal/pushrules/default_override.go b/internal/pushrules/default_override.go index 2266e3b0d..cb825af5f 100644 --- a/internal/pushrules/default_override.go +++ b/internal/pushrules/default_override.go @@ -1,9 +1,5 @@ package pushrules -import ( - "github.com/matrix-org/dendrite/roomserver/acls" -) - func defaultOverrideRules(userID string) []*Rule { return []*Rule{ &mRuleMasterDefinition, @@ -113,7 +109,7 @@ var ( { Kind: EventMatchCondition, Key: "type", - Pattern: pointer(acls.MRoomServerACL), + Pattern: pointer("m.room.server_acl"), }, { Kind: EventMatchCondition, diff --git a/roomserver/internal/input/input_events.go b/roomserver/internal/input/input_events.go index 4422b3c58..520f82a80 100644 --- a/roomserver/internal/input/input_events.go +++ b/roomserver/internal/input/input_events.go @@ -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 // 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() == gomatrixserverlib.MRoomMember { + if event.Type() == spec.MRoomMember { membership, _ := event.Membership() - if membership == gomatrixserverlib.Join { + if membership == spec.Join { _, serverName, _ := gomatrixserverlib.SplitID('@', *event.StateKey()) // only handle local membership events if r.Cfg.Matrix.IsLocalServerName(serverName) { - var aclEvent *gomatrixserverlib.HeaderedEvent - aclEvent, err = r.DB.GetStateEvent(ctx, event.RoomID(), acls.MRoomServerACL, "") + 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.Event) + r.ACLs.OnServerACLUpdate(aclEvent) } } } diff --git a/roomserver/storage/tables/interface_test.go b/roomserver/storage/tables/interface_test.go index 16f957b54..8727e2436 100644 --- a/roomserver/storage/tables/interface_test.go +++ b/roomserver/storage/tables/interface_test.go @@ -3,8 +3,9 @@ package tables import ( "testing" + "github.com/matrix-org/dendrite/roomserver/types" "github.com/matrix-org/dendrite/test" - "github.com/matrix-org/gomatrixserverlib" + "github.com/matrix-org/gomatrixserverlib/spec" "github.com/stretchr/testify/assert" ) @@ -14,7 +15,7 @@ func TestExtractContentValue(t *testing.T) { tests := []struct { name string - event *gomatrixserverlib.HeaderedEvent + event *types.HeaderedEvent want string }{ { @@ -24,37 +25,37 @@ func TestExtractContentValue(t *testing.T) { }, { 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", }, { 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", }, { 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", }, { 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", }, { 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", }, { 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", }, { 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", }, {