mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
webhooks/clubhouse: Extract story labels from references.
It looks like Clubhouse has moved where they store the label name from the "actions" list to the "references" list.
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"id":"5b295c2c-f734-4a1a-a3a5-03c2594ef2d8",
|
"id":"5c37d3a3-6e3d-4b17-963c-adfa0a023d84",
|
||||||
"changed_at":"2018-06-19T19:40:28.185Z",
|
"changed_at":"2019-01-10T23:22:11.694Z",
|
||||||
"primary_id":11,
|
"primary_id":23,
|
||||||
"version":"v1",
|
"version":"v1",
|
||||||
"member_id":"5b1fda16-626f-487f-9ecf-f3a4abf42b8b",
|
"member_id":"5b1fda16-626f-487f-9ecf-f3a4abf42b8b",
|
||||||
"actions":[
|
"actions":[
|
||||||
{
|
{
|
||||||
"id":11,
|
"id":23,
|
||||||
"entity_type":"story",
|
"entity_type":"story",
|
||||||
"action":"update",
|
"action":"update",
|
||||||
"name":"Add cool feature!",
|
"name":"An epic story!",
|
||||||
"story_type":"bug",
|
"story_type":"feature",
|
||||||
"app_url":"https://app.clubhouse.io/zulip/story/11",
|
"app_url":"https://app.clubhouse.io/zulip/story/23",
|
||||||
"changes":{
|
"changes":{
|
||||||
"label_ids":{
|
"label_ids":{
|
||||||
"adds":[
|
"adds":[
|
||||||
@@ -19,11 +19,12 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
],
|
||||||
|
"references":[
|
||||||
{
|
{
|
||||||
"id":18,
|
"id":18,
|
||||||
"entity_type":"label",
|
"entity_type":"label",
|
||||||
"action":"create",
|
|
||||||
"name":"mockup"
|
"name":"mockup"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"id":"5b295cc0-242a-4ecf-b75c-e2467c25513c",
|
"id":"5c37d3f8-4a7e-4cdd-a066-7ced3ace1bd7",
|
||||||
"changed_at":"2018-06-19T19:42:56.825Z",
|
"changed_at":"2019-01-10T23:23:36.331Z",
|
||||||
"primary_id":11,
|
"primary_id":23,
|
||||||
"version":"v1",
|
"version":"v1",
|
||||||
"member_id":"5b1fda16-626f-487f-9ecf-f3a4abf42b8b",
|
"member_id":"5b1fda16-626f-487f-9ecf-f3a4abf42b8b",
|
||||||
"actions":[
|
"actions":[
|
||||||
{
|
{
|
||||||
"id":11,
|
"id":23,
|
||||||
"entity_type":"story",
|
"entity_type":"story",
|
||||||
"action":"update",
|
"action":"update",
|
||||||
"name":"Add cool feature!",
|
"name":"An epic story!",
|
||||||
"story_type":"bug",
|
"story_type":"feature",
|
||||||
"app_url":"https://app.clubhouse.io/zulip/story/11",
|
"app_url":"https://app.clubhouse.io/zulip/story/23",
|
||||||
"changes":{
|
"changes":{
|
||||||
"label_ids":{
|
"label_ids":{
|
||||||
"removes":[
|
"removes":[
|
||||||
|
|||||||
@@ -178,8 +178,8 @@ class ClubhouseWebhookTest(WebhookTestCase):
|
|||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
|
||||||
def test_story_label_added(self) -> None:
|
def test_story_label_added(self) -> None:
|
||||||
expected_message = u"The label **mockup** was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)."
|
expected_message = u"The label **mockup** was added to the story [An epic story!](https://app.clubhouse.io/zulip/story/23)."
|
||||||
self.send_and_test_stream_message('story_update_add_label', "Add cool feature!",
|
self.send_and_test_stream_message('story_update_add_label', "An epic story!",
|
||||||
expected_message)
|
expected_message)
|
||||||
|
|
||||||
@patch('zerver.lib.webhooks.common.check_send_webhook_message')
|
@patch('zerver.lib.webhooks.common.check_send_webhook_message')
|
||||||
|
|||||||
@@ -352,9 +352,9 @@ def get_story_label_body(payload: Dict[str, Any]) -> Optional[str]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
label_id = label_ids_added[0]
|
label_id = label_ids_added[0]
|
||||||
for action in payload["actions"]:
|
for reference in payload["references"]:
|
||||||
if action["id"] == label_id:
|
if reference["id"] == label_id:
|
||||||
kwargs.update({"label_name": action["name"]})
|
kwargs.update({"label_name": reference["name"]})
|
||||||
|
|
||||||
return STORY_LABEL_TEMPLATE.format(**kwargs)
|
return STORY_LABEL_TEMPLATE.format(**kwargs)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user