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/mention/__init__.py
Normal file
0
zerver/webhooks/mention/__init__.py
Normal file
36
zerver/webhooks/mention/doc.md
Normal file
36
zerver/webhooks/mention/doc.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Zulip Mention integration
|
||||
|
||||
Get Mention notifications within Zulip via Zapier!
|
||||
|
||||
{start_tabs}
|
||||
|
||||
1. {!create-an-incoming-webhook.md!}
|
||||
|
||||
1. {!generate-webhook-url-basic.md!}
|
||||
|
||||
1. Go to your Mention feed, and click on your profile in the top-right
|
||||
corner. Select **Settings**, click on **Integrations**, and select
|
||||
the **Zapier** integration.
|
||||
|
||||
1. Click **Explore Mention on Zapier**. Search for "webhooks" in
|
||||
the search bar, and click on **Webhooks by Zapier**. Look for
|
||||
**Add Webhook posts for new Mentions**, and click on
|
||||
**Use this Zap**. Click **Create this Zap**.
|
||||
|
||||
1. Follow the on-screen steps to link your Mention account to Zapier.
|
||||
Select your Mention **Account ID** and **Alert** when prompted.
|
||||
|
||||
1. Follow the on-screen steps to set up **Webhooks by Zapier POST**.
|
||||
When prompted, set **URL** to the URL generated above, and set
|
||||
**Payload Type** to **JSON**. After **Test this Step**, click
|
||||
**Finish**.
|
||||
|
||||
{end_tabs}
|
||||
|
||||
{!congrats.md!}
|
||||
|
||||

|
||||
|
||||
### Related documentation
|
||||
|
||||
{!webhooks-url-specification.md!}
|
||||
65
zerver/webhooks/mention/fixtures/webfeeds.json
Normal file
65
zerver/webhooks/mention/fixtures/webfeeds.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"tasks": "",
|
||||
"tone": "0",
|
||||
"relevance_score": "1",
|
||||
"domain_reach": "13600",
|
||||
"updated_at": "2016-12-01T21:20:47.0+00:00",
|
||||
"published_at": "2016-12-01T21:20:46.22619100+00:00",
|
||||
"language_code": "en",
|
||||
"tone_score": "0.529054",
|
||||
"source_name": "theyworkforyou.com",
|
||||
"children": "",
|
||||
"logs": "",
|
||||
"display_site": "True",
|
||||
"title": "Travel Industry Sees Surge in Eco-Tourism (Travel): 29 Nov 2024: Global Tourism - TheyWorkForYou",
|
||||
"tags": "",
|
||||
"id": "121983065969",
|
||||
"description_short": "\u2026 Child sex abuse is an exceptionally vile crime, and all of Government take it very \u2026",
|
||||
"trashed": "False",
|
||||
"description": "\u2026 Tourism, Culture and Heritage\nMore travelers prioritize environmental sustainability, driving growth in eco-friendly accommodations and activities. Popular destinations include Costa Rica and \u2026",
|
||||
"offsets": {
|
||||
"source_name": "",
|
||||
"description": "122,122,5,5",
|
||||
"title": "",
|
||||
"url": "",
|
||||
"source_url": "",
|
||||
"description_medium": "89,89,5,5",
|
||||
"description_short": "43,43,5,5"
|
||||
},
|
||||
"read": "False",
|
||||
"source_url": "https:\/\/theyworkforyou.com",
|
||||
"author_influence": {
|
||||
"kind": "web",
|
||||
"name": "theyworkforyou.com",
|
||||
"scored_id": "theyworkforyou.com",
|
||||
"url": "https:\/\/theyworkforyou.com",
|
||||
"alert_id": "1380332",
|
||||
"score": "49",
|
||||
"author_unique_id": "theyworkforyou.com",
|
||||
"id": "44169449220"
|
||||
},
|
||||
"important": "False",
|
||||
"_zap_data_last_live_poll": "1480628636",
|
||||
"permissions": {
|
||||
"share_email": "True",
|
||||
"edit": "True",
|
||||
"create_task": "True",
|
||||
"favorite": "True",
|
||||
"share_facebook": "True",
|
||||
"trash": "True",
|
||||
"private_message_reply": "False",
|
||||
"share_buffer": "True"
|
||||
},
|
||||
"alert_id": "1380332",
|
||||
"source_type": "web",
|
||||
"_zap_data_was_live": "True",
|
||||
"_c": "r",
|
||||
"created_at": "2016-12-01T21:20:47.0+00:00",
|
||||
"favorite": "False",
|
||||
"trashed_set_by_user": "False",
|
||||
"_zap_data_was_cached": "True",
|
||||
"url": "https:\/\/www.theyworkforyou.com\/debates\/?id=2016-11-29b.1398.7&p=24887",
|
||||
"description_medium": "\u2026 is more important than keeping children safe. Child sex abuse is an exceptionally vile crime, and all of Government take it very seriously indeed, as I know this House does.\nChildren \u2026",
|
||||
"country": "GB",
|
||||
"unique_id": "https:\/\/www.theyworkforyou.com\/debates\/?id=2016-11-29b.1398.7&p=24887"
|
||||
}
|
||||
21
zerver/webhooks/mention/tests.py
Normal file
21
zerver/webhooks/mention/tests.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
|
||||
class MentionHookTests(WebhookTestCase):
|
||||
def test_mention_webfeed(self) -> None:
|
||||
expected_topic_name = "news"
|
||||
expected_message = """
|
||||
**[Travel Industry Sees Surge in Eco-Tourism (Travel): 29 Nov 2024: Global Tourism - TheyWorkForYou](https://www.theyworkforyou.com/debates/?id=2016-11-29b.1398.7&p=24887)**:
|
||||
|
||||
``` quote
|
||||
\u2026 Tourism, Culture and Heritage\nMore travelers prioritize environmental sustainability, driving growth in eco-friendly accommodations and activities. Popular destinations include Costa Rica and \u2026
|
||||
```
|
||||
""".strip()
|
||||
|
||||
# use fixture named mention_webfeeds
|
||||
self.check_webhook(
|
||||
"webfeeds",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
37
zerver/webhooks/mention/view.py
Normal file
37
zerver/webhooks/mention/view.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# Webhooks for external integrations.
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import webhook_view
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.typed_endpoint import JsonBodyPayload, typed_endpoint
|
||||
from zerver.lib.validator import WildValue, check_string
|
||||
from zerver.lib.webhooks.common import check_send_webhook_message
|
||||
from zerver.models import UserProfile
|
||||
|
||||
|
||||
@webhook_view("Mention")
|
||||
@typed_endpoint
|
||||
def api_mention_webhook(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
*,
|
||||
payload: JsonBodyPayload[WildValue],
|
||||
) -> HttpResponse:
|
||||
title = payload["title"].tame(check_string)
|
||||
source_url = payload["url"].tame(check_string)
|
||||
description = payload["description"].tame(check_string)
|
||||
# construct the body of the message
|
||||
template = """
|
||||
**[{title}]({url})**:
|
||||
|
||||
``` quote
|
||||
{description}
|
||||
```
|
||||
""".strip()
|
||||
body = template.format(title=title, url=source_url, description=description)
|
||||
topic_name = "news"
|
||||
|
||||
# send the message
|
||||
check_send_webhook_message(request, user_profile, topic_name, body)
|
||||
|
||||
return json_success(request)
|
||||
Reference in New Issue
Block a user