1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
import { MatrixClient } from "./client";
import { MatrixEvent } from "./models/event";
import { IPushRule, IPushRules, PushRuleAction, PushRuleKind, TweakName } from "./@types/PushRules";
export interface IActionsObject {
/** Whether this event should notify the user or not. */
notify: boolean;
/** How this event should be notified. */
tweaks: Partial<Record<TweakName, any>>;
}
export declare class PushProcessor {
private readonly client;
/**
* Construct a Push Processor.
* @param client - The Matrix client object to use
*/
constructor(client: MatrixClient);
/**
* Maps the original key from the push rules to a list of property names
* after unescaping.
*/
private readonly parsedKeys;
/**
* Convert a list of actions into a object with the actions as keys and their values
* @example
* eg. `[ 'notify', { set_tweak: 'sound', value: 'default' } ]`
* becomes `{ notify: true, tweaks: { sound: 'default' } }`
* @param actionList - The actions list
*
* @returns A object with key 'notify' (true or false) and an object of actions
*/
static actionListToActionsObject(actionList: PushRuleAction[]): IActionsObject;
/**
* Rewrites conditions on a client's push rules to match the defaults
* where applicable. Useful for upgrading push rules to more strict
* conditions when the server is falling behind on defaults.
* @param incomingRules - The client's existing push rules
* @param userId - The Matrix ID of the client.
* @returns The rewritten rules
*/
static rewriteDefaultRules(incomingRules: IPushRules, userId?: string | undefined): IPushRules;
/**
* Pre-caches the parsed keys for push rules and cleans out any obsolete cache
* entries. Should be called after push rules are updated.
* @param newRules - The new push rules.
*/
updateCachedPushRuleKeys(newRules: IPushRules): void;
private static cachedGlobToRegex;
private matchingRuleFromKindSet;
private templateRuleToRaw;
private eventFulfillsCondition;
private eventFulfillsSenderNotifPermCondition;
private eventFulfillsRoomMemberCountCondition;
private eventFulfillsDisplayNameCondition;
/**
* 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;
/**
* Check whether the given event matches the push rule condition by fetching
* the property from the event and comparing exactly against the condition's
* value.
* @param cond - The push rule condition to check for a match.
* @param ev - The event to check for a match.
*/
private eventFulfillsEventPropertyIsCondition;
/**
* Check whether the given event matches the push rule condition by fetching
* the property from the event and comparing exactly against the condition's
* value.
* @param cond - The push rule condition to check for a match.
* @param ev - The event to check for a match.
*/
private eventFulfillsEventPropertyContains;
private eventFulfillsCallStartedCondition;
private createCachedRegex;
/**
* Parse the key into the separate fields to search by splitting on
* unescaped ".", and then removing any escape characters.
*
* @param str - The key of the push rule condition: a dotted field.
* @returns The unescaped parts to fetch.
* @internal
*/
static partsForDottedKey(str: string): string[];
/**
* For a dotted field and event, fetch the value at that position, if one
* exists.
*
* @param key - The key of the push rule condition: a dotted field to fetch.
* @param ev - The matrix event to fetch the field from.
* @returns The value at the dotted path given by key.
*/
private valueForDottedKey;
private matchingRuleForEventWithRulesets;
private pushActionsForEventAndRulesets;
ruleMatchesEvent(rule: Partial<IPushRule> & Pick<IPushRule, "conditions">, ev: MatrixEvent): boolean;
/**
* Get the user's push actions for the given event
*/
actionsForEvent(ev: MatrixEvent): IActionsObject;
/**
* Get one of the users push rules by its ID
*
* @param ruleId - The ID of the rule to search for
* @returns The push rule, or null if no such rule was found
*/
getPushRuleById(ruleId: string): IPushRule | null;
/**
* Get one of the users push rules by its ID
*
* @param ruleId - The ID of the rule to search for
* @returns rule The push rule, or null if no such rule was found
* @returns kind - The PushRuleKind of the rule to search for
*/
getPushRuleAndKindById(ruleId: string): {
rule: IPushRule;
kind: PushRuleKind;
} | null;
}
//# sourceMappingURL=pushprocessor.d.ts.map
|