snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
0
zerver/webhooks/linear/__init__.py
Normal file
0
zerver/webhooks/linear/__init__.py
Normal file
37
zerver/webhooks/linear/doc.md
Normal file
37
zerver/webhooks/linear/doc.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Zulip Linear integration
|
||||
|
||||
Get Linear notifications in Zulip!
|
||||
|
||||
{start_tabs}
|
||||
|
||||
1. {!create-an-incoming-webhook.md!}
|
||||
|
||||
1. {!generate-webhook-url-basic.md!}
|
||||
|
||||
1. Go to your team on Linear, and open **Settings**. Select **API**,
|
||||
and click on **New Webhook**.
|
||||
|
||||
1. Set **Webhook URL** to the URL generated above. Select the **Data
|
||||
change events** you'd like to receive notifications for, and click
|
||||
**Create Webhook**.
|
||||
|
||||
{end_tabs}
|
||||
|
||||
{!congrats.md!}
|
||||
|
||||

|
||||
|
||||
{!event-filtering-additional-feature.md!}
|
||||
|
||||
!!! warn ""
|
||||
|
||||
**Note**: `comment` events are only supported for comments on
|
||||
issues. Comments on Linear documents do not trigger notifications.
|
||||
|
||||
### Related documentation
|
||||
|
||||
- [Linear webhook events documentation][linear-webhooks]
|
||||
|
||||
{!webhooks-url-specification.md!}
|
||||
|
||||
[linear-webhooks]: https://developers.linear.app/docs/graphql/webhooks
|
||||
25
zerver/webhooks/linear/fixtures/comment_create.json
Normal file
25
zerver/webhooks/linear/fixtures/comment_create.json
Normal file
@@ -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
|
||||
}
|
||||
34
zerver/webhooks/linear/fixtures/comment_on_document.json
Normal file
34
zerver/webhooks/linear/fixtures/comment_on_document.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"action": "create",
|
||||
"actor": {
|
||||
"id": "e825c109-f691-4716-a85f-b68a2626531c",
|
||||
"name": "Dhruv Shetty",
|
||||
"email": "dhruv@example.com",
|
||||
"url": "https://linear.app/zulipdhruv/profiles/dhruv",
|
||||
"type": "user"
|
||||
},
|
||||
"createdAt": "2026-05-19T13:08:19.956Z",
|
||||
"data": {
|
||||
"id": "e3ff103c-53ac-4267-bdfc-cd05f7e49dc7",
|
||||
"createdAt": "2026-05-19T13:08:19.956Z",
|
||||
"updatedAt": "2026-05-19T13:08:19.927Z",
|
||||
"body": "This is an comment on a Document",
|
||||
"documentContentId": "49567929-242f-43b6-a7bf-193744e4279a",
|
||||
"userId": "e825c109-f691-4716-a85f-b68a2626531c",
|
||||
"quotedText": "This is an comment",
|
||||
"reactionData": [],
|
||||
"isArtificialAgentSessionRoot": false,
|
||||
"botActor": null,
|
||||
"user": {
|
||||
"id": "e825c109-f691-4716-a85f-b68a2626531c",
|
||||
"name": "Dhruv Shetty",
|
||||
"email": "dhruv@example.com",
|
||||
"url": "https://linear.app/zulipdhruv/profiles/dhruv"
|
||||
}
|
||||
},
|
||||
"url": "https://linear.app/zulipdhruv/document/hello-ddb80e78e24b#comment-e3ff103c",
|
||||
"type": "Comment",
|
||||
"organizationId": "498d97b2-c819-42cc-8d65-7bffd494ed23",
|
||||
"webhookTimestamp": 1779196118345,
|
||||
"webhookId": "a9d5653b-3026-4030-9c0e-ac964e3bb507"
|
||||
}
|
||||
25
zerver/webhooks/linear/fixtures/comment_remove.json
Normal file
25
zerver/webhooks/linear/fixtures/comment_remove.json
Normal file
@@ -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
|
||||
}
|
||||
31
zerver/webhooks/linear/fixtures/comment_update.json
Normal file
31
zerver/webhooks/linear/fixtures/comment_update.json
Normal file
@@ -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
|
||||
}
|
||||
73
zerver/webhooks/linear/fixtures/issue_create_complex.json
Normal file
73
zerver/webhooks/linear/fixtures/issue_create_complex.json
Normal file
@@ -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
|
||||
}
|
||||
41
zerver/webhooks/linear/fixtures/issue_create_simple.json
Normal file
41
zerver/webhooks/linear/fixtures/issue_create_simple.json
Normal file
@@ -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
|
||||
}
|
||||
81
zerver/webhooks/linear/fixtures/issue_remove.json
Normal file
81
zerver/webhooks/linear/fixtures/issue_remove.json
Normal file
@@ -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
|
||||
}
|
||||
43
zerver/webhooks/linear/fixtures/issue_sub_issue_create.json
Normal file
43
zerver/webhooks/linear/fixtures/issue_sub_issue_create.json
Normal file
@@ -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
|
||||
}
|
||||
44
zerver/webhooks/linear/fixtures/issue_sub_issue_remove.json
Normal file
44
zerver/webhooks/linear/fixtures/issue_sub_issue_remove.json
Normal file
@@ -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
|
||||
}
|
||||
47
zerver/webhooks/linear/fixtures/issue_sub_issue_update.json
Normal file
47
zerver/webhooks/linear/fixtures/issue_sub_issue_update.json
Normal file
@@ -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
|
||||
}
|
||||
84
zerver/webhooks/linear/fixtures/issue_update.json
Normal file
84
zerver/webhooks/linear/fixtures/issue_update.json
Normal file
@@ -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
|
||||
}
|
||||
35
zerver/webhooks/linear/fixtures/project_create.json
Normal file
35
zerver/webhooks/linear/fixtures/project_create.json
Normal file
@@ -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
|
||||
}
|
||||
90
zerver/webhooks/linear/tests.py
Normal file
90
zerver/webhooks/linear/tests.py
Normal file
@@ -0,0 +1,90 @@
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
|
||||
class LinearHookTests(WebhookTestCase):
|
||||
def test_issue_create_simple_without_description(self) -> None:
|
||||
expected_topic_name = "Issue: Drop-down overflow in the select menu."
|
||||
expected_message = "[Issue](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_name,
|
||||
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_name = "notifications"
|
||||
expected_message = "[Issue](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_name,
|
||||
expected_message,
|
||||
)
|
||||
|
||||
def test_issue_create_simple(self) -> None:
|
||||
expected_topic_name = "Issue: Very small font in tooltip"
|
||||
expected_message = '[Issue](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_name, expected_message)
|
||||
|
||||
def test_issue_create_complex(self) -> None:
|
||||
expected_topic_name = "Issue: This is regarding the outage that we faced during ..."
|
||||
expected_message = "[Issue](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_name, expected_message)
|
||||
|
||||
def test_comment_create(self) -> None:
|
||||
expected_topic_name = "Issue: Thorough Impact Analysis and Cost Realization"
|
||||
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_name, expected_message)
|
||||
|
||||
def test_comment_remove(self) -> None:
|
||||
expected_topic_name = "Issue: Thorough Impact Analysis and Cost Realization"
|
||||
expected_message = "Satyam Bansal has removed a comment."
|
||||
self.check_webhook("comment_remove", expected_topic_name, expected_message)
|
||||
|
||||
def test_comment_update(self) -> None:
|
||||
expected_topic_name = "Issue: Thorough Impact Analysis and Cost Realization"
|
||||
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_name, expected_message)
|
||||
|
||||
def test_issue_remove(self) -> None:
|
||||
expected_topic_name = "Issue: This is regarding the outage that we faced on 11/1..."
|
||||
expected_message = "This issue has been removed from team Webhooks."
|
||||
self.check_webhook("issue_remove", expected_topic_name, expected_message)
|
||||
|
||||
def test_issue_sub_issue_create(self) -> None:
|
||||
expected_topic_name = "Sub-Issue: Impact Analysis"
|
||||
expected_message = "[Sub-Issue](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_name, expected_message)
|
||||
|
||||
def test_issue_sub_issue_remove(self) -> None:
|
||||
expected_topic_name = "Sub-Issue: Thorough Impact Analysis and Cost Realization"
|
||||
expected_message = "This issue has been removed from team Webhooks."
|
||||
self.check_webhook("issue_sub_issue_remove", expected_topic_name, expected_message)
|
||||
|
||||
def test_issue_sub_issue_update(self) -> None:
|
||||
expected_topic_name = "Sub-Issue: Thorough Impact Analysis and Cost Realization"
|
||||
expected_message = "[Sub-Issue](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_name, expected_message)
|
||||
|
||||
def test_issue_update(self) -> None:
|
||||
expected_topic_name = "Issue: This is regarding the outage that we faced on 11/1..."
|
||||
expected_message = "[Issue](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_name, 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)
|
||||
|
||||
def test_comment_on_document(self) -> None:
|
||||
payload = self.get_body("comment_on_document")
|
||||
result = self.client_post(
|
||||
self.url,
|
||||
payload,
|
||||
content_type="application/json",
|
||||
)
|
||||
self.assert_json_success(result)
|
||||
169
zerver/webhooks/linear/view.py
Normal file
169
zerver/webhooks/linear/view.py
Normal file
@@ -0,0 +1,169 @@
|
||||
from collections.abc import Callable
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import webhook_view
|
||||
from zerver.lib.exceptions import UnsupportedWebhookEventTypeError
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint
|
||||
from zerver.lib.validator import WildValue, check_int, check_string
|
||||
from zerver.lib.webhooks.common import OptionalUserSpecifiedTopicStr, check_send_webhook_message
|
||||
from zerver.models import UserProfile
|
||||
|
||||
CONTENT_MESSAGE_TEMPLATE = "\n~~~ quote\n{message}\n~~~\n"
|
||||
|
||||
ISSUE_CREATE_OR_UPDATE_TEMPLATE = "[{type}]({url}) was {action} in team {team_name}"
|
||||
|
||||
ISSUE_REMOVE_TEMPLATE = "This issue 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)
|
||||
@typed_endpoint
|
||||
def api_linear_webhook(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
*,
|
||||
payload: JsonBodyPayload[WildValue],
|
||||
user_specified_topic: OptionalUserSpecifiedTopicStr = None,
|
||||
) -> HttpResponse:
|
||||
event_type = get_event_type(payload)
|
||||
if event_type is None:
|
||||
return json_success(request)
|
||||
|
||||
topic_name = 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_name, body)
|
||||
|
||||
return json_success(request)
|
||||
|
||||
|
||||
def get_topic(user_specified_topic: str | None, event: str, payload: WildValue) -> str:
|
||||
if user_specified_topic is not None:
|
||||
return user_specified_topic
|
||||
elif event == "comment":
|
||||
issue_title = payload["data"]["issue"]["title"].tame(check_string)
|
||||
return f"Issue: {issue_title}"
|
||||
elif event == "sub_issue":
|
||||
title = payload["data"]["title"].tame(check_string)
|
||||
return f"Sub-Issue: {title}"
|
||||
elif event == "issue":
|
||||
title = payload["data"]["title"].tame(check_string)
|
||||
return f"Issue: {title}"
|
||||
|
||||
raise UnsupportedWebhookEventTypeError(event)
|
||||
|
||||
|
||||
def get_event_type(payload: WildValue) -> str | None:
|
||||
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":
|
||||
# Document comments also arrive as Comment events but carry
|
||||
# no nested issue object to route a topic to.
|
||||
return "comment" if "issue" in payload["data"] else None
|
||||
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)
|
||||
Reference in New Issue
Block a user