From b3cca772f655c1ae066a6123d726a09079b4594b Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Tue, 25 Oct 2022 17:30:45 -0400 Subject: [PATCH] Mailgun to support `from=` for consistency with `email://` (#711) --- apprise/plugins/NotifyMailgun.py | 9 +++++++++ test/test_plugin_mailgun.py | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/apprise/plugins/NotifyMailgun.py b/apprise/plugins/NotifyMailgun.py index c3d2fe8d..1010f8ef 100644 --- a/apprise/plugins/NotifyMailgun.py +++ b/apprise/plugins/NotifyMailgun.py @@ -160,6 +160,9 @@ class NotifyMailgun(NotifyBase): 'type': 'string', 'map_to': 'from_name', }, + 'from': { + 'alias_of': 'name', + }, 'region': { 'name': _('Region Name'), 'type': 'choice:string', @@ -642,6 +645,12 @@ class NotifyMailgun(NotifyBase): results['from_name'] = \ NotifyMailgun.unquote(results['qsd']['name']) + # Support from= for consistency with `mail://` + elif 'from' in results['qsd'] and len(results['qsd']['from']): + # Extract from name to associate with from address + results['from_name'] = \ + NotifyMailgun.unquote(results['qsd']['name']) + if 'region' in results['qsd'] and len(results['qsd']['region']): # Extract from name to associate with from address results['region_name'] = \ diff --git a/test/test_plugin_mailgun.py b/test/test_plugin_mailgun.py index 1fc3d7fb..30888388 100644 --- a/test/test_plugin_mailgun.py +++ b/test/test_plugin_mailgun.py @@ -107,6 +107,12 @@ apprise_url_tests = ( 'a' * 32, 'b' * 8, 'c' * 8), { 'instance': NotifyMailgun, }), + # We can use the `from=` directive as well: + ('mailgun://user@localhost.localdomain/{}-{}-{}' + '?:from=Chris&:status=admin'.format( + 'a' * 32, 'b' * 8, 'c' * 8), { + 'instance': NotifyMailgun, + }), # bcc and cc ('mailgun://user@localhost.localdomain/{}-{}-{}' '?bcc=user@example.com&cc=user2@example.com'.format(