mirror of https://github.com/caronc/apprise
				
				
				
			Zulip syntax improvements (support token=)
							parent
							
								
									fc7d06751c
								
							
						
					
					
						commit
						f461b68d86
					
				| 
						 | 
				
			
			@ -163,6 +163,9 @@ class NotifyZulip(NotifyBase):
 | 
			
		|||
        'to': {
 | 
			
		||||
            'alias_of': 'targets',
 | 
			
		||||
        },
 | 
			
		||||
        'token': {
 | 
			
		||||
            'alias_of': 'token',
 | 
			
		||||
        },
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    # The default hostname to append to a defined organization
 | 
			
		||||
| 
						 | 
				
			
			@ -377,21 +380,24 @@ class NotifyZulip(NotifyBase):
 | 
			
		|||
        # The botname
 | 
			
		||||
        results['botname'] = NotifyZulip.unquote(results['user'])
 | 
			
		||||
 | 
			
		||||
        # The first token is stored in the hostname
 | 
			
		||||
        # The organization is stored in the hostname
 | 
			
		||||
        results['organization'] = NotifyZulip.unquote(results['host'])
 | 
			
		||||
 | 
			
		||||
        # Now fetch the remaining tokens
 | 
			
		||||
        try:
 | 
			
		||||
            results['token'] = \
 | 
			
		||||
                NotifyZulip.split_path(results['fullpath'])[0]
 | 
			
		||||
        # Store our targets
 | 
			
		||||
        results['targets'] = NotifyZulip.split_path(results['fullpath'])
 | 
			
		||||
 | 
			
		||||
        except IndexError:
 | 
			
		||||
        if 'token' in results['qsd'] and len(results['qsd']['token']):
 | 
			
		||||
            # Store our token if specified
 | 
			
		||||
            results['token'] = NotifyZulip.unquote(results['qsd']['token'])
 | 
			
		||||
 | 
			
		||||
        elif results['targets']:
 | 
			
		||||
            # First item is the token
 | 
			
		||||
            results['token'] = results['targets'].pop(0)
 | 
			
		||||
 | 
			
		||||
        else:
 | 
			
		||||
            # no token
 | 
			
		||||
            results['token'] = None
 | 
			
		||||
 | 
			
		||||
        # Get unquoted entries
 | 
			
		||||
        results['targets'] = NotifyZulip.split_path(results['fullpath'])[1:]
 | 
			
		||||
 | 
			
		||||
        # Support the 'to' variable so that we can support rooms this way too
 | 
			
		||||
        # The 'to' makes it easier to use yaml configuration
 | 
			
		||||
        if 'to' in results['qsd'] and len(results['qsd']['to']):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,6 +84,10 @@ apprise_url_tests = (
 | 
			
		|||
    ('zulip://botname@apprise/{}/?to=channel1/channel2'.format('a' * 32), {
 | 
			
		||||
        'instance': NotifyZulip,
 | 
			
		||||
    }),
 | 
			
		||||
    # Test token=
 | 
			
		||||
    ('zulip://botname@apprise/?token={}&to=channel1'.format('a' * 32), {
 | 
			
		||||
        'instance': NotifyZulip,
 | 
			
		||||
    }),
 | 
			
		||||
    # Valid everything - 2 emails specified
 | 
			
		||||
    ('zulip://botname@apprise/{}/user@example.com/user2@example.com'.format(
 | 
			
		||||
        'a' * 32), {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue