feat: Add sender-based routing support with backward compatibility (Fixes #145)#157
Open
EINDEX wants to merge 13 commits into
Open
feat: Add sender-based routing support with backward compatibility (Fixes #145)#157EINDEX wants to merge 13 commits into
EINDEX wants to merge 13 commits into
Conversation
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3 to 4. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@v3...v4) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: '4' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
…gurations - Modified the senders attribute to include receiver keys. - Enhanced the load_from_yaml function to handle both direct and nested configurations. - Updated tests to reflect changes in sender and receiver key handling. Signed-off-by: EINDEX <snowstarlbk@gmail.com>
|
Hey @EINDEX, I opened issue #164 because the recipient email address doesn't allow periods (e.g., If you could modify the two functions below as follows, this would be possible while preserving all existing functionality: class Sent2RecvRouter(Router):
[...]
async def email_to_apprise(
self, logger: Logger, email: EmailMessage, auth_data: typ.Any, **kwargs) \
-> typ.AsyncGenerator[AppriseNotification, None]:
[...]
mapping = {
'subject': email.subject,
'from': email.from_,
'from_name': email.from_.partition('<')[0].strip(),
'body': email.body,
'to': str(rcpt.key),
'config': rcpt.key.as_configured(),
'type': rcpt.notify_type
}
def _parse_sent2recv_key(logger: Logger, key: str) -> _Key:
def fatal():
logger.critical(
"Invalid config key '%s'; should be a string or an email address",
key)
raise SystemExit(1)
if '@' in key:
user, domain = _parseaddrparts(key)
if not user or not domain:
fatal()
return _Key(user=user, domain=domain.lower())
if '.' in key:
fatal()
return _Key(user=key)Maybe you could include this in your pull request as well 😄 Thanks for your great work. |
|
Hey, sorry it took me a while to test this. Could you add the single line class Sent2RecvRouter(Router):
[...]
async def email_to_apprise(
self, logger: Logger, email: EmailMessage, auth_data: typ.Any, **kwargs) \
-> typ.AsyncGenerator[AppriseNotification, None]:
[...]
mapping = {
'subject': email.subject,
'from': email.from_,
'from_name': email.from_.partition('<')[0].strip(),
'body': email.body,
'to': str(rcpt.key),
'config': rcpt.key.as_configured(),
'type': rcpt.notify_type
}This allows the Let’s hope @YoRyan picks up on these changes soon, including an Apprise update. |
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.
Summary
Adds support for routing notifications by sender address in addition to recipient address.
Backward compatible: existing
configs.<recipient>direct configurations keep their recipient-based meaning.Resolves #145
Changes
SimpleRouterto match sender and recipient patterns usingfnmatchrecipient -> configwith an implicit*@*sendersender -> recipient -> configfor sender-scoped routingExamples
Sender-scoped routing for any recipient:
Fine-grained sender and recipient routing:
Testing
/Users/eindex/.pyenv/versions/3.12.3/bin/python -m pytest -qFollow-up
Dotted full email config keys are handled in stacked PR EINDEX#1 for #164.