mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	webhooks: Remove TrelloWebhookException classes.
This removes zerver/webhooks/trello/view/exceptions.py, which contained legacy Trello webhook exception related classes. We replace them with UnexpectedWebhookEventType, which results in our standard exception handling for unknown event types running (avoiding too-high priority error logging). Fixes #13467.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							5526af32f3
						
					
				
				
					commit
					92817e147d
				
			@@ -12,7 +12,6 @@ from zerver.models import UserProfile
 | 
			
		||||
from .card_actions import SUPPORTED_CARD_ACTIONS, \
 | 
			
		||||
    IGNORED_CARD_ACTIONS, process_card_action
 | 
			
		||||
from .board_actions import SUPPORTED_BOARD_ACTIONS, process_board_action
 | 
			
		||||
from .exceptions import UnsupportedAction
 | 
			
		||||
 | 
			
		||||
@api_key_only_webhook_view('Trello')
 | 
			
		||||
@return_success_on_head_request
 | 
			
		||||
@@ -28,7 +27,7 @@ def api_trello_webhook(request: HttpRequest,
 | 
			
		||||
            return json_success()
 | 
			
		||||
        else:
 | 
			
		||||
            subject, body = message
 | 
			
		||||
    except UnsupportedAction:
 | 
			
		||||
    except UnexpectedWebhookEventType:
 | 
			
		||||
        if action_type in IGNORED_CARD_ACTIONS:
 | 
			
		||||
            return json_success()
 | 
			
		||||
 | 
			
		||||
@@ -43,4 +42,4 @@ def get_subject_and_body(payload: Mapping[str, Any], action_type: str) -> Option
 | 
			
		||||
    if action_type in SUPPORTED_BOARD_ACTIONS:
 | 
			
		||||
        return process_board_action(payload, action_type)
 | 
			
		||||
 | 
			
		||||
    raise UnsupportedAction('{} is not supported'.format(action_type))
 | 
			
		||||
    raise UnexpectedWebhookEventType("Trello", '{} is not supported'.format(action_type))
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
from typing import Any, Dict, Mapping, Optional, Tuple
 | 
			
		||||
 | 
			
		||||
from .exceptions import UnknownUpdateBoardAction
 | 
			
		||||
from zerver.lib.exceptions import UnexpectedWebhookEventType
 | 
			
		||||
 | 
			
		||||
SUPPORTED_BOARD_ACTIONS = [
 | 
			
		||||
    u'removeMemberFromBoard',
 | 
			
		||||
@@ -39,7 +39,7 @@ def get_proper_action(payload: Mapping[str, Any], action_type: Optional[str]) ->
 | 
			
		||||
            return None
 | 
			
		||||
        elif data['old']['name']:
 | 
			
		||||
            return CHANGE_NAME
 | 
			
		||||
        raise UnknownUpdateBoardAction()
 | 
			
		||||
        raise UnexpectedWebhookEventType("Trello", action_type)
 | 
			
		||||
    return action_type
 | 
			
		||||
 | 
			
		||||
def get_subject(payload: Mapping[str, Any]) -> str:
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
from typing import Any, Dict, Mapping, Optional, Tuple
 | 
			
		||||
 | 
			
		||||
from .exceptions import UnknownUpdateCardAction
 | 
			
		||||
from zerver.lib.exceptions import UnexpectedWebhookEventType
 | 
			
		||||
 | 
			
		||||
SUPPORTED_CARD_ACTIONS = [
 | 
			
		||||
    u'updateCard',
 | 
			
		||||
@@ -104,7 +104,7 @@ def get_proper_action(payload: Mapping[str, Any], action_type: str) -> Optional[
 | 
			
		||||
        # within a single list
 | 
			
		||||
        if old_data.get('pos'):
 | 
			
		||||
            return None
 | 
			
		||||
        raise UnknownUpdateCardAction()
 | 
			
		||||
        raise UnexpectedWebhookEventType("Trello", action_type)
 | 
			
		||||
 | 
			
		||||
    return action_type
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
class TrelloWebhookException(Exception):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
class UnsupportedAction(TrelloWebhookException):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
class UnknownUpdateCardAction(TrelloWebhookException):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
class UnknownUpdateBoardAction(TrelloWebhookException):
 | 
			
		||||
    pass
 | 
			
		||||
		Reference in New Issue
	
	Block a user