diff --git a/apprise/plugins/NotifyGotify.py b/apprise/plugins/NotifyGotify.py index 18b7b1c3..c1a4dc92 100644 --- a/apprise/plugins/NotifyGotify.py +++ b/apprise/plugins/NotifyGotify.py @@ -89,6 +89,8 @@ class NotifyGotify(NotifyBase): templates = ( '{schema}://{host}/{token}', '{schema}://{host}:{port}/{token}', + '{schema}://{host}{path}{token}', + '{schema}://{host}:{port}{path}{token}', ) # Define our template tokens @@ -104,6 +106,13 @@ class NotifyGotify(NotifyBase): 'type': 'string', 'required': True, }, + 'path': { + 'name': _('Path'), + 'type': 'string', + 'map_to': 'fullpath', + 'default': '/', + 'required': True, + }, 'port': { 'name': _('Port'), 'type': 'int', @@ -137,6 +146,9 @@ class NotifyGotify(NotifyBase): self.logger.warning(msg) raise TypeError(msg) + # prepare our fullpath + self.fullpath = kwargs.get('fullpath', '/') + if priority not in GOTIFY_PRIORITIES: self.priority = GotifyPriority.NORMAL @@ -161,7 +173,7 @@ class NotifyGotify(NotifyBase): url += ':%d' % self.port # Append our remaining path - url += '/message' + url += '{fullpath}message'.format(fullpath=self.fullpath) # Define our parameteers params = { @@ -245,11 +257,12 @@ class NotifyGotify(NotifyBase): default_port = 443 if self.secure else 80 - return '{schema}://{hostname}{port}/{token}/?{args}'.format( + return '{schema}://{hostname}{port}{fullpath}{token}/?{args}'.format( schema=self.secure_protocol if self.secure else self.protocol, hostname=NotifyGotify.quote(self.host, safe=''), port='' if self.port is None or self.port == default_port else ':{}'.format(self.port), + fullpath=NotifyGotify.quote(self.fullpath, safe='/'), token=self.pprint(self.token, privacy, safe=''), args=NotifyGotify.urlencode(args), ) @@ -271,13 +284,17 @@ class NotifyGotify(NotifyBase): # optionally find the provider key try: - # The first entry is our token - results['token'] = entries.pop(0) + # The last entry is our token + results['token'] = entries.pop() except IndexError: # No token was set results['token'] = None + # Re-assemble our full path + results['fullpath'] = \ + '/' if not entries else '/{}/'.format('/'.join(entries)) + if 'priority' in results['qsd'] and len(results['qsd']['priority']): _map = { 'l': GotifyPriority.LOW, diff --git a/apprise/plugins/NotifyNotica.py b/apprise/plugins/NotifyNotica.py index fea81949..1ac22c12 100644 --- a/apprise/plugins/NotifyNotica.py +++ b/apprise/plugins/NotifyNotica.py @@ -103,6 +103,14 @@ class NotifyNotica(NotifyBase): '{schema}://{user}@{host}:{port}/{token}', '{schema}://{user}:{password}@{host}/{token}', '{schema}://{user}:{password}@{host}:{port}/{token}', + + # Self-hosted notica servers (with custom path) + '{schema}://{host}{path}{token}', + '{schema}://{host}:{port}{path}{token}', + '{schema}://{user}@{host}{path}{token}', + '{schema}://{user}@{host}:{port}{path}{token}', + '{schema}://{user}:{password}@{host}{path}{token}', + '{schema}://{user}:{password}@{host}:{port}{path}{token}', ) # Define our template tokens @@ -133,6 +141,12 @@ class NotifyNotica(NotifyBase): 'type': 'string', 'private': True, }, + 'path': { + 'name': _('Path'), + 'type': 'string', + 'map_to': 'fullpath', + 'default': '/', + }, }) # Define any kwargs we're using diff --git a/test/test_rest_plugins.py b/test/test_rest_plugins.py index f528b35a..5d38e622 100644 --- a/test/test_rest_plugins.py +++ b/test/test_rest_plugins.py @@ -803,6 +803,20 @@ TEST_URLS = ( # Our expected url(privacy=True) startswith() response: 'privacy_url': 'gotify://hostname/t...t', }), + # Provide a hostname, path, and token + ('gotify://hostname/a/path/ending/in/a/slash/%s' % ('u' * 16), { + 'instance': plugins.NotifyGotify, + + # Our expected url(privacy=True) startswith() response: + 'privacy_url': 'gotify://hostname/a/path/ending/in/a/slash/u...u/', + }), + # Provide a hostname, path, and token + ('gotify://hostname/a/path/not/ending/in/a/slash/%s' % ('v' * 16), { + 'instance': plugins.NotifyGotify, + + # Our expected url(privacy=True) startswith() response: + 'privacy_url': 'gotify://hostname/a/path/not/ending/in/a/slash/v...v/', + }), # Provide a priority ('gotify://hostname/%s?priority=high' % ('i' * 16), { 'instance': plugins.NotifyGotify,