mirror of https://github.com/zulip/zulip.git
webhooks/clubhouse: Support story/epic deletion.
This commit is contained in:
parent
d813d29290
commit
dedf56bf31
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"id":"5c1824b6-99eb-456b-a557-9fa9a56cedb0",
|
||||||
|
"changed_at":"2018-12-17T22:35:34.744Z",
|
||||||
|
"primary_id":17,
|
||||||
|
"version":"v1",
|
||||||
|
"member_id":"5b1fda16-626f-487f-9ecf-f3a4abf42b8b",
|
||||||
|
"actions":[
|
||||||
|
{
|
||||||
|
"id":17,
|
||||||
|
"entity_type":"epic",
|
||||||
|
"action":"delete",
|
||||||
|
"name":"Clubhouse Fork"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"id":"5c182454-1f6d-4c08-8d41-dfa5409386a2",
|
||||||
|
"changed_at":"2018-12-17T22:33:56.768Z",
|
||||||
|
"primary_id":25,
|
||||||
|
"version":"v1",
|
||||||
|
"member_id":"5b1fda16-626f-487f-9ecf-f3a4abf42b8b",
|
||||||
|
"actions":[
|
||||||
|
{
|
||||||
|
"id":25,
|
||||||
|
"entity_type":"story",
|
||||||
|
"action":"delete",
|
||||||
|
"story_type":"feature",
|
||||||
|
"name":"New random story"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -14,6 +14,11 @@ class ClubhouseWebhookTest(WebhookTestCase):
|
||||||
expected_message
|
expected_message
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_story_delete(self) -> None:
|
||||||
|
expected_message = u"The story **New random story** was deleted."
|
||||||
|
self.send_and_test_stream_message("story_delete", "New random story",
|
||||||
|
expected_message)
|
||||||
|
|
||||||
def test_epic_story_create(self) -> None:
|
def test_epic_story_create(self) -> None:
|
||||||
expected_message = u"New story [An epic story!](https://app.clubhouse.io/zulip/story/23) was created and added to the epic **New Cool Epic!**."
|
expected_message = u"New story [An epic story!](https://app.clubhouse.io/zulip/story/23) was created and added to the epic **New Cool Epic!**."
|
||||||
self.send_and_test_stream_message(
|
self.send_and_test_stream_message(
|
||||||
|
@ -21,6 +26,11 @@ class ClubhouseWebhookTest(WebhookTestCase):
|
||||||
expected_message
|
expected_message
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_epic_delete(self) -> None:
|
||||||
|
expected_message = u"The epic **Clubhouse Fork** was deleted."
|
||||||
|
self.send_and_test_stream_message("epic_delete", "Clubhouse Fork",
|
||||||
|
expected_message)
|
||||||
|
|
||||||
def test_story_archive(self) -> None:
|
def test_story_archive(self) -> None:
|
||||||
expected_message = u"The story [Story 2](https://app.clubhouse.io/zulip/story/9) was archived."
|
expected_message = u"The story [Story 2](https://app.clubhouse.io/zulip/story/9) was archived."
|
||||||
self.send_and_test_stream_message('story_archive', "Story 2", expected_message)
|
self.send_and_test_stream_message('story_archive', "Story 2", expected_message)
|
||||||
|
|
|
@ -34,6 +34,7 @@ STORY_UPDATE_PROJECT_TEMPLATE = ("The story {name_template} was moved from"
|
||||||
" the **{old}** project to **{new}**.")
|
" the **{old}** project to **{new}**.")
|
||||||
STORY_UPDATE_TYPE_TEMPLATE = ("The type of the story {name_template} was changed"
|
STORY_UPDATE_TYPE_TEMPLATE = ("The type of the story {name_template} was changed"
|
||||||
" from **{old_type}** to **{new_type}**.")
|
" from **{old_type}** to **{new_type}**.")
|
||||||
|
DELETE_TEMPLATE = "The {entity_type} **{name}** was deleted."
|
||||||
|
|
||||||
|
|
||||||
def get_action_with_primary_id(payload: Dict[str, Any]) -> Dict[str, Any]:
|
def get_action_with_primary_id(payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
|
@ -80,6 +81,10 @@ def get_topic_function_based_on_type(payload: Dict[str, Any]) -> Any:
|
||||||
entity_type = get_action_with_primary_id(payload)["entity_type"]
|
entity_type = get_action_with_primary_id(payload)["entity_type"]
|
||||||
return EVENT_TOPIC_FUNCTION_MAPPER.get(entity_type)
|
return EVENT_TOPIC_FUNCTION_MAPPER.get(entity_type)
|
||||||
|
|
||||||
|
def get_delete_body(payload: Dict[str, Any]) -> str:
|
||||||
|
action = get_action_with_primary_id(payload)
|
||||||
|
return DELETE_TEMPLATE.format(**action)
|
||||||
|
|
||||||
def get_story_create_body(payload: Dict[str, Any]) -> str:
|
def get_story_create_body(payload: Dict[str, Any]) -> str:
|
||||||
action = get_action_with_primary_id(payload)
|
action = get_action_with_primary_id(payload)
|
||||||
|
|
||||||
|
@ -402,6 +407,8 @@ def get_name_template(entity: str) -> str:
|
||||||
EVENT_BODY_FUNCTION_MAPPER = {
|
EVENT_BODY_FUNCTION_MAPPER = {
|
||||||
"story_update_archived": get_story_update_archived_body,
|
"story_update_archived": get_story_update_archived_body,
|
||||||
"story_create": get_story_create_body,
|
"story_create": get_story_create_body,
|
||||||
|
"story_delete": get_delete_body,
|
||||||
|
"epic_delete": get_delete_body,
|
||||||
"story-task_create": partial(get_story_task_body, action="added to"),
|
"story-task_create": partial(get_story_task_body, action="added to"),
|
||||||
"story-task_delete": partial(get_story_task_body, action="removed from"),
|
"story-task_delete": partial(get_story_task_body, action="removed from"),
|
||||||
"story-task_update_complete": get_story_task_completed_body,
|
"story-task_update_complete": get_story_task_completed_body,
|
||||||
|
|
Loading…
Reference in New Issue