From 7613a3996218a43d9c461c54b2ddec3b06065aa5 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 27 Feb 2023 14:40:47 -0500 Subject: [PATCH] Add some comments. --- src/@types/PushRules.ts | 2 ++ src/pushprocessor.ts | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/@types/PushRules.ts b/src/@types/PushRules.ts index 56a93df9fb3..f77dcc4159f 100644 --- a/src/@types/PushRules.ts +++ b/src/@types/PushRules.ts @@ -77,6 +77,8 @@ export interface IPushRuleCondition { export interface IEventMatchCondition extends IPushRuleCondition { key: string; pattern?: string; + // Note that value property is an optimization for patterns which do not do + // any globbing and when the key is not "content.body". value?: string; } diff --git a/src/pushprocessor.ts b/src/pushprocessor.ts index 2bbf8fbdb9c..805d70f2505 100644 --- a/src/pushprocessor.ts +++ b/src/pushprocessor.ts @@ -435,6 +435,13 @@ export class PushProcessor { return content.body.search(pat) > -1; } + /** + * Check whether the given event matches the push rule condition by fetching + * the property from the event and comparing against the condition's glob-based + * pattern. + * @param cond - The push rule condition to check for a match. + * @param ev - The event to check for a match. + */ private eventFulfillsEventMatchCondition(cond: IEventMatchCondition, ev: MatrixEvent): boolean { if (!cond.key) { return false; @@ -445,6 +452,9 @@ export class PushProcessor { return false; } + // XXX This does not match in a case-insensitive manner. + // + // See https://spec.matrix.org/v1.5/client-server-api/#conditions-1 if (cond.value) { return cond.value === val; }