summaryrefslogtreecommitdiff
path: root/includes/external/matrix/node_modules/matrix-js-sdk/lib/pushprocessor.d.ts
diff options
context:
space:
mode:
Diffstat (limited to 'includes/external/matrix/node_modules/matrix-js-sdk/lib/pushprocessor.d.ts')
-rw-r--r--includes/external/matrix/node_modules/matrix-js-sdk/lib/pushprocessor.d.ts124
1 files changed, 124 insertions, 0 deletions
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/pushprocessor.d.ts b/includes/external/matrix/node_modules/matrix-js-sdk/lib/pushprocessor.d.ts
new file mode 100644
index 0000000..c0d6ed5
--- /dev/null
+++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/pushprocessor.d.ts
@@ -0,0 +1,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 \ No newline at end of file