aboutsummaryrefslogtreecommitdiff
path: root/roomserver
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2023-10-25 09:47:21 +0200
committerGitHub <noreply@github.com>2023-10-25 09:47:21 +0200
commit4fa8512d576ca2a425e6cc546264934d959bced5 (patch)
tree7931367c774d168535583ed294c3d05d11fed7d3 /roomserver
parent1b124fe9cba8b4699a1f65382e4ea1a5674d12fa (diff)
Check event is not rejected (#3243)
Companion PR to https://github.com/matrix-org/gomatrixserverlib/pull/421
Diffstat (limited to 'roomserver')
-rw-r--r--roomserver/internal/input/input_missing.go7
-rw-r--r--roomserver/internal/query/query.go14
-rw-r--r--roomserver/state/state.go8
-rw-r--r--roomserver/storage/shared/room_updater.go4
4 files changed, 33 insertions, 0 deletions
diff --git a/roomserver/internal/input/input_missing.go b/roomserver/internal/input/input_missing.go
index d9ab291e..21493287 100644
--- a/roomserver/internal/input/input_missing.go
+++ b/roomserver/internal/input/input_missing.go
@@ -498,6 +498,13 @@ func (t *missingStateReq) resolveStatesAndCheck(ctx context.Context, roomVersion
roomVersion, gomatrixserverlib.ToPDUs(stateEventList), gomatrixserverlib.ToPDUs(authEventList), func(roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error) {
return t.inputer.Queryer.QueryUserIDForSender(ctx, roomID, senderID)
},
+ func(eventID string) bool {
+ isRejected, err := t.db.IsEventRejected(ctx, t.roomInfo.RoomNID, eventID)
+ if err != nil {
+ return true
+ }
+ return isRejected
+ },
)
if err != nil {
return nil, err
diff --git a/roomserver/internal/query/query.go b/roomserver/internal/query/query.go
index f87a3f7e..74b01028 100644
--- a/roomserver/internal/query/query.go
+++ b/roomserver/internal/query/query.go
@@ -165,6 +165,13 @@ func (r *Queryer) QueryStateAfterEvents(
info.RoomVersion, gomatrixserverlib.ToPDUs(stateEvents), gomatrixserverlib.ToPDUs(authEvents), func(roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error) {
return r.QueryUserIDForSender(ctx, roomID, senderID)
},
+ func(eventID string) bool {
+ isRejected, rejectedErr := r.DB.IsEventRejected(ctx, info.RoomNID, eventID)
+ if rejectedErr != nil {
+ return true
+ }
+ return isRejected
+ },
)
if err != nil {
return fmt.Errorf("state.ResolveConflictsAdhoc: %w", err)
@@ -676,6 +683,13 @@ func (r *Queryer) QueryStateAndAuthChain(
info.RoomVersion, gomatrixserverlib.ToPDUs(stateEvents), gomatrixserverlib.ToPDUs(authEvents), func(roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error) {
return r.QueryUserIDForSender(ctx, roomID, senderID)
},
+ func(eventID string) bool {
+ isRejected, rejectedErr := r.DB.IsEventRejected(ctx, info.RoomNID, eventID)
+ if rejectedErr != nil {
+ return true
+ }
+ return isRejected
+ },
)
if err != nil {
return err
diff --git a/roomserver/state/state.go b/roomserver/state/state.go
index 1e776ff6..dfd439a2 100644
--- a/roomserver/state/state.go
+++ b/roomserver/state/state.go
@@ -45,6 +45,7 @@ type StateResolutionStorage interface {
AddState(ctx context.Context, roomNID types.RoomNID, stateBlockNIDs []types.StateBlockNID, state []types.StateEntry) (types.StateSnapshotNID, error)
Events(ctx context.Context, roomVersion gomatrixserverlib.RoomVersion, eventNIDs []types.EventNID) ([]types.Event, error)
EventsFromIDs(ctx context.Context, roomInfo *types.RoomInfo, eventIDs []string) ([]types.Event, error)
+ IsEventRejected(ctx context.Context, roomNID types.RoomNID, eventID string) (bool, error)
}
type StateResolution struct {
@@ -1066,6 +1067,13 @@ func (v *StateResolution) resolveConflictsV2(
func(roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error) {
return v.Querier.QueryUserIDForSender(ctx, roomID, senderID)
},
+ func(eventID string) bool {
+ isRejected, err := v.db.IsEventRejected(ctx, v.roomInfo.RoomNID, eventID)
+ if err != nil {
+ return true
+ }
+ return isRejected
+ },
)
}()
diff --git a/roomserver/storage/shared/room_updater.go b/roomserver/storage/shared/room_updater.go
index 70672a33..06284d2e 100644
--- a/roomserver/storage/shared/room_updater.go
+++ b/roomserver/storage/shared/room_updater.go
@@ -250,3 +250,7 @@ func (u *RoomUpdater) MarkEventAsSent(eventNID types.EventNID) error {
func (u *RoomUpdater) MembershipUpdater(targetUserNID types.EventStateKeyNID, targetLocal bool) (*MembershipUpdater, error) {
return u.d.membershipUpdaterTxn(u.ctx, u.txn, u.roomInfo.RoomNID, targetUserNID, targetLocal)
}
+
+func (u *RoomUpdater) IsEventRejected(ctx context.Context, roomNID types.RoomNID, eventID string) (bool, error) {
+ return u.d.IsEventRejected(ctx, roomNID, eventID)
+}