Open
Conversation
42b0114 to
4528a0a
Compare
456c4fe to
a6fb5b2
Compare
Based on Issue ranmocy#36, allows matching on any header and value. ``` (header X-Custom-Header /value/) ``` As we use `GmailMessage.getHeader` function, the header name used in the condition must be case-sensitive. Overall flow: - Rules are parsed, and a list of condition-requested-headers is created. - ThreadData reads in the message data, and all the headers that were requested in the rules (we have to pass SessionData to ThreadData so it knows which headers to search). - Condition.match checks what header to match with, and compares the header's value with the rule's value. In order to get the SessionData.mock.ts to work, SessionData.labels had to be made public. This seems to be a limitation we will continue to hit in testing if we want to test on Sheet Apps, since we cannot use other better libraries.
a6fb5b2 to
3e6fa8d
Compare
Contributor
Author
|
Hi @ranmocy , Any thoughts on this PR? |
gummywubbins
reviewed
Jul 6, 2023
| const first_space = condition_str.indexOf(" "); | ||
| const type_str = condition_str.substring(1, first_space).trim().toUpperCase(); | ||
| const rest_str = condition_str.substring(first_space + 1, condition_str.length - 1).trim(); | ||
| let rest_str = condition_str.substring(first_space + 1, condition_str.length - 1).trim(); |
There was a problem hiding this comment.
The .length - 1 was clipping the last letter off the value I was using
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Match on arbitrary header and value.
Resolves #36, allows matching on any header and value.
As we use
GmailMessage.getHeaderfunction, the header name used in the condition must be case-sensitive.Overall flow:
that were requested in the rules (we have to pass SessionData to ThreadData so it knows which headers to search).
In order to get the SessionData.mock.ts to work, SessionData.labels had to be made public. This seems to be a limitation we will continue to hit in testing if we want to test on Sheet Apps, since we cannot use other better libraries.
NOTE: This utilizes @aaronj1335 's Utils PR (or I could not run anything).
NOTE2: This also utilizes my #65 Refactor tests, so that we can more easily test this feature.