mirror of https://github.com/zulip/zulip.git
parent
dcb163bbe3
commit
2d6e6369f3
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
Binary file not shown.
After Width: | Height: | Size: 448 B |
|
@ -425,6 +425,7 @@ WEBHOOK_INTEGRATIONS: List[WebhookIntegration] = [
|
|||
WebhookIntegration("json", ["misc"], display_name="JSON formatter"),
|
||||
WebhookIntegration("librato", ["monitoring"]),
|
||||
WebhookIntegration("lidarr", ["entertainment"]),
|
||||
WebhookIntegration("linear", ["project-management"], display_name="Linear"),
|
||||
WebhookIntegration("mention", ["marketing"], display_name="Mention"),
|
||||
WebhookIntegration("netlify", ["continuous-integration", "deployment"], display_name="Netlify"),
|
||||
WebhookIntegration("newrelic", ["monitoring"], display_name="New Relic"),
|
||||
|
@ -774,6 +775,7 @@ DOC_SCREENSHOT_CONFIG: Dict[str, List[BaseScreenshotConfig]] = {
|
|||
"json": [ScreenshotConfig("json_github_push__1_commit.json")],
|
||||
"librato": [ScreenshotConfig("three_conditions_alert.json", payload_as_query_param=True)],
|
||||
"lidarr": [ScreenshotConfig("lidarr_tracks_grabbed.json")],
|
||||
"linear": [ScreenshotConfig("issue_create_complex.json")],
|
||||
"mention": [ScreenshotConfig("webfeeds.json")],
|
||||
"nagios": [BaseScreenshotConfig("service_notify.json")],
|
||||
"netlify": [ScreenshotConfig("deploy_building.json")],
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
Get Linear notifications in Zulip!
|
||||
|
||||
1. {!create-stream.md!}
|
||||
|
||||
1. {!create-bot-construct-url.md!}
|
||||
|
||||
You can refer to Linear's documentation for [webhook events](https://developers.linear.app/docs/graphql/webhooks).
|
||||
|
||||
1. Go to your team on Linear and open **Settings**, select **API**,
|
||||
and click on **New Webhook**.
|
||||
|
||||
1. Set **Webhook URL** to the URL constructed above. Select the data
|
||||
change events for which you would like to receive notifications
|
||||
for, and click **Create Webhook**.
|
||||
|
||||
{!congrats.md!}
|
||||
|
||||
![Linear Integration](/static/images/integrations/linear/001.png)
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"action": "create",
|
||||
"createdAt": "2023-04-11T10:21:34.858Z",
|
||||
"data": {
|
||||
"id": "c7cafc52-994d-4984-a217-bff9f9aa9473",
|
||||
"createdAt": "2023-04-11T10:21:34.858Z",
|
||||
"updatedAt": "2023-04-11T10:21:34.858Z",
|
||||
"body": "Performing a thorough impact analysis and cost realization is a crucial step in responding to any system outage or incident. By examining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident, we can gain a comprehensive understanding of the scope of the incident.\n\nThis information can then be used to prioritize the resolution efforts and minimize the impact on our organization's operations. Additionally, cost realization allows us to evaluate the financial impact of the outage on our organization and make informed decisions regarding resource allocation for future incidents.\n\nOverall, conducting a thorough impact analysis and cost realization can help us effectively manage incidents and prevent similar issues from occurring in the future.",
|
||||
"issueId": "f9a37fcf-eb52-44be-a52c-0477f70e9952",
|
||||
"userId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"reactionData": [],
|
||||
"issue": {
|
||||
"id": "f9a37fcf-eb52-44be-a52c-0477f70e9952",
|
||||
"title": "Thorough Impact Analysis and Cost Realization"
|
||||
},
|
||||
"user": {
|
||||
"id": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"name": "Satyam Bansal"
|
||||
}
|
||||
},
|
||||
"url": "https://linear.app/webhooks/issue/WEB-46#comment-c7cafc52",
|
||||
"type": "Comment",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681208494995
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"action": "remove",
|
||||
"createdAt": "2023-04-11T10:22:42.436Z",
|
||||
"data": {
|
||||
"id": "c7cafc52-994d-4984-a217-bff9f9aa9473",
|
||||
"createdAt": "2023-04-11T10:21:34.858Z",
|
||||
"updatedAt": "2023-04-11T10:22:24.895Z",
|
||||
"body": "In responding to any system outage or incident, it is essential to perform a comprehensive impact analysis and cost evaluation. By examining factors such as the extent of the outage, the affected systems or services, the number of users affected, and any error messages or logs generated during the incident, we can gain a detailed understanding of the incident's scope.\n\nThis information is then critical in prioritizing resolution efforts and reducing the impact on our organization's operations. Additionally, conducting cost realization allows us to assess the financial implications of the outage and make informed decisions about allocating resources for future incidents.\n\nOverall, performing a thorough impact analysis and cost realization is an effective way to manage incidents and prevent similar issues from recurring.",
|
||||
"issueId": "f9a37fcf-eb52-44be-a52c-0477f70e9952",
|
||||
"userId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"editedAt": "2023-04-11T10:22:24.895Z",
|
||||
"reactionData": [],
|
||||
"issue": {
|
||||
"id": "f9a37fcf-eb52-44be-a52c-0477f70e9952",
|
||||
"title": "Thorough Impact Analysis and Cost Realization"
|
||||
},
|
||||
"user": {
|
||||
"id": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"name": "Satyam Bansal"
|
||||
}
|
||||
},
|
||||
"type": "Comment",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681208562499
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"action": "update",
|
||||
"createdAt": "2023-04-11T10:22:24.895Z",
|
||||
"data": {
|
||||
"id": "c7cafc52-994d-4984-a217-bff9f9aa9473",
|
||||
"createdAt": "2023-04-11T10:21:34.858Z",
|
||||
"updatedAt": "2023-04-11T10:22:24.895Z",
|
||||
"body": "Invalid response to any system outage or incident, it is essential to perform a comprehensive impact analysis and cost evaluation. By examining factors such as the extent of the outage, the affected systems or services, the number of users affected, and any error messages or logs generated during the incident, we can gain a detailed understanding of the incident's scope.\n\nThis information is then critical in prioritizing resolution efforts and reducing the impact on our organization's operations. Additionally, conducting cost realization allows us to assess the financial implications of the outage and make informed decisions about allocating resources for future incidents.\n\nOverall, performing a thorough impact analysis and cost realization is an effective way to manage incidents and prevent similar issues from recurring.",
|
||||
"issueId": "f9a37fcf-eb52-44be-a52c-0477f70e9952",
|
||||
"userId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"editedAt": "2023-04-11T10:22:24.895Z",
|
||||
"reactionData": [],
|
||||
"issue": {
|
||||
"id": "f9a37fcf-eb52-44be-a52c-0477f70e9952",
|
||||
"title": "Thorough Impact Analysis and Cost Realization"
|
||||
},
|
||||
"user": {
|
||||
"id": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"name": "Satyam Bansal"
|
||||
}
|
||||
},
|
||||
"updatedFrom": {
|
||||
"updatedAt": "2023-04-11T10:21:34.858Z",
|
||||
"body": "Performing a thorough impact analysis and cost realization is a crucial step in responding to any system outage or incident. By examining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident, we can gain a comprehensive understanding of the scope of the incident.\n\nThis information can then be used to prioritize the resolution efforts and minimize the impact on our organization's operations. Additionally, cost realization allows us to evaluate the financial impact of the outage on our organization and make informed decisions regarding resource allocation for future incidents.\n\nOverall, conducting a thorough impact analysis and cost realization can help us effectively manage incidents and prevent similar issues from occurring in the future.",
|
||||
"editedAt": null
|
||||
},
|
||||
"url": "https://linear.app/webhooks/issue/WEB-46#comment-c7cafc52",
|
||||
"type": "Comment",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681208545073
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"action": "create",
|
||||
"createdAt": "2023-04-11T10:10:15.037Z",
|
||||
"data": {
|
||||
"id": "3443a709-f2b5-46f2-a136-a0445fd432be",
|
||||
"createdAt": "2023-04-11T10:10:15.037Z",
|
||||
"updatedAt": "2023-04-11T10:10:15.037Z",
|
||||
"number": 44,
|
||||
"title": "This is regarding the outage that we faced during 11/12/22 from 2000 to 2200.",
|
||||
"priority": 1,
|
||||
"boardOrder": 0,
|
||||
"sortOrder": -2036,
|
||||
"startedAt": "2023-04-11T10:10:15.093Z",
|
||||
"teamId": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"previousIdentifiers": [],
|
||||
"creatorId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"assigneeId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"stateId": "a2530cac-36a0-4b6d-9af0-6357784035d4",
|
||||
"priorityLabel": "Urgent",
|
||||
"subscriberIds": [
|
||||
"674c90c8-35ea-454d-8ca4-5548258fd795"
|
||||
],
|
||||
"labelIds": [
|
||||
"6e4da2ed-ee8b-4b19-9cf8-40e5603e04c1",
|
||||
"56111f1a-e733-49f2-856a-c42318bb8739",
|
||||
"196379c2-287d-436d-962c-b2c0ce8281a1",
|
||||
"926b0916-05e2-4e8b-a7c6-96bc2c763326"
|
||||
],
|
||||
"description": "The outage that occurred on the above-mentioned date is a cause for concern as it could have significant implications for the organization and its users. A prolonged outage can result in lost revenue, productivity, and customer confidence. Therefore, it is essential to conduct a detailed assessment and analysis to identify the root cause of the outage and take appropriate measures to prevent its recurrence.\n\nThe analysis process may involve the use of specialized tools and techniques to help pinpoint the exact cause of the outage. Once the root cause has been identified, the organization can take steps to implement effective solutions that can mitigate the risk of a similar outage happening in the future. The assessment and analysis process will help the organization to develop a more robust and reliable IT infrastructure that can provide uninterrupted services to its users.",
|
||||
"descriptionData": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"text\":\"The outage that occurred on the above-mentioned date is a cause for concern as it could have significant implications for the organization and its users. A prolonged outage can result in lost revenue, productivity, and customer confidence. Therefore, it is essential to conduct a detailed assessment and analysis to identify the root cause of the outage and take appropriate measures to prevent its recurrence.\",\"type\":\"text\"}]},{\"type\":\"paragraph\",\"content\":[{\"text\":\"The analysis process may involve the use of specialized tools and techniques to help pinpoint the exact cause of the outage. Once the root cause has been identified, the organization can take steps to implement effective solutions that can mitigate the risk of a similar outage happening in the future. The assessment and analysis process will help the organization to develop a more robust and reliable IT infrastructure that can provide uninterrupted services to its users.\",\"type\":\"text\"}]}]}",
|
||||
"assignee": {
|
||||
"id": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"name": "Satyam Bansal"
|
||||
},
|
||||
"state": {
|
||||
"id": "a2530cac-36a0-4b6d-9af0-6357784035d4",
|
||||
"color": "#f2c94c",
|
||||
"name": "In Progress",
|
||||
"type": "started"
|
||||
},
|
||||
"team": {
|
||||
"id": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"key": "WEB",
|
||||
"name": "Webhooks"
|
||||
},
|
||||
"labels": [
|
||||
{
|
||||
"id": "56111f1a-e733-49f2-856a-c42318bb8739",
|
||||
"color": "#4EA7FC",
|
||||
"name": "Improvement"
|
||||
},
|
||||
{
|
||||
"id": "196379c2-287d-436d-962c-b2c0ce8281a1",
|
||||
"color": "#BB87FC",
|
||||
"name": "Feature"
|
||||
},
|
||||
{
|
||||
"id": "6e4da2ed-ee8b-4b19-9cf8-40e5603e04c1",
|
||||
"color": "#EB5757",
|
||||
"name": "Bug"
|
||||
},
|
||||
{
|
||||
"id": "926b0916-05e2-4e8b-a7c6-96bc2c763326",
|
||||
"color": "#26b5ce",
|
||||
"name": "Custom Label"
|
||||
}
|
||||
]
|
||||
},
|
||||
"url": "https://linear.app/webhooks/issue/WEB-44/this-is-regarding-the-outage-that-we-faced-during-111222-from-2000-to",
|
||||
"type": "Issue",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681207816078
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"action": "create",
|
||||
"createdAt": "2023-04-11T09:59:47.094Z",
|
||||
"data": {
|
||||
"id": "a4344dc7-7d8d-4b28-a93c-553ac9aba41a",
|
||||
"createdAt": "2023-04-11T09:59:47.094Z",
|
||||
"updatedAt": "2023-04-11T09:59:47.094Z",
|
||||
"number": 43,
|
||||
"title": "Very small font in tooltip",
|
||||
"priority": 0,
|
||||
"boardOrder": 0,
|
||||
"sortOrder": -27663,
|
||||
"teamId": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"previousIdentifiers": [],
|
||||
"creatorId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"stateId": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"priorityLabel": "No priority",
|
||||
"subscriberIds": [
|
||||
"674c90c8-35ea-454d-8ca4-5548258fd795"
|
||||
],
|
||||
"labelIds": [],
|
||||
"description": "The tooltips at the \"Select Drawing\" and \"Edit Drawing\" buttons have a very small font and therefore are not very legible. Apart from this, the wording of the text has to be changed to fit better with the overall design pattern.",
|
||||
"descriptionData": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"text\":\"The tooltips at the \\\"Select Drawing\\\" and \\\"Edit Drawing\\\" buttons have a very small font and therefore are not very legible. Apart from this, the wording of the text has to be changed to fit better with the overall design pattern.\",\"type\":\"text\"}]}]}",
|
||||
"state": {
|
||||
"id": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"color": "#e2e2e2",
|
||||
"name": "Todo",
|
||||
"type": "unstarted"
|
||||
},
|
||||
"team": {
|
||||
"id": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"key": "WEB",
|
||||
"name": "Webhooks"
|
||||
},
|
||||
"labels": []
|
||||
},
|
||||
"url": "https://linear.app/webhooks/issue/WEB-43/very-small-font-in-tooltip",
|
||||
"type": "Issue",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681207187330
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"action": "create",
|
||||
"createdAt": "2023-04-11T09:47:53.218Z",
|
||||
"data": {
|
||||
"id": "21e12515-fe5e-4923-88a1-e9ace5056473",
|
||||
"createdAt": "2023-04-11T09:47:53.218Z",
|
||||
"updatedAt": "2023-04-11T09:47:53.218Z",
|
||||
"number": 42,
|
||||
"title": "Drop-down overflow in the select menu.",
|
||||
"priority": 2,
|
||||
"boardOrder": 0,
|
||||
"sortOrder": -26718,
|
||||
"teamId": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"previousIdentifiers": [],
|
||||
"creatorId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"stateId": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"priorityLabel": "High",
|
||||
"subscriberIds": [
|
||||
"674c90c8-35ea-454d-8ca4-5548258fd795"
|
||||
],
|
||||
"labelIds": [],
|
||||
"state": {
|
||||
"id": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"color": "#e2e2e2",
|
||||
"name": "Todo",
|
||||
"type": "unstarted"
|
||||
},
|
||||
"team": {
|
||||
"id": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"key": "WEB",
|
||||
"name": "Webhooks"
|
||||
},
|
||||
"labels": []
|
||||
},
|
||||
"url": "https://linear.app/webhooks/issue/WEB-42/drop-down-overflow-in-the-select-menu",
|
||||
"type": "Issue",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681206473447
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
"action": "remove",
|
||||
"createdAt": "2023-04-11T10:17:17.810Z",
|
||||
"data": {
|
||||
"id": "3443a709-f2b5-46f2-a136-a0445fd432be",
|
||||
"createdAt": "2023-04-11T10:10:15.037Z",
|
||||
"updatedAt": "2023-04-11T10:16:53.023Z",
|
||||
"archivedAt": "2023-04-11T10:17:17.810Z",
|
||||
"number": 44,
|
||||
"title": "This is regarding the outage that we faced on 11/12/22 from 2000 to 2200 and also on 25/12/22 from 0000 to 0230",
|
||||
"priority": 1,
|
||||
"boardOrder": 0,
|
||||
"sortOrder": -2036,
|
||||
"startedAt": "2023-04-11T10:10:15.093Z",
|
||||
"trashed": true,
|
||||
"teamId": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"cycleId": "eaef2755-de5b-4342-accb-79060378493f",
|
||||
"previousIdentifiers": [],
|
||||
"creatorId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"assigneeId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"stateId": "a2530cac-36a0-4b6d-9af0-6357784035d4",
|
||||
"priorityLabel": "Urgent",
|
||||
"subscriberIds": [
|
||||
"674c90c8-35ea-454d-8ca4-5548258fd795"
|
||||
],
|
||||
"labelIds": [
|
||||
"6e4da2ed-ee8b-4b19-9cf8-40e5603e04c1",
|
||||
"56111f1a-e733-49f2-856a-c42318bb8739",
|
||||
"196379c2-287d-436d-962c-b2c0ce8281a1",
|
||||
"926b0916-05e2-4e8b-a7c6-96bc2c763326"
|
||||
],
|
||||
"description": "The outage that occurred on the above-mentioned date is a cause for concern as it could have significant implications for the organization and its users. A prolonged outage can result in lost revenue, productivity, and customer confidence. Therefore, it is essential to conduct a detailed assessment and analysis to identify the root cause of the outage and take appropriate measures to prevent its recurrence.\n\nThe analysis process may involve the use of specialized tools and techniques to help pinpoint the exact cause of the outage. Once the root cause has been identified, the organization can take steps to implement effective solutions that can mitigate the risk of a similar outage happening in the future. The assessment and analysis process will help the organization to develop a more robust and reliable IT infrastructure that can provide uninterrupted services to its users.",
|
||||
"descriptionData": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"text\":\"The outage that occurred on the above-mentioned date is a cause for concern as it could have significant implications for the organization and its users. A prolonged outage can result in lost revenue, productivity, and customer confidence. Therefore, it is essential to conduct a detailed assessment and analysis to identify the root cause of the outage and take appropriate measures to prevent its recurrence.\",\"type\":\"text\"}]},{\"type\":\"paragraph\",\"content\":[{\"text\":\"The analysis process may involve the use of specialized tools and techniques to help pinpoint the exact cause of the outage. Once the root cause has been identified, the organization can take steps to implement effective solutions that can mitigate the risk of a similar outage happening in the future. The assessment and analysis process will help the organization to develop a more robust and reliable IT infrastructure that can provide uninterrupted services to its users.\",\"type\":\"text\"}]}]}",
|
||||
"assignee": {
|
||||
"id": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"name": "Satyam Bansal"
|
||||
},
|
||||
"cycle": {
|
||||
"id": "eaef2755-de5b-4342-accb-79060378493f",
|
||||
"number": 1,
|
||||
"startsAt": "2023-04-05T18:30:00.000Z",
|
||||
"endsAt": "2023-04-12T18:30:00.000Z"
|
||||
},
|
||||
"state": {
|
||||
"id": "a2530cac-36a0-4b6d-9af0-6357784035d4",
|
||||
"color": "#f2c94c",
|
||||
"name": "In Progress",
|
||||
"type": "started"
|
||||
},
|
||||
"team": {
|
||||
"id": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"key": "WEB",
|
||||
"name": "Webhooks"
|
||||
},
|
||||
"labels": [
|
||||
{
|
||||
"id": "56111f1a-e733-49f2-856a-c42318bb8739",
|
||||
"color": "#4EA7FC",
|
||||
"name": "Improvement"
|
||||
},
|
||||
{
|
||||
"id": "196379c2-287d-436d-962c-b2c0ce8281a1",
|
||||
"color": "#BB87FC",
|
||||
"name": "Feature"
|
||||
},
|
||||
{
|
||||
"id": "6e4da2ed-ee8b-4b19-9cf8-40e5603e04c1",
|
||||
"color": "#EB5757",
|
||||
"name": "Bug"
|
||||
},
|
||||
{
|
||||
"id": "926b0916-05e2-4e8b-a7c6-96bc2c763326",
|
||||
"color": "#26b5ce",
|
||||
"name": "Custom Label"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "Issue",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681208237985
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"action": "create",
|
||||
"createdAt": "2023-04-11T10:10:15.037Z",
|
||||
"data": {
|
||||
"id": "f9a37fcf-eb52-44be-a52c-0477f70e9952",
|
||||
"createdAt": "2023-04-11T10:10:15.037Z",
|
||||
"updatedAt": "2023-04-11T10:10:15.037Z",
|
||||
"number": 46,
|
||||
"title": "Impact Analysis",
|
||||
"priority": 0,
|
||||
"boardOrder": 0,
|
||||
"sortOrder": -29786,
|
||||
"teamId": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"previousIdentifiers": [],
|
||||
"creatorId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"stateId": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"parentId": "3443a709-f2b5-46f2-a136-a0445fd432be",
|
||||
"subIssueSortOrder": 1102,
|
||||
"priorityLabel": "No priority",
|
||||
"subscriberIds": [
|
||||
"674c90c8-35ea-454d-8ca4-5548258fd795"
|
||||
],
|
||||
"labelIds": [],
|
||||
"description": "Examining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident.",
|
||||
"descriptionData": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"text\":\"Examining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident.\",\"type\":\"text\"}]}]}",
|
||||
"state": {
|
||||
"id": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"color": "#e2e2e2",
|
||||
"name": "Todo",
|
||||
"type": "unstarted"
|
||||
},
|
||||
"team": {
|
||||
"id": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"key": "WEB",
|
||||
"name": "Webhooks"
|
||||
},
|
||||
"labels": []
|
||||
},
|
||||
"url": "https://linear.app/webhooks/issue/WEB-46/impact-analysis",
|
||||
"type": "Issue",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681207816141
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"action": "remove",
|
||||
"createdAt": "2023-04-11T10:13:05.795Z",
|
||||
"data": {
|
||||
"id": "f9a37fcf-eb52-44be-a52c-0477f70e9952",
|
||||
"createdAt": "2023-04-11T10:10:15.037Z",
|
||||
"updatedAt": "2023-04-11T10:12:11.142Z",
|
||||
"archivedAt": "2023-04-11T10:13:05.795Z",
|
||||
"number": 46,
|
||||
"title": "Thorough Impact Analysis and Cost Realization",
|
||||
"priority": 0,
|
||||
"boardOrder": 0,
|
||||
"sortOrder": -29786,
|
||||
"trashed": true,
|
||||
"teamId": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"previousIdentifiers": [],
|
||||
"creatorId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"stateId": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"parentId": "3443a709-f2b5-46f2-a136-a0445fd432be",
|
||||
"subIssueSortOrder": 1102,
|
||||
"priorityLabel": "No priority",
|
||||
"subscriberIds": [
|
||||
"674c90c8-35ea-454d-8ca4-5548258fd795"
|
||||
],
|
||||
"labelIds": [],
|
||||
"description": "Examining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident.",
|
||||
"descriptionData": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"text\":\"Examining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident.\",\"type\":\"text\"}]}]}",
|
||||
"state": {
|
||||
"id": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"color": "#e2e2e2",
|
||||
"name": "Todo",
|
||||
"type": "unstarted"
|
||||
},
|
||||
"team": {
|
||||
"id": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"key": "WEB",
|
||||
"name": "Webhooks"
|
||||
},
|
||||
"labels": []
|
||||
},
|
||||
"type": "Issue",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681207985997
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"action": "update",
|
||||
"createdAt": "2023-04-11T10:12:11.141Z",
|
||||
"data": {
|
||||
"id": "f9a37fcf-eb52-44be-a52c-0477f70e9952",
|
||||
"createdAt": "2023-04-11T10:10:15.037Z",
|
||||
"updatedAt": "2023-04-11T10:12:11.141Z",
|
||||
"number": 46,
|
||||
"title": "Thorough Impact Analysis and Cost Realization",
|
||||
"priority": 0,
|
||||
"boardOrder": 0,
|
||||
"sortOrder": -29786,
|
||||
"teamId": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"previousIdentifiers": [],
|
||||
"creatorId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"stateId": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"parentId": "3443a709-f2b5-46f2-a136-a0445fd432be",
|
||||
"subIssueSortOrder": 1102,
|
||||
"priorityLabel": "No priority",
|
||||
"subscriberIds": [
|
||||
"674c90c8-35ea-454d-8ca4-5548258fd795"
|
||||
],
|
||||
"labelIds": [],
|
||||
"description": "Examining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident.",
|
||||
"descriptionData": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"text\":\"Examining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident.\",\"type\":\"text\"}]}]}",
|
||||
"state": {
|
||||
"id": "a19a64b3-1d56-4ecb-b40e-d14aee5e9368",
|
||||
"color": "#e2e2e2",
|
||||
"name": "Todo",
|
||||
"type": "unstarted"
|
||||
},
|
||||
"team": {
|
||||
"id": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"key": "WEB",
|
||||
"name": "Webhooks"
|
||||
},
|
||||
"labels": []
|
||||
},
|
||||
"updatedFrom": {
|
||||
"updatedAt": "2023-04-11T10:10:15.037Z",
|
||||
"title": "Impact Analysis"
|
||||
},
|
||||
"url": "https://linear.app/webhooks/issue/WEB-46/thorough-impact-analysis-and-cost-realization",
|
||||
"type": "Issue",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681207931317
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
{
|
||||
"action": "update",
|
||||
"createdAt": "2023-04-11T10:16:53.022Z",
|
||||
"data": {
|
||||
"id": "3443a709-f2b5-46f2-a136-a0445fd432be",
|
||||
"createdAt": "2023-04-11T10:10:15.037Z",
|
||||
"updatedAt": "2023-04-11T10:16:53.022Z",
|
||||
"number": 44,
|
||||
"title": "This is regarding the outage that we faced on 11/12/22 from 2000 to 2200 and also on 25/12/22 from 0000 to 0230",
|
||||
"priority": 1,
|
||||
"boardOrder": 0,
|
||||
"sortOrder": -2036,
|
||||
"startedAt": "2023-04-11T10:10:15.093Z",
|
||||
"teamId": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"cycleId": "eaef2755-de5b-4342-accb-79060378493f",
|
||||
"previousIdentifiers": [],
|
||||
"creatorId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"assigneeId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"stateId": "a2530cac-36a0-4b6d-9af0-6357784035d4",
|
||||
"priorityLabel": "Urgent",
|
||||
"subscriberIds": [
|
||||
"674c90c8-35ea-454d-8ca4-5548258fd795"
|
||||
],
|
||||
"labelIds": [
|
||||
"6e4da2ed-ee8b-4b19-9cf8-40e5603e04c1",
|
||||
"56111f1a-e733-49f2-856a-c42318bb8739",
|
||||
"196379c2-287d-436d-962c-b2c0ce8281a1",
|
||||
"926b0916-05e2-4e8b-a7c6-96bc2c763326"
|
||||
],
|
||||
"description": "The outage that occurred on the above-mentioned date is a cause for concern as it could have significant implications for the organization and its users. A prolonged outage can result in lost revenue, productivity, and customer confidence. Therefore, it is essential to conduct a detailed assessment and analysis to identify the root cause of the outage and take appropriate measures to prevent its recurrence.\n\nThe analysis process may involve the use of specialized tools and techniques to help pinpoint the exact cause of the outage. Once the root cause has been identified, the organization can take steps to implement effective solutions that can mitigate the risk of a similar outage happening in the future. The assessment and analysis process will help the organization to develop a more robust and reliable IT infrastructure that can provide uninterrupted services to its users.",
|
||||
"descriptionData": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"text\":\"The outage that occurred on the above-mentioned date is a cause for concern as it could have significant implications for the organization and its users. A prolonged outage can result in lost revenue, productivity, and customer confidence. Therefore, it is essential to conduct a detailed assessment and analysis to identify the root cause of the outage and take appropriate measures to prevent its recurrence.\",\"type\":\"text\"}]},{\"type\":\"paragraph\",\"content\":[{\"text\":\"The analysis process may involve the use of specialized tools and techniques to help pinpoint the exact cause of the outage. Once the root cause has been identified, the organization can take steps to implement effective solutions that can mitigate the risk of a similar outage happening in the future. The assessment and analysis process will help the organization to develop a more robust and reliable IT infrastructure that can provide uninterrupted services to its users.\",\"type\":\"text\"}]}]}",
|
||||
"assignee": {
|
||||
"id": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"name": "Satyam Bansal"
|
||||
},
|
||||
"cycle": {
|
||||
"id": "eaef2755-de5b-4342-accb-79060378493f",
|
||||
"number": 1,
|
||||
"startsAt": "2023-04-05T18:30:00.000Z",
|
||||
"endsAt": "2023-04-12T18:30:00.000Z"
|
||||
},
|
||||
"state": {
|
||||
"id": "a2530cac-36a0-4b6d-9af0-6357784035d4",
|
||||
"color": "#f2c94c",
|
||||
"name": "In Progress",
|
||||
"type": "started"
|
||||
},
|
||||
"team": {
|
||||
"id": "9e383f51-2629-4f19-97ff-451cc2f0a0ad",
|
||||
"key": "WEB",
|
||||
"name": "Webhooks"
|
||||
},
|
||||
"labels": [
|
||||
{
|
||||
"id": "56111f1a-e733-49f2-856a-c42318bb8739",
|
||||
"color": "#4EA7FC",
|
||||
"name": "Improvement"
|
||||
},
|
||||
{
|
||||
"id": "196379c2-287d-436d-962c-b2c0ce8281a1",
|
||||
"color": "#BB87FC",
|
||||
"name": "Feature"
|
||||
},
|
||||
{
|
||||
"id": "6e4da2ed-ee8b-4b19-9cf8-40e5603e04c1",
|
||||
"color": "#EB5757",
|
||||
"name": "Bug"
|
||||
},
|
||||
{
|
||||
"id": "926b0916-05e2-4e8b-a7c6-96bc2c763326",
|
||||
"color": "#26b5ce",
|
||||
"name": "Custom Label"
|
||||
}
|
||||
]
|
||||
},
|
||||
"updatedFrom": {
|
||||
"updatedAt": "2023-04-11T10:13:05.980Z",
|
||||
"title": "This is regarding the outage that we faced during 11/12/22 from 2000 to 2200."
|
||||
},
|
||||
"url": "https://linear.app/webhooks/issue/WEB-44/this-is-regarding-the-outage-that-we-faced-on-111222-from-2000-to-2200",
|
||||
"type": "Issue",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681208213456
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"action": "create",
|
||||
"createdAt": "2023-04-11T19:26:16.461Z",
|
||||
"data": {
|
||||
"id": "521660ac-782f-4dd9-8928-95dbc9cb4c9b",
|
||||
"createdAt": "2023-04-11T19:26:16.461Z",
|
||||
"updatedAt": "2023-04-11T19:26:16.461Z",
|
||||
"name": "This is just a sample project to test the working.",
|
||||
"description": "",
|
||||
"slugId": "3d89ec1c20d3",
|
||||
"color": "#bec2c8",
|
||||
"state": "backlog",
|
||||
"creatorId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"leadId": "674c90c8-35ea-454d-8ca4-5548258fd795",
|
||||
"sortOrder": 2014.64,
|
||||
"issueCountHistory": [],
|
||||
"completedIssueCountHistory": [],
|
||||
"scopeHistory": [],
|
||||
"completedScopeHistory": [],
|
||||
"inProgressScopeHistory": [],
|
||||
"slackNewIssue": true,
|
||||
"slackIssueComments": true,
|
||||
"slackIssueStatuses": true,
|
||||
"teamIds": [
|
||||
"9e383f51-2629-4f19-97ff-451cc2f0a0ad"
|
||||
],
|
||||
"memberIds": [
|
||||
"674c90c8-35ea-454d-8ca4-5548258fd795"
|
||||
]
|
||||
},
|
||||
"url": "https://linear.app/webhooks/project/this-is-just-a-sample-project-to-test-the-working-3d89ec1c20d3",
|
||||
"type": "Project",
|
||||
"organizationId": "7a661544-df08-4cd1-a1e3-5ec611898806",
|
||||
"webhookTimestamp": 1681241176588
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
|
||||
class LinearHookTests(WebhookTestCase):
|
||||
STREAM_NAME = "Linear"
|
||||
URL_TEMPLATE = "/api/v1/external/linear?&api_key={api_key}&stream={stream}"
|
||||
WEBHOOK_DIR_NAME = "linear"
|
||||
|
||||
def test_issue_create_simple_without_description(self) -> None:
|
||||
expected_topic = "21e12515-fe5e-4923-88a1-e9ace5056473"
|
||||
expected_message = "Issue [#42 Drop-down overflow in the select menu.](https://linear.app/webhooks/issue/WEB-42/drop-down-overflow-in-the-select-menu) was created in team Webhooks.\nPriority: High, Status: Todo."
|
||||
self.check_webhook(
|
||||
"issue_create_simple_without_description",
|
||||
expected_topic,
|
||||
expected_message,
|
||||
)
|
||||
|
||||
def test_issue_create_simple_without_description_with_custom_topic_in_url(self) -> None:
|
||||
self.url = self.build_webhook_url(topic="notifications")
|
||||
expected_topic = "notifications"
|
||||
expected_message = "Issue [#42 Drop-down overflow in the select menu.](https://linear.app/webhooks/issue/WEB-42/drop-down-overflow-in-the-select-menu) was created in team Webhooks.\nPriority: High, Status: Todo."
|
||||
self.check_webhook(
|
||||
"issue_create_simple_without_description",
|
||||
expected_topic,
|
||||
expected_message,
|
||||
)
|
||||
|
||||
def test_issue_create_simple(self) -> None:
|
||||
expected_topic = "a4344dc7-7d8d-4b28-a93c-553ac9aba41a"
|
||||
expected_message = 'Issue [#43 Very small font in tooltip](https://linear.app/webhooks/issue/WEB-43/very-small-font-in-tooltip) was created in team Webhooks:\n~~~ quote\nThe tooltips at the "Select Drawing" and "Edit Drawing" buttons have a very small font and therefore are not very legible. Apart from this, the wording of the text has to be changed to fit better with the overall design pattern.\n~~~\n\nStatus: Todo.'
|
||||
self.check_webhook("issue_create_simple", expected_topic, expected_message)
|
||||
|
||||
def test_issue_create_complex(self) -> None:
|
||||
expected_topic = "3443a709-f2b5-46f2-a136-a0445fd432be"
|
||||
expected_message = "Issue [#44 This is regarding the outage that we faced during 11/12/22 from 2000 to 2200.](https://linear.app/webhooks/issue/WEB-44/this-is-regarding-the-outage-that-we-faced-during-111222-from-2000-to) was created in team Webhooks:\n~~~ quote\nThe outage that occurred on the above-mentioned date is a cause for concern as it could have significant implications for the organization and its users. A prolonged outage can result in lost revenue, productivity, and customer confidence. Therefore, it is essential to conduct a detailed assessment and analysis to identify the root cause of the outage and take appropriate measures to prevent its recurrence.\n\nThe analysis process may involve the use of specialized tools and techniques to help pinpoint the exact cause of the outage. Once the root cause has been identified, the organization can take steps to implement effective solutions that can mitigate the risk of a similar outage happening in the future. The assessment and analysis process will help the organization to develop a more robust and reliable IT infrastructure that can provide uninterrupted services to its users.\n~~~\n\nPriority: Urgent, Assignee: Satyam Bansal, Status: In Progress."
|
||||
self.check_webhook("issue_create_complex", expected_topic, expected_message)
|
||||
|
||||
def test_comment_create(self) -> None:
|
||||
expected_topic = "f9a37fcf-eb52-44be-a52c-0477f70e9952"
|
||||
expected_message = "Satyam Bansal [commented](https://linear.app/webhooks/issue/WEB-46#comment-c7cafc52) on issue **Thorough Impact Analysis and Cost Realization**:\n~~~ quote\nPerforming a thorough impact analysis and cost realization is a crucial step in responding to any system outage or incident. By examining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident, we can gain a comprehensive understanding of the scope of the incident.\n\nThis information can then be used to prioritize the resolution efforts and minimize the impact on our organization's operations. Additionally, cost realization allows us to evaluate the financial impact of the outage on our organization and make informed decisions regarding resource allocation for future incidents.\n\nOverall, conducting a thorough impact analysis and cost realization can help us effectively manage incidents and prevent similar issues from occurring in the future.\n~~~"
|
||||
self.check_webhook("comment_create", expected_topic, expected_message)
|
||||
|
||||
def test_comment_remove(self) -> None:
|
||||
expected_topic = "f9a37fcf-eb52-44be-a52c-0477f70e9952"
|
||||
expected_message = "Satyam Bansal has removed a comment."
|
||||
self.check_webhook("comment_remove", expected_topic, expected_message)
|
||||
|
||||
def test_comment_update(self) -> None:
|
||||
expected_topic = "f9a37fcf-eb52-44be-a52c-0477f70e9952"
|
||||
expected_message = "Satyam Bansal [updated comment](https://linear.app/webhooks/issue/WEB-46#comment-c7cafc52) on issue **Thorough Impact Analysis and Cost Realization**:\n~~~ quote\nInvalid response to any system outage or incident, it is essential to perform a comprehensive impact analysis and cost evaluation. By examining factors such as the extent of the outage, the affected systems or services, the number of users affected, and any error messages or logs generated during the incident, we can gain a detailed understanding of the incident's scope.\n\nThis information is then critical in prioritizing resolution efforts and reducing the impact on our organization's operations. Additionally, conducting cost realization allows us to assess the financial implications of the outage and make informed decisions about allocating resources for future incidents.\n\nOverall, performing a thorough impact analysis and cost realization is an effective way to manage incidents and prevent similar issues from recurring.\n~~~"
|
||||
self.check_webhook("comment_update", expected_topic, expected_message)
|
||||
|
||||
def test_issue_remove(self) -> None:
|
||||
expected_topic = "3443a709-f2b5-46f2-a136-a0445fd432be"
|
||||
expected_message = "Issue **#44 This is regarding the outage that we faced on 11/12/22 from 2000 to 2200 and also on 25/12/22 from 0000 to 0230** has been removed from team Webhooks."
|
||||
self.check_webhook("issue_remove", expected_topic, expected_message)
|
||||
|
||||
def test_issue_sub_issue_create(self) -> None:
|
||||
expected_topic = "3443a709-f2b5-46f2-a136-a0445fd432be"
|
||||
expected_message = "Sub-Issue [#46 Impact Analysis](https://linear.app/webhooks/issue/WEB-46/impact-analysis) was created in team Webhooks:\n~~~ quote\nExamining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident.\n~~~\n\nStatus: Todo."
|
||||
self.check_webhook("issue_sub_issue_create", expected_topic, expected_message)
|
||||
|
||||
def test_issue_sub_issue_remove(self) -> None:
|
||||
expected_topic = "3443a709-f2b5-46f2-a136-a0445fd432be"
|
||||
expected_message = "Sub-Issue **#46 Thorough Impact Analysis and Cost Realization** has been removed from team Webhooks."
|
||||
self.check_webhook("issue_sub_issue_remove", expected_topic, expected_message)
|
||||
|
||||
def test_issue_sub_issue_update(self) -> None:
|
||||
expected_topic = "3443a709-f2b5-46f2-a136-a0445fd432be"
|
||||
expected_message = "Sub-Issue [#46 Thorough Impact Analysis and Cost Realization](https://linear.app/webhooks/issue/WEB-46/thorough-impact-analysis-and-cost-realization) was updated in team Webhooks:\n~~~ quote\nExamining the extent of the outage, the affected systems or services, the number of users impacted, and any error messages or logs generated during the incident.\n~~~\n\nStatus: Todo."
|
||||
self.check_webhook("issue_sub_issue_update", expected_topic, expected_message)
|
||||
|
||||
def test_issue_update(self) -> None:
|
||||
expected_topic = "3443a709-f2b5-46f2-a136-a0445fd432be"
|
||||
expected_message = "Issue [#44 This is regarding the outage that we faced on 11/12/22 from 2000 to 2200 and also on 25/12/22 from 0000 to 0230](https://linear.app/webhooks/issue/WEB-44/this-is-regarding-the-outage-that-we-faced-on-111222-from-2000-to-2200) was updated in team Webhooks:\n~~~ quote\nThe outage that occurred on the above-mentioned date is a cause for concern as it could have significant implications for the organization and its users. A prolonged outage can result in lost revenue, productivity, and customer confidence. Therefore, it is essential to conduct a detailed assessment and analysis to identify the root cause of the outage and take appropriate measures to prevent its recurrence.\n\nThe analysis process may involve the use of specialized tools and techniques to help pinpoint the exact cause of the outage. Once the root cause has been identified, the organization can take steps to implement effective solutions that can mitigate the risk of a similar outage happening in the future. The assessment and analysis process will help the organization to develop a more robust and reliable IT infrastructure that can provide uninterrupted services to its users.\n~~~\n\nPriority: Urgent, Assignee: Satyam Bansal, Status: In Progress."
|
||||
self.check_webhook("issue_update", expected_topic, expected_message)
|
||||
|
||||
def test_project_create(self) -> None:
|
||||
payload = self.get_body("project_create")
|
||||
result = self.client_post(
|
||||
self.url,
|
||||
payload,
|
||||
content_type="application/json",
|
||||
)
|
||||
self.assert_json_success(result)
|
|
@ -0,0 +1,168 @@
|
|||
from typing import Callable, Dict, Optional
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import webhook_view
|
||||
from zerver.lib.exceptions import UnsupportedWebhookEventTypeError
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.validator import WildValue, check_int, check_string, to_wild_value
|
||||
from zerver.lib.webhooks.common import check_send_webhook_message
|
||||
from zerver.models import UserProfile
|
||||
|
||||
CONTENT_MESSAGE_TEMPLATE = "\n~~~ quote\n{message}\n~~~\n"
|
||||
|
||||
ISSUE_CREATE_OR_UPDATE_TEMPLATE = (
|
||||
"{type} [#{number} {title}]({url}) was {action} in team {team_name}"
|
||||
)
|
||||
|
||||
ISSUE_REMOVE_TEMPLATE = "{type} **#{number} {title}** has been removed from team {team_name}."
|
||||
COMMENT_CREATE_OR_UPDATE_TEMPLATE = "{user} [{action}]({url}) on issue **{issue_title}**:"
|
||||
COMMENT_REMOVE_TEMPLATE = "{user} has removed a comment."
|
||||
|
||||
|
||||
def get_issue_created_or_updated_message(event: str, payload: WildValue, action: str) -> str:
|
||||
message = ISSUE_CREATE_OR_UPDATE_TEMPLATE.format(
|
||||
type="Issue" if event == "issue" else "Sub-Issue",
|
||||
number=payload["data"]["number"].tame(check_int),
|
||||
title=payload["data"]["title"].tame(check_string),
|
||||
url=payload["url"].tame(check_string),
|
||||
action=action,
|
||||
team_name=payload["data"]["team"]["name"].tame(check_string),
|
||||
)
|
||||
|
||||
has_description = "description" in payload["data"]
|
||||
if has_description:
|
||||
message += f":{CONTENT_MESSAGE_TEMPLATE.format(message=payload['data']['description'].tame(check_string))}"
|
||||
else:
|
||||
message += "."
|
||||
|
||||
to_add = []
|
||||
|
||||
priority_label = payload["data"]["priorityLabel"].tame(check_string)
|
||||
if priority_label != "No priority":
|
||||
to_add.append(f"Priority: {priority_label}")
|
||||
|
||||
has_assignee = "assignee" in payload["data"]
|
||||
if has_assignee:
|
||||
to_add.append(f"Assignee: {payload['data']['assignee']['name'].tame(check_string)}")
|
||||
|
||||
status = payload["data"]["state"]["name"].tame(check_string)
|
||||
to_add.append(f"Status: {status}")
|
||||
|
||||
message += f"\n{', '.join(to_add)}."
|
||||
|
||||
return message
|
||||
|
||||
|
||||
def get_issue_remove_body(payload: WildValue, event: str) -> str:
|
||||
return ISSUE_REMOVE_TEMPLATE.format(
|
||||
type="Issue" if event == "issue" else "Sub-Issue",
|
||||
number=payload["data"]["number"].tame(check_int),
|
||||
title=payload["data"]["title"].tame(check_string),
|
||||
team_name=payload["data"]["team"]["name"].tame(check_string),
|
||||
)
|
||||
|
||||
|
||||
def get_comment_create_or_update_body(payload: WildValue, event: str, action: str) -> str:
|
||||
message = COMMENT_CREATE_OR_UPDATE_TEMPLATE.format(
|
||||
user=payload["data"]["user"]["name"].tame(check_string),
|
||||
action=action,
|
||||
url=payload["url"].tame(check_string),
|
||||
issue_title=payload["data"]["issue"]["title"].tame(check_string),
|
||||
)
|
||||
message += CONTENT_MESSAGE_TEMPLATE.format(message=payload["data"]["body"].tame(check_string))
|
||||
return message
|
||||
|
||||
|
||||
def get_comment_remove_body(payload: WildValue, event: str) -> str:
|
||||
return COMMENT_REMOVE_TEMPLATE.format(user=payload["data"]["user"]["name"].tame(check_string))
|
||||
|
||||
|
||||
def get_issue_or_sub_issue_message(payload: WildValue, event: str) -> str:
|
||||
action = payload["action"].tame(check_string)
|
||||
if action == "remove":
|
||||
return get_issue_remove_body(payload, event)
|
||||
|
||||
return get_issue_created_or_updated_message(
|
||||
event, payload, action="created" if action == "create" else "updated"
|
||||
)
|
||||
|
||||
|
||||
def get_comment_message(payload: WildValue, event: str) -> str:
|
||||
action = payload["action"].tame(check_string)
|
||||
if action == "remove":
|
||||
return get_comment_remove_body(payload, event)
|
||||
|
||||
return get_comment_create_or_update_body(
|
||||
payload, event, "commented" if action == "create" else "updated comment"
|
||||
)
|
||||
|
||||
|
||||
EVENT_FUNCTION_MAPPER: Dict[str, Callable[[WildValue, str], str]] = {
|
||||
"issue": get_issue_or_sub_issue_message,
|
||||
"sub_issue": get_issue_or_sub_issue_message,
|
||||
"comment": get_comment_message,
|
||||
}
|
||||
|
||||
IGNORED_EVENTS = ["IssueLabel", "Project", "ProjectUpdate", "Cycle", "Reaction"]
|
||||
|
||||
ALL_EVENT_TYPES = list(EVENT_FUNCTION_MAPPER.keys())
|
||||
|
||||
|
||||
@webhook_view("Linear", notify_bot_owner_on_invalid_json=True, all_event_types=ALL_EVENT_TYPES)
|
||||
@has_request_variables
|
||||
def api_linear_webhook(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
payload: WildValue = REQ(argument_type="body", converter=to_wild_value),
|
||||
user_specified_topic: Optional[str] = REQ("topic", default=None),
|
||||
) -> HttpResponse:
|
||||
event_type = get_event_type(payload)
|
||||
if event_type is None:
|
||||
return json_success(request)
|
||||
|
||||
topic = get_topic(user_specified_topic, event_type, payload)
|
||||
|
||||
body_function = EVENT_FUNCTION_MAPPER[event_type]
|
||||
body = body_function(payload, event_type)
|
||||
|
||||
check_send_webhook_message(request, user_profile, topic, body)
|
||||
|
||||
return json_success(request)
|
||||
|
||||
|
||||
def get_topic(user_specified_topic: Optional[str], event: str, payload: WildValue) -> str:
|
||||
if user_specified_topic is not None:
|
||||
return user_specified_topic
|
||||
elif event == "comment":
|
||||
issue_id = payload["data"]["issueId"].tame(check_string)
|
||||
return issue_id
|
||||
elif event == "sub_issue":
|
||||
parent = payload["data"]["parentId"].tame(check_string)
|
||||
return parent
|
||||
elif event == "issue":
|
||||
issue_id = payload["data"]["id"].tame(check_string)
|
||||
return issue_id
|
||||
|
||||
raise UnsupportedWebhookEventTypeError("unknown event type")
|
||||
|
||||
|
||||
def get_event_type(payload: WildValue) -> Optional[str]:
|
||||
event_type = payload["type"].tame(check_string)
|
||||
|
||||
if event_type == "Issue":
|
||||
has_parent_id = "parentId" in payload["data"]
|
||||
return "issue" if not has_parent_id else "sub_issue"
|
||||
elif event_type == "Comment":
|
||||
return "comment"
|
||||
elif event_type in IGNORED_EVENTS:
|
||||
return None
|
||||
|
||||
# This happens when a new event type is added to Linear and we
|
||||
# haven't updated the integration yet.
|
||||
complete_event = "{}:{}".format(
|
||||
event_type, payload.get("action", "???").tame(check_string)
|
||||
) # nocoverage
|
||||
|
||||
raise UnsupportedWebhookEventTypeError(complete_event)
|
Loading…
Reference in New Issue