Merge branch 'nico/fix-unknown-push-conditions' into 'main'
fix: Skip rules with unknown conditions See merge request famedly/company/frontend/famedlysdk!1277
This commit is contained in:
commit
aa24c0ce66
|
|
@ -186,6 +186,8 @@ class _OptimizedRules {
|
|||
notificationPermissions.add(key);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw Exception('Unknown push condition: ${condition.kind}');
|
||||
}
|
||||
}
|
||||
actions = EvaluatedPushRuleAction.fromActions(rule.actions);
|
||||
|
|
|
|||
|
|
@ -208,6 +208,29 @@ void main() {
|
|||
testNotMatch(override_ruleset2, event);
|
||||
});
|
||||
|
||||
test('invalid push condition', () async {
|
||||
final invalid_ruleset = PushRuleSet(override: [
|
||||
PushRule(ruleId: 'my.rule', default$: false, enabled: true, actions: [
|
||||
'notify',
|
||||
{'set_tweak': 'highlight', 'value': true},
|
||||
{'set_tweak': 'sound', 'value': 'goose.wav'},
|
||||
], conditions: [
|
||||
PushCondition(
|
||||
kind: 'invalidcondition', pattern: 'fox', key: 'content.body'),
|
||||
])
|
||||
]);
|
||||
|
||||
expect(() => PushruleEvaluator.fromRuleset(invalid_ruleset),
|
||||
returnsNormally);
|
||||
|
||||
final evaluator = PushruleEvaluator.fromRuleset(invalid_ruleset);
|
||||
final event = Event.fromJson(jsonObj, room);
|
||||
final actions = evaluator.match(event);
|
||||
expect(actions.highlight, false);
|
||||
expect(actions.sound, null);
|
||||
expect(actions.notify, false);
|
||||
});
|
||||
|
||||
test('match_display_name rule', () async {
|
||||
final event = Event.fromJson(jsonObj, room);
|
||||
(event.room.states[EventTypes.RoomMember] ??= {})[client.userID!] =
|
||||
|
|
|
|||
Loading…
Reference in New Issue