support regex matching against specific keys #486
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
edit: See latest comment for the updated design.
I made a small change to the server, to support regex-matching against specific labels in the event.
For example, on macOS, Messages.app's window title consists only of the name of the contact. Matching against "John Doe" with the default
regex
rule would match either theapp
ortitle
label, which would be insufficient, as it would also match other apps for which the title contains "John Doe".With this new
KeyValue
rule, you can now specifically define in which field the value is expected to match.For the above example, the following change is made to the configuration JSON:
Specifically,
rule.type
is changed fromregex
tokeyvalue
andrule.regex
is changed torule.rules
which is a list of objects, for which the key is the name of the field you want to match against, and the value is a rule object (so in the future, this could support glob rules as well).Note that I'm adding these rules directly in the SQLite database, I did not update the UI, so that'll have to be tackled by someone else if this is deemed worthy of including in a future release.
There are also no tests, currently. I'm willing to add those, but it might take a few days/weeks before I get to that. This was mainly a quick change to scratch an itch I had, and I wanted to push this up to see if this can land in an official release in the future.