Skip to content

Commit

Permalink
Add some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Mar 1, 2023
1 parent c8a4d9b commit 4862c23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/@types/PushRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export interface IPushRuleCondition<N extends ConditionKind | string> {
export interface IEventMatchCondition extends IPushRuleCondition<ConditionKind.EventMatch> {
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;
}

Expand Down
10 changes: 10 additions & 0 deletions src/pushprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 4862c23

Please sign in to comment.