Honor deprecation notices by removing them and accompanied code (#283)

This commit is contained in:
Chris Caron 2020-08-28 16:49:09 -04:00 committed by GitHub
parent 6dfd429b25
commit 66d285a57e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 154 deletions

View File

@ -469,20 +469,9 @@ class NotifyDiscord(NotifyBase):
# Update Avatar Icon # Update Avatar Icon
results['avatar'] = parse_bool(results['qsd'].get('avatar', True)) results['avatar'] = parse_bool(results['qsd'].get('avatar', True))
# Use Thumbnail # Boolean to include an image or not
if 'thumbnail' in results['qsd']: results['include_image'] = parse_bool(results['qsd'].get(
# Deprication Notice issued for v0.7.5 'image', NotifyDiscord.template_args['image']['default']))
NotifyDiscord.logger.deprecate(
'The Discord URL contains the parameter '
'"thumbnail=" which will be deprecated in an upcoming '
'release. Please use "image=" instead.'
)
# use image= for consistency with the other plugins but we also
# support thumbnail= for backwards compatibility.
results['include_image'] = \
parse_bool(results['qsd'].get(
'image', results['qsd'].get('thumbnail', False)))
# Extract avatar url if it was specified # Extract avatar url if it was specified
if 'avatar_url' in results['qsd']: if 'avatar_url' in results['qsd']:

View File

@ -1069,34 +1069,12 @@ class NotifyMatrix(NotifyBase):
if 'to' in results['qsd'] and len(results['qsd']['to']): if 'to' in results['qsd'] and len(results['qsd']['to']):
results['targets'] += NotifyMatrix.parse_list(results['qsd']['to']) results['targets'] += NotifyMatrix.parse_list(results['qsd']['to'])
# Thumbnail (old way) # Boolean to include an image or not
if 'thumbnail' in results['qsd']: results['include_image'] = parse_bool(results['qsd'].get(
# Deprication Notice issued for v0.7.5 'image', NotifyMatrix.template_args['image']['default']))
NotifyMatrix.logger.deprecate(
'The Matrix URL contains the parameter '
'"thumbnail=" which will be deprecated in an upcoming '
'release. Please use "image=" instead.'
)
# use image= for consistency with the other plugins but we also # Get our mode
# support thumbnail= for backwards compatibility. results['mode'] = results['qsd'].get('mode')
results['include_image'] = \
parse_bool(results['qsd'].get(
'image', results['qsd'].get('thumbnail', False)))
# Webhook (old way)
if 'webhook' in results['qsd']:
# Deprication Notice issued for v0.7.5
NotifyMatrix.logger.deprecate(
'The Matrix URL contains the parameter '
'"webhook=" which will be deprecated in an upcoming '
'release. Please use "mode=" instead.'
)
# use mode= for consistency with the other plugins but we also
# support webhook= for backwards compatibility.
results['mode'] = results['qsd'].get(
'mode', results['qsd'].get('webhook'))
# t2bot detection... look for just a hostname, and/or just a user/host # t2bot detection... look for just a hostname, and/or just a user/host
# if we match this; we can go ahead and set the mode (but only if # if we match this; we can go ahead and set the mode (but only if

View File

@ -60,10 +60,6 @@ class NotifyPushjet(NotifyBase):
'{schema}://{host}/{secret_key}', '{schema}://{host}/{secret_key}',
'{schema}://{user}:{password}@{host}:{port}/{secret_key}', '{schema}://{user}:{password}@{host}:{port}/{secret_key}',
'{schema}://{user}:{password}@{host}/{secret_key}', '{schema}://{user}:{password}@{host}/{secret_key}',
# Kept for backwards compatibility; will be depricated eventually
'{schema}://{secret_key}@{host}',
'{schema}://{secret_key}@{host}:{port}',
) )
# Define our tokens # Define our tokens
@ -244,13 +240,6 @@ class NotifyPushjet(NotifyBase):
pjets://hostname:port/secret_key pjets://hostname:port/secret_key
pjets://user:pass@hostname/secret_key pjets://user:pass@hostname/secret_key
pjets://user:pass@hostname:port/secret_key pjets://user:pass@hostname:port/secret_key
Legacy (Depricated) Syntax:
pjet://secret_key@hostname
pjet://secret_key@hostname:port
pjets://secret_key@hostname
pjets://secret_key@hostname:port
""" """
results = NotifyBase.parse_url(url) results = NotifyBase.parse_url(url)
if not results: if not results:
@ -273,22 +262,4 @@ class NotifyPushjet(NotifyBase):
results['secret_key'] = \ results['secret_key'] = \
NotifyPushjet.unquote(results['qsd']['secret']) NotifyPushjet.unquote(results['qsd']['secret'])
if results.get('secret_key') is None:
# Deprication Notice issued for v0.7.9
NotifyPushjet.logger.deprecate(
'The Pushjet URL contains secret_key in the user field'
' which will be deprecated in an upcoming '
'release. Please place this in the path of the URL instead.'
)
# Store it as it's value based on the user field
results['secret_key'] = \
NotifyPushjet.unquote(results.get('user'))
# there is no way http-auth is enabled, be sure to unset the
# current defined user (if present). This is done due to some
# logic that takes place in the send() since we support http-auth.
results['user'] = None
results['password'] = None
return results return results

View File

@ -323,19 +323,8 @@ class NotifyRyver(NotifyBase):
# no token # no token
results['token'] = None results['token'] = None
if 'webhook' in results['qsd']: # Retrieve the mode
# Deprication Notice issued for v0.7.5 results['mode'] = results['qsd'].get('mode', RyverWebhookMode.RYVER)
NotifyRyver.logger.deprecate(
'The Ryver URL contains the parameter '
'"webhook=" which will be deprecated in an upcoming '
'release. Please use "mode=" instead.'
)
# use mode= for consistency with the other plugins but we also
# support webhook= for backwards compatibility.
results['mode'] = results['qsd'].get(
'mode', results['qsd'].get(
'webhook', RyverWebhookMode.RYVER))
# use image= for consistency with the other plugins # use image= for consistency with the other plugins
results['include_image'] = \ results['include_image'] = \

View File

@ -73,9 +73,8 @@ class NotifyTwitter(NotifyBase):
# The services URL # The services URL
service_url = 'https://twitter.com/' service_url = 'https://twitter.com/'
# The default secure protocol is twitter. 'tweet' is left behind # The default secure protocol is twitter.
# for backwards compatibility of older apprise usage secure_protocol = 'twitter'
secure_protocol = ('twitter', 'tweet')
# A URL that takes you to the setup/help of the specific protocol # A URL that takes you to the setup/help of the specific protocol
setup_url = 'https://github.com/caronc/apprise/wiki/Notify_twitter' setup_url = 'https://github.com/caronc/apprise/wiki/Notify_twitter'
@ -593,7 +592,7 @@ class NotifyTwitter(NotifyBase):
return '{schema}://{ckey}/{csecret}/{akey}/{asecret}' \ return '{schema}://{ckey}/{csecret}/{akey}/{asecret}' \
'/{targets}/?{params}'.format( '/{targets}/?{params}'.format(
schema=self.secure_protocol[0], schema=self.secure_protocol,
ckey=self.pprint(self.ckey, privacy, safe=''), ckey=self.pprint(self.ckey, privacy, safe=''),
csecret=self.pprint( csecret=self.pprint(
self.csecret, privacy, mode=PrivacyMode.Secret, safe=''), self.csecret, privacy, mode=PrivacyMode.Secret, safe=''),
@ -663,9 +662,4 @@ class NotifyTwitter(NotifyBase):
results['targets'] += \ results['targets'] += \
NotifyTwitter.parse_list(results['qsd']['to']) NotifyTwitter.parse_list(results['qsd']['to'])
if results.get('schema', 'twitter').lower() == 'tweet':
# Deprication Notice issued for v0.7.9
NotifyTwitter.logger.deprecate(
'tweet:// has been replaced by twitter://')
return results return results

View File

@ -281,25 +281,7 @@ TEST_URLS = (
'instance': plugins.NotifyDiscord, 'instance': plugins.NotifyDiscord,
'requests_response_code': requests.codes.no_content, 'requests_response_code': requests.codes.no_content,
}), }),
# test image= field
# Enable other options
# DEPRICATED reference to Thumbnail
('discord://%s/%s?format=markdown&footer=Yes&thumbnail=Yes' % (
'i' * 24, 't' * 64), {
'instance': plugins.NotifyDiscord,
'requests_response_code': requests.codes.no_content,
# Our expected url(privacy=True) startswith() response:
'privacy_url': 'discord://i...i/t...t/',
}),
('discord://%s/%s?format=markdown&footer=Yes&thumbnail=No' % (
'i' * 24, 't' * 64), {
'instance': plugins.NotifyDiscord,
'requests_response_code': requests.codes.no_content,
}),
# thumbnail= is depricated and image= is the proper entry
('discord://%s/%s?format=markdown&footer=Yes&image=Yes' % ( ('discord://%s/%s?format=markdown&footer=Yes&image=Yes' % (
'i' * 24, 't' * 64), { 'i' * 24, 't' * 64), {
'instance': plugins.NotifyDiscord, 'instance': plugins.NotifyDiscord,
@ -311,8 +293,11 @@ TEST_URLS = (
'i' * 24, 't' * 64), { 'i' * 24, 't' * 64), {
'instance': plugins.NotifyDiscord, 'instance': plugins.NotifyDiscord,
'requests_response_code': requests.codes.no_content, 'requests_response_code': requests.codes.no_content,
# don't include an image by default }),
'include_image': True, ('discord://%s/%s?format=markdown&footer=Yes&image=Yes' % (
'i' * 24, 't' * 64), {
'instance': plugins.NotifyDiscord,
'requests_response_code': requests.codes.no_content,
}), }),
('https://discord.com/api/webhooks/{}/{}'.format( ('https://discord.com/api/webhooks/{}/{}'.format(
'0' * 10, 'B' * 40), { '0' * 10, 'B' * 40), {
@ -1549,20 +1534,6 @@ TEST_URLS = (
# user and token correctly specified with webhook # user and token correctly specified with webhook
'instance': plugins.NotifyMatrix, 'instance': plugins.NotifyMatrix,
}), }),
# Legacy (depricated) webhook reference
('matrix://user:token@localhost?webhook=matrix&format=text', {
# user and token correctly specified with webhook
'instance': plugins.NotifyMatrix,
'response': False,
}),
('matrix://user:token@localhost?webhook=matrix&format=html', {
# user and token correctly specified with webhook
'instance': plugins.NotifyMatrix,
}),
('matrix://user:token@localhost?webhook=slack&format=text', {
# user and token correctly specified with webhook
'instance': plugins.NotifyMatrix,
}),
('matrixs://user:token@localhost?mode=SLACK&format=markdown', { ('matrixs://user:token@localhost?mode=SLACK&format=markdown', {
# user and token specified; slack webhook still detected # user and token specified; slack webhook still detected
# despite uppercase characters # despite uppercase characters
@ -1598,15 +1569,6 @@ TEST_URLS = (
# user and token specified; image set to True # user and token specified; image set to True
'instance': plugins.NotifyMatrix, 'instance': plugins.NotifyMatrix,
}), }),
# Legacy (Depricated) image reference
('matrixs://user:token@localhost?mode=slack&thumbnail=False', {
# user and token specified; image set to True
'instance': plugins.NotifyMatrix,
}),
('matrixs://user:token@localhost?mode=slack&thumbnail=True', {
# user and token specified; image set to True
'instance': plugins.NotifyMatrix,
}),
('matrix://user:token@localhost?mode=On', { ('matrix://user:token@localhost?mode=On', {
# invalid webhook specified (unexpected boolean) # invalid webhook specified (unexpected boolean)
'instance': TypeError, 'instance': TypeError,
@ -2767,10 +2729,6 @@ TEST_URLS = (
('pjet://%s' % ('a' * 32), { ('pjet://%s' % ('a' * 32), {
'instance': TypeError, 'instance': TypeError,
}), }),
# Legacy method of logging in (soon to be depricated)
('pjet://%s@localhost' % ('a' * 32), {
'instance': plugins.NotifyPushjet,
}),
# The proper way to log in # The proper way to log in
('pjet://user:pass@localhost/%s' % ('a' * 32), { ('pjet://user:pass@localhost/%s' % ('a' * 32), {
'instance': plugins.NotifyPushjet, 'instance': plugins.NotifyPushjet,
@ -2786,12 +2744,6 @@ TEST_URLS = (
# Our expected url(privacy=True) startswith() response: # Our expected url(privacy=True) startswith() response:
'privacy_url': 'pjet://user:****@localhost', 'privacy_url': 'pjet://user:****@localhost',
}), }),
# Specify your own server with login (no secret = fail normally)
# however this will work since we're providing depricated support
# at this time so the 'user' get's picked up as being the secret_key
('pjet://user:pass@localhost', {
'instance': plugins.NotifyPushjet,
}),
# Specify your own server with port # Specify your own server with port
('pjets://localhost:8080/%s' % ('a' * 32), { ('pjets://localhost:8080/%s' % ('a' * 32), {
'instance': plugins.NotifyPushjet, 'instance': plugins.NotifyPushjet,
@ -3133,8 +3085,8 @@ TEST_URLS = (
# Just org provided (no token) # Just org provided (no token)
'instance': TypeError, 'instance': TypeError,
}), }),
('ryver://apprise/ckhrjW8w672m6HG?webhook=invalid', { ('ryver://apprise/ckhrjW8w672m6HG?mode=invalid', {
# Invalid webhook provided # invalid mode provided
'instance': TypeError, 'instance': TypeError,
}), }),
('ryver://x/ckhrjW8w672m6HG?mode=slack', { ('ryver://x/ckhrjW8w672m6HG?mode=slack', {
@ -4092,12 +4044,6 @@ TEST_URLS = (
# A Public Tweet # A Public Tweet
'instance': plugins.NotifyTwitter, 'instance': plugins.NotifyTwitter,
}), }),
('tweet://consumer_key/consumer_secret/access_token/access_secret', {
# tweet:// is to be depricated; but we will support for purposes of
# generating a warning to the user; the above matches an above
# twitter:// reference so that it can use what was cached
'instance': plugins.NotifyTwitter,
}),
('twitter://user@ckey/csecret/access_token/access_secret?mode=invalid', { ('twitter://user@ckey/csecret/access_token/access_secret?mode=invalid', {
# An invalid mode # An invalid mode
'instance': TypeError, 'instance': TypeError,

View File

@ -28,6 +28,7 @@ import pytest
import mock import mock
import requests import requests
from json import dumps from json import dumps
from apprise import Apprise
from apprise import AppriseAttachment from apprise import AppriseAttachment
from apprise import AppriseAsset from apprise import AppriseAsset
from apprise import NotifyType from apprise import NotifyType
@ -279,3 +280,10 @@ def test_notify_telegram_plugin(mock_post, mock_get):
assert len(obj.targets) == 0 assert len(obj.targets) == 0
assert obj.notify(title='hello', body='world') is False assert obj.notify(title='hello', body='world') is False
assert len(obj.targets) == 0 assert len(obj.targets) == 0
# Test Telegram Group
obj = Apprise.instantiate(
'tgram://123456789:ABCdefghijkl123456789opqyz/-123456789525')
assert isinstance(obj, plugins.NotifyTelegram)
assert len(obj.targets) == 1
assert '-123456789525' in obj.targets