mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Don't match state_key push rules for non-state events
This commit is contained in:
parent
b1ead68d12
commit
f6944f6390
2 changed files with 9 additions and 1 deletions
|
|
@ -155,7 +155,7 @@ func (cond *PushCondition) matchValue(room Room, evt *event.Event) bool {
|
|||
return pattern.MatchString(string(evt.RoomID))
|
||||
case "state_key":
|
||||
if evt.StateKey == nil {
|
||||
return cond.Pattern == ""
|
||||
return false
|
||||
}
|
||||
return pattern.MatchString(*evt.StateKey)
|
||||
case "content":
|
||||
|
|
|
|||
|
|
@ -60,9 +60,17 @@ func TestPushCondition_Match_KindEvent_RoomID(t *testing.T) {
|
|||
func TestPushCondition_Match_KindEvent_BlankStateKey(t *testing.T) {
|
||||
condition := newMatchPushCondition("state_key", "")
|
||||
evt := newFakeEvent(event.NewEventType("m.room.foo"), &struct{}{})
|
||||
blankString := ""
|
||||
evt.StateKey = &blankString
|
||||
assert.True(t, condition.Match(blankTestRoom, evt))
|
||||
}
|
||||
|
||||
func TestPushCondition_Match_KindEvent_NonStateStateKey(t *testing.T) {
|
||||
condition := newMatchPushCondition("state_key", "")
|
||||
evt := newFakeEvent(event.NewEventType("m.room.foo"), &struct{}{})
|
||||
assert.False(t, condition.Match(blankTestRoom, evt))
|
||||
}
|
||||
|
||||
func TestPushCondition_Match_KindEvent_BlankStateKey_Fail(t *testing.T) {
|
||||
condition := newMatchPushCondition("state_key", "not blank")
|
||||
evt := newFakeEvent(event.NewEventType("m.room.foo"), &struct{}{})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue