Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

webhooks/intercom: Clear out the outdated integration, and disable it.

Niloth P1cf139841c33
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index 962058905ec..0867a16acc8 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -216,7 +216,7 @@ class Integration:
self.doc = doc
def is_enabled_in_catalog(self) -> bool:
- return True
+ return self.name != "intercom"
def get_logo_path(self, fallback_logo_path: str | None = None) -> str:
paths_to_check = [
@@ -722,11 +722,7 @@ INCOMING_WEBHOOK_INTEGRATIONS: list[IncomingWebhookIntegration] = [
display_name="Home Assistant",
),
IncomingWebhookIntegration("ifttt", ["meta-integration"], display_name="IFTTT"),
- IncomingWebhookIntegration(
- "intercom",
- ["customer-support"],
- [WebhookScreenshotConfig("conversation_admin_replied.json")],
- ),
+ IncomingWebhookIntegration("intercom", ["customer-support"]),
IncomingWebhookIntegration(
"jira",
["project-management"],
@@ -1114,6 +1110,8 @@ INTEGRATIONS_MISSING_SCREENSHOT_CONFIG = (
# The fixture's goal.losedate needs to be modified dynamically,
# so the screenshot config is commented out.
{"beeminder"}
+ # Disabled integrations that are in the process of being added or rewritten.
+ | {"intercom"}
# Integrations that call external API endpoints.
| {"slack"}
# Integrations that require screenshots of message threads - support is yet to be added
diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py
index 2ac5d3a305c..ef988f5e3c8 100644
--- a/zerver/tests/test_docs.py
+++ b/zerver/tests/test_docs.py
@@ -503,7 +503,13 @@ class DocPageTest(ZulipTestCase):
# for the PythonAPIIntegrations, so we cannot avoid going out of sync
# when adding/deleting screenshots.
# Use this set to temporarily add exclusions to this test.
- exception_images: set[str] = {"git/001.png"}
+ exception_images: set[str] = {
+ # Images used in docs of python-zulip-api integrations
+ "git/001.png",
+ # Images used in docs of disabled integrations
+ "logos/intercom.svg",
+ "intercom/001.png",
+ }
images_in_dir.update(exception_images)
images_in_docs.update(exception_images)
diff --git a/zerver/webhooks/intercom/fixtures/company_created.json b/zerver/webhooks/intercom/fixtures/company_created.json
deleted file mode 100644
index b4bb1a1fe42..00000000000
--- a/zerver/webhooks/intercom/fixtures/company_created.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "company",
- "id": "5c96b2c0d1c4c1a2d455b937",
- "company_id": "5c96b2c0d1c4c1a2d455b936-qualification-company",
- "app_id": "i6wc9ipe",
- "name": "Kandra Labs",
- "plan_id": null,
- "remote_created_at": null,
- "created_at": "2019-03-23T22:27:12.078Z",
- "updated_at": "2019-03-23T22:27:12.147Z",
- "last_request_at": "2019-03-23T22:20:52.453Z",
- "monthly_spend": 0,
- "session_count": 0,
- "user_count": 1,
- "tag_ids": [],
- "custom_attributes": {}
- }
- },
- "links": {},
- "id": "notif_1126b848-48b0-4bbb-8106-3df9d42f1a90",
- "topic": "company.created",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553380032,
- "created_at": 1553380032,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/contact_added_email.json b/zerver/webhooks/intercom/fixtures/contact_added_email.json
deleted file mode 100644
index 5c53ce4c97b..00000000000
--- a/zerver/webhooks/intercom/fixtures/contact_added_email.json
+++ /dev/null
@@ -1,78 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "contact",
- "id": "5c96b122177026171b401e20",
- "user_id": "8f9ef493-c5f9-4817-895d-874c3704ea49",
- "anonymous": true,
- "email": "[email protected]",
- "phone": null,
- "name": null,
- "pseudonym": "Azure Bus from St. John's",
- "avatar": {
- "type": "avatar",
- "image_url": null
- },
- "app_id": "i6wc9ipe",
- "companies": {
- "type": "company.list",
- "companies": []
- },
- "location_data": {
- "type": "location_data",
- "city_name": "St. John's",
- "continent_code": "NA",
- "country_name": "Canada",
- "postal_code": "A1B",
- "region_name": "Newfoundland and Labrador",
- "timezone": "America/St_Johns",
- "country_code": "CAN",
- "latitude": null,
- "longitude": null
- },
- "last_request_at": "2019-03-23T22:20:52.453+00:00",
- "created_at": "2019-03-23T22:20:18.253+00:00",
- "remote_created_at": null,
- "signed_up_at": null,
- "updated_at": "2019-03-23T22:21:46.437+00:00",
- "session_count": 0,
- "social_profiles": {
- "type": "social_profile.list",
- "social_profiles": []
- },
- "unsubscribed_from_emails": false,
- "marked_email_as_spam": false,
- "has_hard_bounced": false,
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "segments": {
- "type": "segment.list",
- "segments": []
- },
- "custom_attributes": {},
- "referrer": null,
- "utm_campaign": null,
- "utm_content": null,
- "utm_medium": null,
- "utm_source": null,
- "utm_term": null,
- "do_not_track": null,
- "last_seen_ip": null,
- "user_agent_data": null
- }
- },
- "links": {},
- "id": "notif_0cdd6657-8227-439f-899e-957646831785",
- "topic": "contact.added_email",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553379706,
- "created_at": 1553379706,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/contact_created.json b/zerver/webhooks/intercom/fixtures/contact_created.json
deleted file mode 100644
index e32f7fb0649..00000000000
--- a/zerver/webhooks/intercom/fixtures/contact_created.json
+++ /dev/null
@@ -1,78 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "contact",
- "id": "5c96b122177026171b401e20",
- "user_id": "8f9ef493-c5f9-4817-895d-874c3704ea49",
- "anonymous": true,
- "email": "[email protected]",
- "phone": null,
- "name": null,
- "pseudonym": "Azure Bus from St. John's",
- "avatar": {
- "type": "avatar",
- "image_url": "https://static.intercomassets.com/app/pseudonym_avatars_2019/azure-bus.png"
- },
- "app_id": "i6wc9ipe",
- "companies": {
- "type": "company.list",
- "companies": []
- },
- "location_data": {
- "type": "location_data",
- "city_name": "St. John's",
- "continent_code": "NA",
- "country_name": "Canada",
- "postal_code": "A1B",
- "region_name": "Newfoundland and Labrador",
- "timezone": "America/St_Johns",
- "country_code": "CAN",
- "latitude": null,
- "longitude": null
- },
- "last_request_at": "2019-03-23T22:20:52.453+00:00",
- "created_at": "2019-03-23T22:20:18.253+00:00",
- "remote_created_at": null,
- "signed_up_at": null,
- "updated_at": "2019-03-23T22:20:52.000Z",
- "session_count": 0,
- "social_profiles": {
- "type": "social_profile.list",
- "social_profiles": []
- },
- "unsubscribed_from_emails": false,
- "marked_email_as_spam": false,
- "has_hard_bounced": false,
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "segments": {
- "type": "segment.list",
- "segments": []
- },
- "custom_attributes": {},
- "referrer": null,
- "utm_campaign": null,
- "utm_content": null,
- "utm_medium": null,
- "utm_source": null,
- "utm_term": null,
- "do_not_track": null,
- "last_seen_ip": null,
- "user_agent_data": null
- }
- },
- "links": {},
- "id": "notif_dc69e41e-58c6-49d0-8d36-69669db7fc67",
- "topic": "contact.created",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553379652,
- "created_at": 1553379652,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/contact_signed_up.json b/zerver/webhooks/intercom/fixtures/contact_signed_up.json
deleted file mode 100644
index a198357e52d..00000000000
--- a/zerver/webhooks/intercom/fixtures/contact_signed_up.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "user",
- "id": "5c96bcd732ba0a1531c0264c",
- "user_id": null,
- "anonymous": false,
- "email": "[email protected]",
- "phone": null,
- "name": null,
- "pseudonym": "Lilac Raindrop from St. John's",
- "avatar": {
- "type": "avatar",
- "image_url": null
- },
- "app_id": "i6wc9ipe",
- "companies": {
- "type": "company.list",
- "companies": []
- },
- "location_data": {
- "type": "location_data",
- "city_name": "St. John's",
- "continent_code": "NA",
- "country_name": "Canada",
- "postal_code": "A1B",
- "region_name": "Newfoundland and Labrador",
- "timezone": "America/St_Johns",
- "country_code": "CAN",
- "latitude": null,
- "longitude": null
- },
- "last_request_at": "2019-03-23T23:14:41.517+00:00",
- "created_at": "2019-03-23T23:10:15.062+00:00",
- "remote_created_at": "2019-03-26T23:04:14.500+00:00",
- "signed_up_at": "2019-03-26T23:04:14.500+00:00",
- "updated_at": "2019-03-26T23:04:14.634+00:00",
- "session_count": 0,
- "social_profiles": {
- "type": "social_profile.list",
- "social_profiles": []
- },
- "unsubscribed_from_emails": false,
- "marked_email_as_spam": false,
- "has_hard_bounced": false,
- "tags": {
- "type": "tag.list",
- "tags": [
- {
- "type": "tag",
- "id": "2525085"
- }
- ]
- },
- "segments": {
- "type": "segment.list",
- "segments": [
- {
- "type": "segment",
- "id": "5ac7ad3ed9cd4bd75b1575e0"
- },
- {
- "type": "segment",
- "id": "5ac7ad3ed9cd4bd75b1575e1"
- }
- ]
- },
- "custom_attributes": {},
- "referrer": "http://localhost:9991/devlogin/",
- "utm_campaign": null,
- "utm_content": null,
- "utm_medium": null,
- "utm_source": null,
- "utm_term": null,
- "do_not_track": null,
- "last_seen_ip": null,
- "user_agent_data": null
- }
- },
- "links": {},
- "id": "notif_ed7d1f52-8a8e-4389-b715-ab7d5c027354",
- "topic": "contact.signed_up",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553641454,
- "created_at": 1553641454,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/contact_tag_created.json b/zerver/webhooks/intercom/fixtures/contact_tag_created.json
deleted file mode 100644
index 2ba4b81915d..00000000000
--- a/zerver/webhooks/intercom/fixtures/contact_tag_created.json
+++ /dev/null
@@ -1,113 +0,0 @@
-{
- "type":"notification_event",
- "app_id":"i6wc9ipe",
- "data":{
- "type":"notification_event_data",
- "item":{
- "type":"contact_tag",
- "created_at":1553291522,
- "tag":{
- "type":"tag",
- "id":"2525085",
- "name":"developer"
- },
- "contact":{
- "type":"contact",
- "id":"5c9553cb27e377f24eed49f7",
- "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
- "anonymous":true,
- "email":"[email protected]",
- "phone":"+17093452342",
- "name":"Eeshan Garg",
- "pseudonym":"Rose Poodle from St. John's",
- "avatar":{
- "type":"avatar",
- "image_url":"https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
- },
- "app_id":"i6wc9ipe",
- "companies":{
- "type":"company.list",
- "companies":[
- {
- "type":"company",
- "company_id":"5c9555b50af2951cc897b79a-qualification-company",
- "id":"5c9555b50af2951cc897b79b",
- "name":"Kandra Labs"
- }
- ]
- },
- "location_data":{
- "type":"location_data",
- "city_name":"St. John's",
- "continent_code":"NA",
- "country_name":"Canada",
- "postal_code":"A1B",
- "region_name":"Newfoundland and Labrador",
- "timezone":"America/St_Johns",
- "country_code":"CAN",
- "latitude":null,
- "longitude":null
- },
- "last_request_at":"2019-03-22T21:42:36.634+00:00",
- "created_at":"2019-03-22T21:29:47.980+00:00",
- "remote_created_at":null,
- "signed_up_at":null,
- "updated_at":"2019-03-22T21:52:02.210+00:00",
- "session_count":0,
- "social_profiles":{
- "type":"social_profile.list",
- "social_profiles":[
- {
- "type":"social_profile",
- "name":"github",
- "id":null,
- "username":"eeshangarg",
- "url":"https://github.com/eeshangarg"
- }
- ]
- },
- "unsubscribed_from_emails":false,
- "marked_email_as_spam":false,
- "has_hard_bounced":false,
- "tags":{
- "type":"tag.list",
- "tags":[
- {
- "type":"tag",
- "id":"2525085"
- }
- ]
- },
- "segments":{
- "type":"segment.list",
- "segments":[
-
- ]
- },
- "custom_attributes":{
-
- },
- "referrer":null,
- "utm_campaign":null,
- "utm_content":null,
- "utm_medium":null,
- "utm_source":null,
- "utm_term":null,
- "do_not_track":null,
- "last_seen_ip":null,
- "user_agent_data":null
- }
- }
- },
- "links":{
-
- },
- "id":"notif_cac9735a-d7a1-4425-8b8b-c45cdf915892",
- "topic":"contact.tag.created",
- "delivery_status":"pending",
- "delivery_attempts":1,
- "delivered_at":0,
- "first_sent_at":1553291522,
- "created_at":1553291522,
- "self":null
-}
diff --git a/zerver/webhooks/intercom/fixtures/contact_tag_deleted.json b/zerver/webhooks/intercom/fixtures/contact_tag_deleted.json
deleted file mode 100644
index 3e15639ce56..00000000000
--- a/zerver/webhooks/intercom/fixtures/contact_tag_deleted.json
+++ /dev/null
@@ -1,110 +0,0 @@
-{
- "type":"notification_event",
- "app_id":"i6wc9ipe",
- "data":{
- "type":"notification_event_data",
- "item":{
- "type":"contact_tag",
- "created_at":1553291644,
- "tag":{
- "type":"tag",
- "id":"2525085",
- "name":"developer"
- },
- "contact":{
- "type":"contact",
- "id":"5c9553cb27e377f24eed49f7",
- "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
- "anonymous":true,
- "email":"[email protected]",
- "phone":"+17093452342",
- "name":"Eeshan Garg",
- "pseudonym":"Rose Poodle from St. John's",
- "avatar":{
- "type":"avatar",
- "image_url":"https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
- },
- "app_id":"i6wc9ipe",
- "companies":{
- "type":"company.list",
- "companies":[
- {
- "type":"company",
- "company_id":"5c9555b50af2951cc897b79a-qualification-company",
- "id":"5c9555b50af2951cc897b79b",
- "name":"Kandra Labs"
- }
- ]
- },
- "location_data":{
- "type":"location_data",
- "city_name":"St. John's",
- "continent_code":"NA",
- "country_name":"Canada",
- "postal_code":"A1B",
- "region_name":"Newfoundland and Labrador",
- "timezone":"America/St_Johns",
- "country_code":"CAN",
- "latitude":null,
- "longitude":null
- },
- "last_request_at":"2019-03-22T21:42:36.634+00:00",
- "created_at":"2019-03-22T21:29:47.980+00:00",
- "remote_created_at":null,
- "signed_up_at":null,
- "updated_at":"2019-03-22T21:54:04.618+00:00",
- "session_count":0,
- "social_profiles":{
- "type":"social_profile.list",
- "social_profiles":[
- {
- "type":"social_profile",
- "name":"github",
- "id":null,
- "username":"eeshangarg",
- "url":"https://github.com/eeshangarg"
- }
- ]
- },
- "unsubscribed_from_emails":false,
- "marked_email_as_spam":false,
- "has_hard_bounced":false,
- "tags":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "segments":{
- "type":"segment.list",
- "segments":[
-
- ]
- },
- "custom_attributes":{
-
- },
- "referrer":null,
- "utm_campaign":null,
- "utm_content":null,
- "utm_medium":null,
- "utm_source":null,
- "utm_term":null,
- "do_not_track":null,
- "last_seen_ip":null,
- "user_agent_data":null
- }
- }
- },
- "links":{
-
- },
- "id":"notif_5cecbde1-e2f4-46dc-8f6a-378ddd22b1f7",
- "topic":"contact.tag.deleted",
- "delivery_status":"pending",
- "delivery_attempts":1,
- "delivered_at":0,
- "first_sent_at":1553291644,
- "created_at":1553291644,
- "self":null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_admin_assigned.json b/zerver/webhooks/intercom/fixtures/conversation_admin_assigned.json
deleted file mode 100644
index d980e47a41d..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_admin_assigned.json
+++ /dev/null
@@ -1,103 +0,0 @@
-{
- "type":"notification_event",
- "app_id":"i6wc9ipe",
- "data":{
- "type":"notification_event_data",
- "item":{
- "type":"conversation",
- "id":"21322009097",
- "created_at":1553290933,
- "updated_at":1553291111,
- "user":{
- "type":"lead",
- "id":"5c9553cb27e377f24eed49f7",
- "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
- "name":"Eeshan Garg",
- "email":"[email protected]",
- "do_not_track":null
- },
- "assignee":{
- "type":"admin",
- "id":"1957471",
- "name":"Tim Abbott",
- "email":"[email protected]"
- },
- "conversation_message":{
- "type":"conversation_message",
- "id":"331499307",
- "url":"http://localhost:9991/api/",
- "subject":"",
- "body":"<p>Hello</p>",
- "author":{
- "type":"user",
- "id":"5c9553cb27e377f24eed49f7"
- },
- "attachments":[
-
- ]
- },
- "conversation_parts":{
- "type":"conversation_part.list",
- "conversation_parts":[
- {
- "type":"conversation_part",
- "id":"2824382500",
- "part_type":"assignment",
- "body":"<p>Hey Eeshan! How can I help?</p>",
- "created_at":1553291111,
- "updated_at":1553291111,
- "notified_at":1553291111,
- "assigned_to":{
- "type":"admin",
- "id":"1957471",
- "name":"Eeshan Garg"
- },
- "author":{
- "type":"admin",
- "id":"1957471",
- "name":"Eeshan Garg"
- },
- "attachments":[
-
- ],
- "external_id":null
- }
- ],
- "total_count":1
- },
- "open":true,
- "state":"open",
- "snoozed_until":null,
- "read":false,
- "metadata":{
-
- },
- "tags":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "tags_added":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "links":{
- "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21322009097"
- }
- }
- },
- "links":{
-
- },
- "id":"notif_b577ea09-0998-45cf-ade1-df4d102a58ec",
- "topic":"conversation.admin.assigned",
- "delivery_status":"pending",
- "delivery_attempts":1,
- "delivered_at":0,
- "first_sent_at":1553291112,
- "created_at":1553291112,
- "self":null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_admin_closed.json b/zerver/webhooks/intercom/fixtures/conversation_admin_closed.json
deleted file mode 100644
index c7bfb2a9aeb..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_admin_closed.json
+++ /dev/null
@@ -1,99 +0,0 @@
-{
- "type":"notification_event",
- "app_id":"i6wc9ipe",
- "data":{
- "type":"notification_event_data",
- "item":{
- "type":"conversation",
- "id":"21322009097",
- "created_at":1553290933,
- "updated_at":1553291389,
- "user":{
- "type":"lead",
- "id":"5c9553cb27e377f24eed49f7",
- "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
- "name":"Eeshan Garg",
- "email":"[email protected]",
- "do_not_track":null
- },
- "assignee":{
- "type":"admin",
- "id":"1957471",
- "name":"Cordelia, Lear's daughter",
- "email":"[email protected]"
- },
- "conversation_message":{
- "type":"conversation_message",
- "id":"331499307",
- "url":"http://localhost:9991/api/",
- "subject":"",
- "body":"<p>Hello</p>",
- "author":{
- "type":"user",
- "id":"5c9553cb27e377f24eed49f7"
- },
- "attachments":[
-
- ]
- },
- "conversation_parts":{
- "type":"conversation_part.list",
- "conversation_parts":[
- {
- "type":"conversation_part",
- "id":"2824395628",
- "part_type":"close",
- "body":null,
- "created_at":1553291389,
- "updated_at":1553291389,
- "notified_at":1553291389,
- "assigned_to":null,
- "author":{
- "type":"admin",
- "id":"1957471",
- "name":"Eeshan Garg"
- },
- "attachments":[
-
- ],
- "external_id":null
- }
- ],
- "total_count":1
- },
- "open":false,
- "state":"closed",
- "snoozed_until":null,
- "read":true,
- "metadata":{
-
- },
- "tags":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "tags_added":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "links":{
- "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21322009097"
- }
- }
- },
- "links":{
-
- },
- "id":"notif_2bc4bf3a-0064-4fb0-9e17-dc44d91bcb9b",
- "topic":"conversation.admin.closed",
- "delivery_status":"pending",
- "delivery_attempts":1,
- "delivered_at":0,
- "first_sent_at":1553291390,
- "created_at":1553291390,
- "self":null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_admin_noted.json b/zerver/webhooks/intercom/fixtures/conversation_admin_noted.json
deleted file mode 100644
index 443fda23668..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_admin_noted.json
+++ /dev/null
@@ -1,87 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "conversation",
- "id": "21330067382",
- "created_at": 1553378082,
- "updated_at": 1553378536,
- "user": {
- "type": "lead",
- "id": "5c9553cb27e377f24eed49f7",
- "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
- "name": "Eeshan Garg",
- "email": "[email protected]",
- "do_not_track": null
- },
- "assignee": {
- "type": "admin",
- "id": "1957471",
- "name": "Cordelia, Lear's daughter",
- "email": "[email protected]"
- },
- "conversation_message": {
- "type": "conversation_message",
- "id": "331786931",
- "url": "http://localhost:9991/api/",
- "subject": "",
- "body": "<p>Hey! I'd like to set up a new account</p>",
- "author": {
- "type": "user",
- "id": "5c9553cb27e377f24eed49f7"
- },
- "attachments": []
- },
- "conversation_parts": {
- "type": "conversation_part.list",
- "conversation_parts": [
- {
- "type": "conversation_part",
- "id": "2826904904",
- "part_type": "note",
- "body": "<p>Talk to Tim about this user's query.</p>",
- "created_at": 1553378536,
- "updated_at": 1553378536,
- "notified_at": 1553378536,
- "assigned_to": null,
- "author": {
- "type": "admin",
- "id": "1957471",
- "name": "Eeshan Garg"
- },
- "attachments": [],
- "external_id": null
- }
- ],
- "total_count": 1
- },
- "open": true,
- "state": "open",
- "snoozed_until": null,
- "read": true,
- "metadata": {},
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "tags_added": {
- "type": "tag.list",
- "tags": []
- },
- "links": {
- "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330067382"
- }
- }
- },
- "links": {},
- "id": "notif_2087a079-b2de-408b-8f30-8d56695fe2d9",
- "topic": "conversation.admin.noted",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553378537,
- "created_at": 1553378537,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_admin_opened.json b/zerver/webhooks/intercom/fixtures/conversation_admin_opened.json
deleted file mode 100644
index 0060eb9aefd..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_admin_opened.json
+++ /dev/null
@@ -1,91 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "conversation",
- "id": "21330229536",
- "created_at": 1553380785,
- "updated_at": 1553380931,
- "user": {
- "type": "lead",
- "id": "5c96b58c27e3772c4751b2a3",
- "user_id": "ced6189f-e3b0-40b6-ab3a-9fdb27f4b3b0",
- "name": "Cordelia, Lear's daughter",
- "email": "[email protected]",
- "do_not_track": null
- },
- "assignee": {
- "type": "admin",
- "id": "1957471",
- "name": "Eeshan Garg",
- "email": "[email protected]"
- },
- "conversation_message": {
- "type": "conversation_message",
- "id": "331793703",
- "url": "http://localhost:9991/integrations/",
- "subject": "",
- "body": "<p>Hello</p>",
- "author": {
- "type": "user",
- "id": "5c96b58c27e3772c4751b2a3"
- },
- "attachments": []
- },
- "conversation_parts": {
- "type": "conversation_part.list",
- "conversation_parts": [
- {
- "type": "conversation_part",
- "id": "2826953202",
- "part_type": "open",
- "body": null,
- "created_at": 1553380931,
- "updated_at": 1553380931,
- "notified_at": 1553380931,
- "assigned_to": {
- "type": "admin",
- "id": "1957471",
- "name": "Eeshan Garg"
- },
- "author": {
- "type": "admin",
- "id": "1957471",
- "name": "Eeshan Garg"
- },
- "attachments": [],
- "external_id": null
- }
- ],
- "total_count": 1
- },
- "open": true,
- "state": "open",
- "snoozed_until": null,
- "read": true,
- "metadata": {},
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "tags_added": {
- "type": "tag.list",
- "tags": []
- },
- "links": {
- "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330229536"
- }
- }
- },
- "links": {},
- "id": "notif_d8906f30-db91-466e-9be2-4715fce4ab8b",
- "topic": "conversation.admin.opened",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553380932,
- "created_at": 1553380932,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_admin_replied.json b/zerver/webhooks/intercom/fixtures/conversation_admin_replied.json
deleted file mode 100644
index 9944b8fa13a..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_admin_replied.json
+++ /dev/null
@@ -1,103 +0,0 @@
-{
- "type":"notification_event",
- "app_id":"i6wc9ipe",
- "data":{
- "type":"notification_event_data",
- "item":{
- "type":"conversation",
- "id":"21322009097",
- "created_at":1553290933,
- "updated_at":1553291111,
- "user":{
- "type":"lead",
- "id":"5c9553cb27e377f24eed49f7",
- "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
- "name":"Eeshan Garg",
- "email":"[email protected]",
- "do_not_track":null
- },
- "assignee":{
- "type": "admin",
- "id": "1957471",
- "name": "Cordelia, Lear's daughter",
- "email": "[email protected]"
- },
- "conversation_message":{
- "type":"conversation_message",
- "id":"331499307",
- "url":"http://localhost:9991/api/",
- "subject":"",
- "body":"<p>Hello</p>",
- "author":{
- "type":"user",
- "id":"5c9553cb27e377f24eed49f7"
- },
- "attachments":[
-
- ]
- },
- "conversation_parts":{
- "type":"conversation_part.list",
- "conversation_parts":[
- {
- "type":"conversation_part",
- "id":"2824382500",
- "part_type":"assignment",
- "body":"<p>Hey Eeshan! How can I help?</p>",
- "created_at":1553291111,
- "updated_at":1553291111,
- "notified_at":1553291111,
- "assigned_to":{
- "type":"admin",
- "id":"1957471",
- "name":"Eeshan Garg"
- },
- "author":{
- "type":"admin",
- "id":"1957471",
- "name":"Eeshan Garg"
- },
- "attachments":[
-
- ],
- "external_id":null
- }
- ],
- "total_count":1
- },
- "open":true,
- "state":"open",
- "snoozed_until":null,
- "read":false,
- "metadata":{
-
- },
- "tags":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "tags_added":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "links":{
- "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21322009097"
- }
- }
- },
- "links":{
-
- },
- "id":"notif_44d1f763-d3ad-4927-8e5c-da6cd6ca78d2",
- "topic":"conversation.admin.replied",
- "delivery_status":"pending",
- "delivery_attempts":1,
- "delivered_at":0,
- "first_sent_at":1553291112,
- "created_at":1553291112,
- "self":null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_admin_single_created.json b/zerver/webhooks/intercom/fixtures/conversation_admin_single_created.json
deleted file mode 100644
index 9613cd85433..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_admin_single_created.json
+++ /dev/null
@@ -1,69 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "conversation",
- "id": "21330075292",
- "created_at": 1553378181,
- "updated_at": 1553378181,
- "user": {
- "type": "lead",
- "id": "5c9553cb27e377f24eed49f7",
- "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
- "name": "Eeshan Garg",
- "email": "[email protected]",
- "do_not_track": null
- },
- "assignee": {
- "type": "admin",
- "id": "1957471",
- "name": "Cordelia, Lear's daughter",
- "email": "[email protected]"
- },
- "conversation_message": {
- "type": "conversation_message",
- "id": "331787154",
- "url": null,
- "subject": "Hello",
- "body": "<p>Hi Eeshan, What's up</p>",
- "author": {
- "type": "admin",
- "id": "1957471"
- },
- "attachments": []
- },
- "conversation_parts": {
- "type": "conversation_part.list",
- "conversation_parts": [],
- "total_count": 0
- },
- "open": false,
- "state": "closed",
- "snoozed_until": null,
- "read": false,
- "metadata": {},
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "tags_added": {
- "type": "tag.list",
- "tags": []
- },
- "links": {
- "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330075292"
- }
- }
- },
- "links": {},
- "id": "notif_ca44c80b-1eaa-411c-b10f-046890017eea",
- "topic": "conversation.admin.single.created",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553378181,
- "created_at": 1553378181,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_admin_snoozed.json b/zerver/webhooks/intercom/fixtures/conversation_admin_snoozed.json
deleted file mode 100644
index 78c9978160d..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_admin_snoozed.json
+++ /dev/null
@@ -1,87 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "conversation",
- "id": "21330067382",
- "created_at": 1553378082,
- "updated_at": 1553378413,
- "user": {
- "type": "lead",
- "id": "5c9553cb27e377f24eed49f7",
- "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
- "name": "Eeshan Garg",
- "email": "[email protected]",
- "do_not_track": null
- },
- "assignee": {
- "type": "admin",
- "id": "1957471",
- "name": "Cordelia, Lear's daughter",
- "email": "[email protected]"
- },
- "conversation_message": {
- "type": "conversation_message",
- "id": "331786931",
- "url": "http://localhost:9991/api/",
- "subject": "",
- "body": "<p>Hey! I'd like to set up a new account</p>",
- "author": {
- "type": "user",
- "id": "5c9553cb27e377f24eed49f7"
- },
- "attachments": []
- },
- "conversation_parts": {
- "type": "conversation_part.list",
- "conversation_parts": [
- {
- "type": "conversation_part",
- "id": "2826902108",
- "part_type": "snoozed",
- "body": null,
- "created_at": 1553378413,
- "updated_at": 1553378413,
- "notified_at": 1553378413,
- "assigned_to": null,
- "author": {
- "type": "admin",
- "id": "1957471",
- "name": "Eeshan Garg"
- },
- "attachments": [],
- "external_id": null
- }
- ],
- "total_count": 1
- },
- "open": true,
- "state": "snoozed",
- "snoozed_until": 1553513400,
- "read": true,
- "metadata": {},
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "tags_added": {
- "type": "tag.list",
- "tags": []
- },
- "links": {
- "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330067382"
- }
- }
- },
- "links": {},
- "id": "notif_0530a65a-8052-4f67-9070-a50f1363dc68",
- "topic": "conversation.admin.snoozed",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553378414,
- "created_at": 1553378414,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_admin_unsnoozed.json b/zerver/webhooks/intercom/fixtures/conversation_admin_unsnoozed.json
deleted file mode 100644
index 3c3e026861f..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_admin_unsnoozed.json
+++ /dev/null
@@ -1,87 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "conversation",
- "id": "21330067382",
- "created_at": 1553378082,
- "updated_at": 1553378474,
- "user": {
- "type": "lead",
- "id": "5c9553cb27e377f24eed49f7",
- "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
- "name": "Eeshan Garg",
- "email": "[email protected]",
- "do_not_track": null
- },
- "assignee": {
- "type": "admin",
- "id": "1957471",
- "name": "Cordelia, Lear's daughter",
- "email": "[email protected]"
- },
- "conversation_message": {
- "type": "conversation_message",
- "id": "331786931",
- "url": "http://localhost:9991/api/",
- "subject": "",
- "body": "<p>Hey! I'd like to set up a new account</p>",
- "author": {
- "type": "user",
- "id": "5c9553cb27e377f24eed49f7"
- },
- "attachments": []
- },
- "conversation_parts": {
- "type": "conversation_part.list",
- "conversation_parts": [
- {
- "type": "conversation_part",
- "id": "2826903472",
- "part_type": "unsnoozed",
- "body": null,
- "created_at": 1553378474,
- "updated_at": 1553378474,
- "notified_at": 1553378474,
- "assigned_to": null,
- "author": {
- "type": "admin",
- "id": "1957471",
- "name": "Eeshan Garg"
- },
- "attachments": [],
- "external_id": null
- }
- ],
- "total_count": 1
- },
- "open": true,
- "state": "open",
- "snoozed_until": null,
- "read": true,
- "metadata": {},
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "tags_added": {
- "type": "tag.list",
- "tags": []
- },
- "links": {
- "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330067382"
- }
- }
- },
- "links": {},
- "id": "notif_f0f76ee2-f2c0-4526-90cd-caebecfc5ec5",
- "topic": "conversation.admin.unsnoozed",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553378475,
- "created_at": 1553378475,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_part_tag_created.json b/zerver/webhooks/intercom/fixtures/conversation_part_tag_created.json
deleted file mode 100644
index 47e234d9e2c..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_part_tag_created.json
+++ /dev/null
@@ -1,98 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "conversation",
- "id": "21330067382",
- "created_at": 1553378082,
- "updated_at": 1553378536,
- "user": {
- "type": "lead",
- "id": "5c9553cb27e377f24eed49f7",
- "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
- "name": "Eeshan Garg",
- "email": "[email protected]",
- "do_not_track": null
- },
- "assignee": {
- "type": "nobody_admin",
- "id": null
- },
- "conversation_message": {
- "type": "conversation_message",
- "id": "331786931",
- "url": "http://localhost:9991/api/",
- "subject": "",
- "body": "<p>Hey! I'd like to set up a new account</p>",
- "author": {
- "type": "user",
- "id": "5c9553cb27e377f24eed49f7"
- },
- "attachments": []
- },
- "conversation_parts": {
- "type": "conversation_part.list",
- "conversation_parts": [
- {
- "type": "conversation_part",
- "id": "331786931",
- "part_type": "comment",
- "body": "<p>Hey! I'd like to set up a new account</p>",
- "created_at": 1553378082,
- "updated_at": 1553378744,
- "notified_at": 1553378082,
- "assigned_to": null,
- "author": {
- "type": "user",
- "id": "5c9553cb27e377f24eed49f7",
- "name": "Eeshan Garg",
- "email": "[email protected]"
- },
- "attachments": [],
- "external_id": null
- }
- ],
- "total_count": 1
- },
- "open": true,
- "state": "open",
- "snoozed_until": null,
- "read": true,
- "metadata": {},
- "tags": {
- "type": "tag.list",
- "tags": [
- {
- "type": "tag",
- "id": "2525085",
- "name": "developer"
- }
- ]
- },
- "tags_added": {
- "type": "tag.list",
- "tags": [
- {
- "type": "tag",
- "id": "2525085",
- "name": "developer"
- }
- ]
- },
- "links": {
- "conversation_web": "https://app.intercom.io/a/apps/i6wc9ipe/conversations/21330067382"
- }
- }
- },
- "links": {},
- "id": "notif_11aef68a-8049-4f29-bbd9-48a7adfc8f30",
- "topic": "conversation_part.tag.created",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553378744,
- "created_at": 1553378744,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_user_created.json b/zerver/webhooks/intercom/fixtures/conversation_user_created.json
deleted file mode 100644
index e041d039b37..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_user_created.json
+++ /dev/null
@@ -1,79 +0,0 @@
-{
- "type":"notification_event",
- "app_id":"i6wc9ipe",
- "data":{
- "type":"notification_event_data",
- "item":{
- "type":"conversation",
- "id":"21321941764",
- "created_at":1553290198,
- "updated_at":1553290198,
- "user":{
- "type":"lead",
- "id":"5c9553cb27e377f24eed49f7",
- "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
- "name":"Rose Poodle from St. John's",
- "email":"",
- "do_not_track":null
- },
- "assignee":{
- "type":"nobody_admin",
- "id":null
- },
- "conversation_message":{
- "type":"conversation_message",
- "id":"331494375",
- "url":"http://localhost:9991/api/",
- "subject":"",
- "body":"<p>Hello everyone!</p>",
- "author":{
- "type":"user",
- "id":"5c9553cb27e377f24eed49f7"
- },
- "attachments":[
-
- ]
- },
- "conversation_parts":{
- "type":"conversation_part.list",
- "conversation_parts":[
-
- ],
- "total_count":0
- },
- "open":true,
- "state":"open",
- "snoozed_until":null,
- "read":true,
- "metadata":{
-
- },
- "tags":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "tags_added":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "links":{
- "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21321941764"
- }
- }
- },
- "links":{
-
- },
- "id":"notif_3ac27816-d27c-45fd-a65a-bbaf021cf780",
- "topic":"conversation.user.created",
- "delivery_status":"pending",
- "delivery_attempts":1,
- "delivered_at":0,
- "first_sent_at":1553290198,
- "created_at":1553290198,
- "self":null
-}
diff --git a/zerver/webhooks/intercom/fixtures/conversation_user_replied.json b/zerver/webhooks/intercom/fixtures/conversation_user_replied.json
deleted file mode 100644
index 6e40d1191a8..00000000000
--- a/zerver/webhooks/intercom/fixtures/conversation_user_replied.json
+++ /dev/null
@@ -1,100 +0,0 @@
-{
- "type":"notification_event",
- "app_id":"i6wc9ipe",
- "data":{
- "type":"notification_event_data",
- "item":{
- "type":"conversation",
- "id":"21322009097",
- "created_at":1553290933,
- "updated_at":1553291307,
- "user":{
- "type":"lead",
- "id":"5c9553cb27e377f24eed49f7",
- "user_id":"75067020-1204-495c-8edc-abb7d88bdd43",
- "name":"Eeshan Garg",
- "email":"[email protected]",
- "do_not_track":null
- },
- "assignee":{
- "type":"admin",
- "id":"1957471",
- "name":"Eeshan Garg",
- "email":"[email protected]"
- },
- "conversation_message":{
- "type":"conversation_message",
- "id":"331499307",
- "url":"http://localhost:9991/api/",
- "subject":"",
- "body":"<p>Hello</p>",
- "author":{
- "type":"user",
- "id":"5c9553cb27e377f24eed49f7"
- },
- "attachments":[
-
- ]
- },
- "conversation_parts":{
- "type":"conversation_part.list",
- "conversation_parts":[
- {
- "type":"conversation_part",
- "id":"2824391734",
- "part_type":"comment",
- "body":"<p>Well, I need some help getting access to a developer account.</p>",
- "created_at":1553291307,
- "updated_at":1553291307,
- "notified_at":1553291307,
- "assigned_to":null,
- "author":{
- "type":"user",
- "id":"5c9553cb27e377f24eed49f7",
- "name":"Eeshan Garg",
- "email":"[email protected]"
- },
- "attachments":[
-
- ],
- "external_id":null
- }
- ],
- "total_count":1
- },
- "open":true,
- "state":"open",
- "snoozed_until":null,
- "read":true,
- "metadata":{
-
- },
- "tags":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "tags_added":{
- "type":"tag.list",
- "tags":[
-
- ]
- },
- "links":{
- "conversation_web":"https://app.intercom.io/a/apps/i6wc9ipe/conversations/21322009097"
- }
- }
- },
- "links":{
-
- },
- "id":"notif_2c71fff0-65ef-46be-bbfe-dbf637bbff15",
- "topic":"conversation.user.replied",
- "delivery_status":"pending",
- "delivery_attempts":1,
- "delivered_at":0,
- "first_sent_at":1553291308,
- "created_at":1553291308,
- "self":null
-}
diff --git a/zerver/webhooks/intercom/fixtures/event_created.json b/zerver/webhooks/intercom/fixtures/event_created.json
deleted file mode 100644
index 756ab59ca2b..00000000000
--- a/zerver/webhooks/intercom/fixtures/event_created.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "event",
- "event_name": "invited-friend",
- "id": "84ca8d44-8f2e-11e3-bbc6-6d72c14baf72",
- "intercom_user_id": "5c9aabdf2ddf20549a41453a",
- "user_id": "12",
- "email": "[email protected]",
- "metadata": {},
- "created_at": 1391691571,
- "ext_metadata": {}
- }
- },
- "links": {},
- "id": "notif_da25b9d8-797b-4858-ac4a-4a2e9bbecee4",
- "topic": "event.created",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553642228,
- "created_at": 1553642228,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/user_created.json b/zerver/webhooks/intercom/fixtures/user_created.json
deleted file mode 100644
index 64bbc4da3c3..00000000000
--- a/zerver/webhooks/intercom/fixtures/user_created.json
+++ /dev/null
@@ -1,74 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "user",
- "id": "5c9ab3e78cd7330140ce5033",
- "user_id": "25",
- "anonymous": false,
- "email": "[email protected]",
- "phone": "2345570987",
- "name": "Aaron Smith",
- "pseudonym": null,
- "avatar": {
- "type": "avatar",
- "image_url": null
- },
- "app_id": "i6wc9ipe",
- "companies": {
- "type": "company.list",
- "companies": [
- {
- "type": "company",
- "company_id": "366",
- "id": "5c9ab3e78cd7330140ce5034",
- "name": "Zulip"
- }
- ]
- },
- "location_data": {},
- "last_request_at": null,
- "created_at": "2019-03-26T23:21:11.907+00:00",
- "remote_created_at": "2014-02-18T13:48:51.000+00:00",
- "signed_up_at": "2014-02-18T13:48:51.000+00:00",
- "updated_at": "2019-03-26T23:21:11.904+00:00",
- "session_count": 0,
- "social_profiles": {
- "type": "social_profile.list",
- "social_profiles": []
- },
- "unsubscribed_from_emails": false,
- "marked_email_as_spam": false,
- "has_hard_bounced": false,
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "segments": {
- "type": "segment.list",
- "segments": []
- },
- "custom_attributes": {},
- "referrer": null,
- "utm_campaign": null,
- "utm_content": null,
- "utm_medium": null,
- "utm_source": null,
- "utm_term": null,
- "do_not_track": null,
- "last_seen_ip": null,
- "user_agent_data": null
- }
- },
- "links": {},
- "id": "notif_61f436a9-6a2e-4f9b-9e85-68043477da63",
- "topic": "user.created",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553642472,
- "created_at": 1553642471,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/user_deleted.json b/zerver/webhooks/intercom/fixtures/user_deleted.json
deleted file mode 100644
index 483e95188bd..00000000000
--- a/zerver/webhooks/intercom/fixtures/user_deleted.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "user",
- "id": "5c9553cb27e377f24eed49f7",
- "user_id": "75067020-1204-495c-8edc-abb7d88bdd43",
- "email": "[email protected]"
- }
- },
- "links": {},
- "id": "notif_03e00e17-30d8-4c8a-91a4-6486a3df66e0",
- "topic": "user.deleted",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553379090,
- "created_at": 1553379090,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/user_email_updated.json b/zerver/webhooks/intercom/fixtures/user_email_updated.json
deleted file mode 100644
index 75ed9df2a5e..00000000000
--- a/zerver/webhooks/intercom/fixtures/user_email_updated.json
+++ /dev/null
@@ -1,78 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "contact",
- "id": "5c96b122177026171b401e20",
- "user_id": "8f9ef493-c5f9-4817-895d-874c3704ea49",
- "anonymous": true,
- "email": "[email protected]",
- "phone": null,
- "name": null,
- "pseudonym": "Azure Bus from St. John's",
- "avatar": {
- "type": "avatar",
- "image_url": "https://static.intercomassets.com/app/pseudonym_avatars_2019/azure-bus.png"
- },
- "app_id": "i6wc9ipe",
- "companies": {
- "type": "company.list",
- "companies": []
- },
- "location_data": {
- "type": "location_data",
- "city_name": "St. John's",
- "continent_code": "NA",
- "country_name": "Canada",
- "postal_code": "A1B",
- "region_name": "Newfoundland and Labrador",
- "timezone": "America/St_Johns",
- "country_code": "CAN",
- "latitude": null,
- "longitude": null
- },
- "last_request_at": "2019-03-23T22:20:52.453+00:00",
- "created_at": "2019-03-23T22:20:18.253+00:00",
- "remote_created_at": null,
- "signed_up_at": null,
- "updated_at": "2019-03-23T22:20:59.490+00:00",
- "session_count": 0,
- "social_profiles": {
- "type": "social_profile.list",
- "social_profiles": []
- },
- "unsubscribed_from_emails": false,
- "marked_email_as_spam": false,
- "has_hard_bounced": false,
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "segments": {
- "type": "segment.list",
- "segments": []
- },
- "custom_attributes": {},
- "referrer": null,
- "utm_campaign": null,
- "utm_content": null,
- "utm_medium": null,
- "utm_source": null,
- "utm_term": null,
- "do_not_track": null,
- "last_seen_ip": null,
- "user_agent_data": null
- }
- },
- "links": {},
- "id": "notif_687f7dfc-afd2-48ce-b31a-7a087d2ebf71",
- "topic": "user.email.updated",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553379706,
- "created_at": 1553379706,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/user_tag_created.json b/zerver/webhooks/intercom/fixtures/user_tag_created.json
deleted file mode 100644
index ce15d983973..00000000000
--- a/zerver/webhooks/intercom/fixtures/user_tag_created.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "user_tag",
- "user": {
- "type": "user",
- "id": "5c9aabdf2ddf20549a41453a",
- "user_id": "12",
- "anonymous": false,
- "email": "[email protected]",
- "phone": null,
- "name": "eeshangarg",
- "pseudonym": null,
- "avatar": {
- "type": "avatar",
- "image_url": "https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
- },
- "app_id": "i6wc9ipe",
- "companies": {
- "type": "company.list",
- "companies": []
- },
- "location_data": {},
- "last_request_at": null,
- "created_at": "2019-03-26T22:46:55.851+00:00",
- "remote_created_at": "2019-03-03T00:00:00.000+00:00",
- "signed_up_at": "2019-03-03T00:00:00.000+00:00",
- "updated_at": "2019-03-26T22:46:56.045+00:00",
- "session_count": 0,
- "social_profiles": {
- "type": "social_profile.list",
- "social_profiles": [
- {
- "type": "social_profile",
- "name": "github",
- "id": null,
- "username": "eeshangarg",
- "url": "https://github.com/eeshangarg"
- }
- ]
- },
- "unsubscribed_from_emails": false,
- "marked_email_as_spam": false,
- "has_hard_bounced": false,
- "tags": {
- "type": "tag.list",
- "tags": [
- {
- "type": "tag",
- "id": "2525085"
- }
- ]
- },
- "segments": {
- "type": "segment.list",
- "segments": []
- },
- "custom_attributes": {},
- "referrer": null,
- "utm_campaign": null,
- "utm_content": null,
- "utm_medium": null,
- "utm_source": null,
- "utm_term": null,
- "do_not_track": null,
- "last_seen_ip": null,
- "user_agent_data": null
- },
- "tag": {
- "type": "tag",
- "id": "2525085",
- "name": "developer"
- },
- "created_at": 1553640416,
- "admin": {
- "type": "admin"
- }
- }
- },
- "links": {},
- "id": "notif_800ae4f0-e326-41e7-a4e9-c4e7a97d45f4",
- "topic": "user.tag.created",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553640416,
- "created_at": 1553640416,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/user_tag_deleted.json b/zerver/webhooks/intercom/fixtures/user_tag_deleted.json
deleted file mode 100644
index 3e0c9b3dc19..00000000000
--- a/zerver/webhooks/intercom/fixtures/user_tag_deleted.json
+++ /dev/null
@@ -1,92 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "user_tag",
- "user": {
- "type": "user",
- "id": "5c9aabdf2ddf20549a41453a",
- "user_id": "12",
- "anonymous": false,
- "email": "[email protected]",
- "phone": null,
- "name": "eeshangarg",
- "pseudonym": null,
- "avatar": {
- "type": "avatar",
- "image_url": "https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
- },
- "app_id": "i6wc9ipe",
- "companies": {
- "type": "company.list",
- "companies": []
- },
- "location_data": {},
- "last_request_at": null,
- "created_at": "2019-03-26T22:46:55.851+00:00",
- "remote_created_at": "2019-03-03T00:00:00.000+00:00",
- "signed_up_at": "2019-03-03T00:00:00.000+00:00",
- "updated_at": "2019-03-26T22:48:23.743+00:00",
- "session_count": 0,
- "social_profiles": {
- "type": "social_profile.list",
- "social_profiles": [
- {
- "type": "social_profile",
- "name": "github",
- "id": null,
- "username": "eeshangarg",
- "url": "https://github.com/eeshangarg"
- }
- ]
- },
- "unsubscribed_from_emails": false,
- "marked_email_as_spam": false,
- "has_hard_bounced": false,
- "tags": {
- "type": "tag.list",
- "tags": [
- {
- "type": "tag",
- "id": "2525085"
- }
- ]
- },
- "segments": {
- "type": "segment.list",
- "segments": []
- },
- "custom_attributes": {},
- "referrer": null,
- "utm_campaign": null,
- "utm_content": null,
- "utm_medium": null,
- "utm_source": null,
- "utm_term": null,
- "do_not_track": null,
- "last_seen_ip": null,
- "user_agent_data": null
- },
- "tag": {
- "type": "tag",
- "id": "2535149",
- "name": "CSV Import - 2019-03-26 22:46:04 UTC"
- },
- "created_at": 1553640503,
- "admin": {
- "type": "admin"
- }
- }
- },
- "links": {},
- "id": "notif_89864fe7-ef26-4b32-b410-160871aa7fb9",
- "topic": "user.tag.deleted",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553640503,
- "created_at": 1553640503,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/fixtures/user_unsubscribed.json b/zerver/webhooks/intercom/fixtures/user_unsubscribed.json
deleted file mode 100644
index b2c0b7c5745..00000000000
--- a/zerver/webhooks/intercom/fixtures/user_unsubscribed.json
+++ /dev/null
@@ -1,93 +0,0 @@
-{
- "type": "notification_event",
- "app_id": "i6wc9ipe",
- "data": {
- "type": "notification_event_data",
- "item": {
- "type": "contact",
- "id": "5c96b122177026171b401e20",
- "user_id": "8f9ef493-c5f9-4817-895d-874c3704ea49",
- "anonymous": true,
- "email": "[email protected]",
- "phone": "+17982347588",
- "name": "Eeshan Garg",
- "pseudonym": "Azure Bus from St. John's",
- "avatar": {
- "type": "avatar",
- "image_url": "https://img.fullcontact.com/static/85ce413bcdac4cec3cfdb3a8da530f8b_8a853b478c3122d7e4ec9e14f81d9a3d9ea9da198d85c1985efc2403fa6bdb0c"
- },
- "app_id": "i6wc9ipe",
- "companies": {
- "type": "company.list",
- "companies": [
- {
- "type": "company",
- "company_id": "5c96b2c0d1c4c1a2d455b936-qualification-company",
- "id": "5c96b2c0d1c4c1a2d455b937",
- "name": "Kandra Labs"
- }
- ]
- },
- "location_data": {
- "type": "location_data",
- "city_name": "St. John's",
- "continent_code": "NA",
- "country_name": "Canada",
- "postal_code": "A1B",
- "region_name": "Newfoundland and Labrador",
- "timezone": "America/St_Johns",
- "country_code": "CAN",
- "latitude": null,
- "longitude": null
- },
- "last_request_at": "2019-03-23T22:20:52.453+00:00",
- "created_at": "2019-03-23T22:20:18.253+00:00",
- "remote_created_at": null,
- "signed_up_at": null,
- "updated_at": "2019-03-23T22:28:55.055+00:00",
- "session_count": 0,
- "social_profiles": {
- "type": "social_profile.list",
- "social_profiles": [
- {
- "type": "social_profile",
- "name": "github",
- "id": null,
- "username": "eeshangarg",
- "url": "https://github.com/eeshangarg"
- }
- ]
- },
- "unsubscribed_from_emails": true,
- "marked_email_as_spam": false,
- "has_hard_bounced": false,
- "tags": {
- "type": "tag.list",
- "tags": []
- },
- "segments": {
- "type": "segment.list",
- "segments": []
- },
- "custom_attributes": {},
- "referrer": null,
- "utm_campaign": null,
- "utm_content": null,
- "utm_medium": null,
- "utm_source": null,
- "utm_term": null,
- "do_not_track": null,
- "last_seen_ip": null,
- "user_agent_data": null
- }
- },
- "links": {},
- "id": "notif_71d6309c-0655-4793-86e5-19141d36642b",
- "topic": "user.unsubscribed",
- "delivery_status": "pending",
- "delivery_attempts": 1,
- "delivered_at": 0,
- "first_sent_at": 1553380135,
- "created_at": 1553380135,
- "self": null
-}
diff --git a/zerver/webhooks/intercom/tests.py b/zerver/webhooks/intercom/tests.py
index c1d5d0e3de0..f8bffef7a58 100644
--- a/zerver/webhooks/intercom/tests.py
+++ b/zerver/webhooks/intercom/tests.py
@@ -6,257 +6,3 @@ class IntercomWebHookTests(WebhookTestCase):
expected_topic_name = "Intercom"
expected_message = "Intercom webhook has been successfully configured."
self.check_webhook("ping", expected_topic_name, expected_message)
-
- def test_company_created(self) -> None:
- expected_topic_name = "Companies"
- expected_message = """
-New company **Kandra Labs** created:
-* **User count**: 1
-* **Monthly spending**: 0
-""".strip()
- self.check_webhook(
- "company_created",
- expected_topic_name,
- expected_message,
- )
-
- def test_contact_added_email(self) -> None:
- expected_topic_name = "Contact: Azure Bus from St. John's"
- expected_message = "New email [email protected] added to contact."
- self.check_webhook(
- "contact_added_email",
- expected_topic_name,
- expected_message,
- )
-
- def test_contact_created(self) -> None:
- expected_topic_name = "Contact: Azure Bus from St. John's"
- expected_message = """
-New contact created:
-* **Name (or pseudonym)**: Azure Bus from St. John's
-* **Email**: [email protected]
-* **Location**: St. John's, Newfoundland and Labrador, Canada
-""".strip()
- self.check_webhook(
- "contact_created",
- expected_topic_name,
- expected_message,
- )
-
- def test_contact_signed_up(self) -> None:
- expected_topic_name = "User: Lilac Raindrop from St. John's"
- expected_message = """
-Contact signed up:
-* **Email**: [email protected]
-* **Location**: St. John's, Newfoundland and Labrador, Canada
-""".strip()
- self.check_webhook(
- "contact_signed_up",
- expected_topic_name,
- expected_message,
- )
-
- def test_contact_tag_created(self) -> None:
- expected_topic_name = "Contact: Eeshan Garg"
- expected_message = "Contact tagged with the `developer` tag."
- self.check_webhook(
- "contact_tag_created",
- expected_topic_name,
- expected_message,
- )
-
- def test_contact_tag_deleted(self) -> None:
- expected_topic_name = "Contact: Eeshan Garg"
- expected_message = "The tag `developer` was removed from the contact."
- self.check_webhook(
- "contact_tag_deleted",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_admin_assigned(self) -> None:
- expected_topic_name = "Lead: Eeshan Garg"
- expected_message = "Tim Abbott assigned to conversation."
- self.check_webhook(
- "conversation_admin_assigned",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_admin_opened(self) -> None:
- expected_topic_name = "Lead: Cordelia, Lear's daughter"
- expected_message = "Eeshan Garg opened the conversation."
- self.check_webhook(
- "conversation_admin_opened",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_admin_closed(self) -> None:
- expected_topic_name = "Lead: Eeshan Garg"
- expected_message = "Cordelia, Lear's daughter closed the conversation."
- self.check_webhook(
- "conversation_admin_closed",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_admin_snoozed(self) -> None:
- expected_topic_name = "Lead: Eeshan Garg"
- expected_message = "Cordelia, Lear's daughter snoozed the conversation."
- self.check_webhook(
- "conversation_admin_snoozed",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_admin_unsnoozed(self) -> None:
- expected_topic_name = "Lead: Eeshan Garg"
- expected_message = "Cordelia, Lear's daughter unsnoozed the conversation."
- self.check_webhook(
- "conversation_admin_unsnoozed",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_admin_replied(self) -> None:
- expected_topic_name = "Lead: Eeshan Garg"
- expected_message = """
-Cordelia, Lear's daughter replied to the conversation:
-
-``` quote
-Hey Eeshan! How can I help?
-```
-""".strip()
- self.check_webhook(
- "conversation_admin_replied",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_admin_noted(self) -> None:
- expected_topic_name = "Lead: Eeshan Garg"
- expected_message = """
-Cordelia, Lear's daughter added a note to the conversation:
-
-``` quote
-Talk to Tim about this user's query.
-```
-""".strip()
- self.check_webhook(
- "conversation_admin_noted",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_admin_single_created(self) -> None:
- expected_topic_name = "Lead: Eeshan Garg"
- expected_message = """
-Cordelia, Lear's daughter initiated a conversation:
-
-``` quote
-Hi Eeshan, What's up
-```
-""".strip()
- self.check_webhook(
- "conversation_admin_single_created",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_user_created(self) -> None:
- expected_topic_name = "Lead: Rose Poodle from St. John's"
- expected_message = """
-Rose Poodle from St. John's initiated a conversation:
-
-``` quote
-Hello everyone!
-```
-""".strip()
- self.check_webhook(
- "conversation_user_created",
- expected_topic_name,
- expected_message,
- )
-
- def test_conversation_user_replied(self) -> None:
- expected_topic_name = "Lead: Eeshan Garg"
- expected_message = """
-Eeshan Garg replied to the conversation:
-
-``` quote
-Well, I need some help getting access to a developer account.
-```
-""".strip()
- self.check_webhook(
- "conversation_user_replied",
- expected_topic_name,
- expected_message,
- )
-
- def test_event_created(self) -> None:
- expected_topic_name = "Events"
- expected_message = "New event **invited-friend** created."
- self.check_webhook(
- "event_created",
- expected_topic_name,
- expected_message,
- )
-
- def test_user_created(self) -> None:
- expected_topic_name = "User: Aaron Smith"
- expected_message = """
-New user created:
-* **Name**: Aaron Smith
-* **Email**: [email protected]
-""".strip()
-
- self.check_webhook(
- "user_created",
- expected_topic_name,
- expected_message,
- )
-
- def test_user_deleted(self) -> None:
- self.check_webhook(
- "user_deleted",
- "User deleted.",
- )
-
- def test_user_email_updated(self) -> None:
- self.check_webhook(
- "user_email_updated",
- "Contact: Azure Bus from St. John's",
- "User's email was updated to [email protected].",
- )
-
- def test_user_tag_created(self) -> None:
- self.check_webhook(
- "user_tag_created",
- "User: eeshangarg",
- "The tag `developer` was added to the user.",
- )
-
- def test_user_tag_deleted(self) -> None:
- expected_topic_name = "User: eeshangarg"
- expected_message = (
- "The tag `CSV Import - 2019-03-26 22:46:04 UTC` was removed from the user."
- )
-
- self.check_webhook(
- "user_tag_deleted",
- expected_topic_name,
- expected_message,
- )
-
- def test_user_unsubscribed(self) -> None:
- self.check_webhook(
- "user_unsubscribed",
- "Contact: Eeshan Garg",
- "User unsubscribed from emails.",
- )
-
- def test_success_on_http_head(self) -> None:
- result = self.client_head(self.url)
- self.assertEqual(result.status_code, 200)
diff --git a/zerver/webhooks/intercom/view.py b/zerver/webhooks/intercom/view.py
index c1af4669dfb..9ca2db7fa7d 100644
--- a/zerver/webhooks/intercom/view.py
+++ b/zerver/webhooks/intercom/view.py
@@ -1,294 +1,15 @@
from collections.abc import Callable
-from html.parser import HTMLParser
from django.http import HttpRequest, HttpResponse
-from typing_extensions import override
from zerver.decorator import return_success_on_head_request, webhook_view
from zerver.lib.exceptions import UnsupportedWebhookEventTypeError
-from zerver.lib.partial import partial
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_none_or, check_string
+from zerver.lib.validator import WildValue, check_string
from zerver.lib.webhooks.common import check_send_webhook_message, get_setup_webhook_message
from zerver.models import UserProfile
-COMPANY_CREATED = """
-New company **{name}** created:
-* **User count**: {user_count}
-* **Monthly spending**: {monthly_spend}
-""".strip()
-
-CONTACT_EMAIL_ADDED = "New email {email} added to contact."
-
-CONTACT_CREATED = """
-New contact created:
-* **Name (or pseudonym)**: {name}
-* **Email**: {email}
-* **Location**: {location_info}
-""".strip()
-
-CONTACT_SIGNED_UP = """
-Contact signed up:
-* **Email**: {email}
-* **Location**: {location_info}
-""".strip()
-
-CONTACT_TAG_CREATED = "Contact tagged with the `{name}` tag."
-
-CONTACT_TAG_DELETED = "The tag `{name}` was removed from the contact."
-
-CONVERSATION_ADMIN_ASSIGNED = "{name} assigned to conversation."
-
-CONVERSATION_ADMIN_TEMPLATE = "{admin_name} {action} the conversation."
-
-CONVERSATION_ADMIN_REPLY_TEMPLATE = """
-{admin_name} {action} the conversation:
-
-``` quote
-{content}
-```
-""".strip()
-
-CONVERSATION_ADMIN_INITIATED_CONVERSATION = """
-{admin_name} initiated a conversation:
-
-``` quote
-{content}
-```
-""".strip()
-
-EVENT_CREATED = "New event **{event_name}** created."
-
-USER_CREATED = """
-New user created:
-* **Name**: {name}
-* **Email**: {email}
-""".strip()
-
-
-class MLStripper(HTMLParser):
- def __init__(self) -> None:
- self.reset()
- self.strict = False
- self.convert_charrefs = True
- self.fed: list[str] = []
-
- @override
- def handle_data(self, d: str) -> None:
- self.fed.append(d)
-
- def get_data(self) -> str:
- return "".join(self.fed)
-
-
-def strip_tags(html: str) -> str:
- s = MLStripper()
- s.feed(html)
- return s.get_data()
-
-
-def get_topic_for_contacts(user: WildValue) -> str:
- topic_name = "{type}: {name}".format(
- type=user["type"].tame(check_string).capitalize(),
- name=user.get("name").tame(check_none_or(check_string))
- or user.get("pseudonym").tame(check_none_or(check_string))
- or user.get("email").tame(check_none_or(check_string)),
- )
-
- return topic_name
-
-
-def get_company_created_message(payload: WildValue) -> tuple[str, str]:
- body = COMPANY_CREATED.format(
- name=payload["data"]["item"]["name"].tame(check_string),
- user_count=payload["data"]["item"]["user_count"].tame(check_int),
- monthly_spend=payload["data"]["item"]["monthly_spend"].tame(check_int),
- )
- return ("Companies", body)
-
-
-def get_contact_added_email_message(payload: WildValue) -> tuple[str, str]:
- user = payload["data"]["item"]
- body = CONTACT_EMAIL_ADDED.format(email=user["email"].tame(check_string))
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
-
-def get_contact_created_message(payload: WildValue) -> tuple[str, str]:
- contact = payload["data"]["item"]
- body = CONTACT_CREATED.format(
- name=contact.get("name").tame(check_none_or(check_string))
- or contact.get("pseudonym").tame(check_none_or(check_string)),
- email=contact["email"].tame(check_string),
- location_info="{city_name}, {region_name}, {country_name}".format(
- city_name=contact["location_data"]["city_name"].tame(check_string),
- region_name=contact["location_data"]["region_name"].tame(check_string),
- country_name=contact["location_data"]["country_name"].tame(check_string),
- ),
- )
- topic_name = get_topic_for_contacts(contact)
- return (topic_name, body)
-
-
-def get_contact_signed_up_message(payload: WildValue) -> tuple[str, str]:
- contact = payload["data"]["item"]
- body = CONTACT_SIGNED_UP.format(
- email=contact["email"].tame(check_string),
- location_info="{city_name}, {region_name}, {country_name}".format(
- city_name=contact["location_data"]["city_name"].tame(check_string),
- region_name=contact["location_data"]["region_name"].tame(check_string),
- country_name=contact["location_data"]["country_name"].tame(check_string),
- ),
- )
- topic_name = get_topic_for_contacts(contact)
- return (topic_name, body)
-
-
-def get_contact_tag_created_message(payload: WildValue) -> tuple[str, str]:
- body = CONTACT_TAG_CREATED.format(
- name=payload["data"]["item"]["tag"]["name"].tame(check_string)
- )
- contact = payload["data"]["item"]["contact"]
- topic_name = get_topic_for_contacts(contact)
- return (topic_name, body)
-
-
-def get_contact_tag_deleted_message(payload: WildValue) -> tuple[str, str]:
- body = CONTACT_TAG_DELETED.format(
- name=payload["data"]["item"]["tag"]["name"].tame(check_string)
- )
- contact = payload["data"]["item"]["contact"]
- topic_name = get_topic_for_contacts(contact)
- return (topic_name, body)
-
-
-def get_conversation_admin_assigned_message(payload: WildValue) -> tuple[str, str]:
- body = CONVERSATION_ADMIN_ASSIGNED.format(
- name=payload["data"]["item"]["assignee"]["name"].tame(check_string)
- )
- user = payload["data"]["item"]["user"]
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
-
-def get_conversation_admin_message(
- action: str,
- payload: WildValue,
-) -> tuple[str, str]:
- assignee = payload["data"]["item"]["assignee"]
- user = payload["data"]["item"]["user"]
- body = CONVERSATION_ADMIN_TEMPLATE.format(
- admin_name=assignee.get("name").tame(check_none_or(check_string)),
- action=action,
- )
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
-
-def get_conversation_admin_reply_message(
- action: str,
- payload: WildValue,
-) -> tuple[str, str]:
- assignee = payload["data"]["item"]["assignee"]
- user = payload["data"]["item"]["user"]
- note = payload["data"]["item"]["conversation_parts"]["conversation_parts"][0]
- content = strip_tags(note["body"].tame(check_string))
- body = CONVERSATION_ADMIN_REPLY_TEMPLATE.format(
- admin_name=assignee.get("name").tame(check_none_or(check_string)),
- action=action,
- content=content,
- )
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
-
-def get_conversation_admin_single_created_message(payload: WildValue) -> tuple[str, str]:
- assignee = payload["data"]["item"]["assignee"]
- user = payload["data"]["item"]["user"]
- conversation_body = payload["data"]["item"]["conversation_message"]["body"].tame(check_string)
- content = strip_tags(conversation_body)
- body = CONVERSATION_ADMIN_INITIATED_CONVERSATION.format(
- admin_name=assignee.get("name").tame(check_none_or(check_string)),
- content=content,
- )
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
-
-def get_conversation_user_created_message(payload: WildValue) -> tuple[str, str]:
- user = payload["data"]["item"]["user"]
- conversation_body = payload["data"]["item"]["conversation_message"]["body"].tame(check_string)
- content = strip_tags(conversation_body)
- body = CONVERSATION_ADMIN_INITIATED_CONVERSATION.format(
- admin_name=user.get("name").tame(check_none_or(check_string)),
- content=content,
- )
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
-
-def get_conversation_user_replied_message(payload: WildValue) -> tuple[str, str]:
- user = payload["data"]["item"]["user"]
- note = payload["data"]["item"]["conversation_parts"]["conversation_parts"][0]
- content = strip_tags(note["body"].tame(check_string))
- body = CONVERSATION_ADMIN_REPLY_TEMPLATE.format(
- admin_name=user.get("name").tame(check_none_or(check_string)),
- action="replied to",
- content=content,
- )
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
-
-def get_event_created_message(payload: WildValue) -> tuple[str, str]:
- event = payload["data"]["item"]
- body = EVENT_CREATED.format(event_name=event["event_name"].tame(check_string))
- return ("Events", body)
-
-
-def get_user_created_message(payload: WildValue) -> tuple[str, str]:
- user = payload["data"]["item"]
- body = USER_CREATED.format(
- name=user["name"].tame(check_string), email=user["email"].tame(check_string)
- )
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
-
-def get_user_deleted_message(payload: WildValue) -> tuple[str, str]:
- user = payload["data"]["item"]
- topic_name = get_topic_for_contacts(user)
- return (topic_name, "User deleted.")
-
-
-def get_user_email_updated_message(payload: WildValue) -> tuple[str, str]:
- user = payload["data"]["item"]
- body = "User's email was updated to {}.".format(user["email"].tame(check_string))
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
-
-def get_user_tagged_message(
- action: str,
- payload: WildValue,
-) -> tuple[str, str]:
- user = payload["data"]["item"]["user"]
- tag = payload["data"]["item"]["tag"]
- topic_name = get_topic_for_contacts(user)
- body = "The tag `{tag_name}` was {action} the user.".format(
- tag_name=tag["name"].tame(check_string),
- action=action,
- )
- return (topic_name, body)
-
-
-def get_user_unsubscribed_message(payload: WildValue) -> tuple[str, str]:
- user = payload["data"]["item"]
- body = "User unsubscribed from emails."
- topic_name = get_topic_for_contacts(user)
- return (topic_name, body)
-
def get_ping_message(payload: WildValue) -> tuple[str, str]:
body = get_setup_webhook_message("Intercom")
@@ -297,33 +18,7 @@ def get_ping_message(payload: WildValue) -> tuple[str, str]:
EVENT_TO_FUNCTION_MAPPER: dict[str, Callable[[WildValue], tuple[str, str]]] = {
- "company.created": get_company_created_message,
- "contact.added_email": get_contact_added_email_message,
- "contact.created": get_contact_created_message,
- "contact.signed_up": get_contact_signed_up_message,
- "contact.tag.created": get_contact_tag_created_message,
- "contact.tag.deleted": get_contact_tag_deleted_message,
- "conversation.admin.assigned": get_conversation_admin_assigned_message,
- "conversation.admin.closed": partial(get_conversation_admin_message, "closed"),
- "conversation.admin.opened": partial(get_conversation_admin_message, "opened"),
- "conversation.admin.snoozed": partial(get_conversation_admin_message, "snoozed"),
- "conversation.admin.unsnoozed": partial(get_conversation_admin_message, "unsnoozed"),
- "conversation.admin.replied": partial(get_conversation_admin_reply_message, "replied to"),
- "conversation.admin.noted": partial(get_conversation_admin_reply_message, "added a note to"),
- "conversation.admin.single.created": get_conversation_admin_single_created_message,
- "conversation.user.created": get_conversation_user_created_message,
- "conversation.user.replied": get_conversation_user_replied_message,
- "event.created": get_event_created_message,
- "ping": get_ping_message,
- "user.created": get_user_created_message,
- "user.deleted": get_user_deleted_message,
- "user.email.updated": get_user_email_updated_message,
- "user.tag.created": partial(get_user_tagged_message, "added to"),
- "user.tag.deleted": partial(get_user_tagged_message, "removed from"),
- "user.unsubscribed": get_user_unsubscribed_message,
- # Note that we do not have a payload for visitor.signed_up
- # but it should be identical to contact.signed_up
- "visitor.signed_up": get_contact_signed_up_message,
+ "ping": get_ping_message
}
ALL_EVENT_TYPES = list(EVENT_TO_FUNCTION_MAPPER.keys())