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/opencollective/__init__.py
Normal file
0
zerver/webhooks/opencollective/__init__.py
Normal file
25
zerver/webhooks/opencollective/doc.md
Normal file
25
zerver/webhooks/opencollective/doc.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Zulip Open Collective integration
|
||||
|
||||
Get Zulip notifications for new sign-ups on your **Open Collective** page.
|
||||
|
||||
{start_tabs}
|
||||
|
||||
1. {!create-an-incoming-webhook.md!}
|
||||
|
||||
1. {!generate-webhook-url-basic.md!}
|
||||
|
||||
1. In Open Collective, navigate to one of the collectives under
|
||||
**My Collectives**. Go to **Settings** > **Webhooks**.
|
||||
|
||||
1. Set **URL** to the URL generated above, and choose **Activity** >
|
||||
**New Member**.
|
||||
|
||||
{end_tabs}
|
||||
|
||||
{!congrats.md!}
|
||||
|
||||

|
||||
|
||||
### Related documentation
|
||||
|
||||
{!webhooks-url-specification.md!}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"createdAt": "2021-06-21T17:25:24.344Z",
|
||||
"id": 1242511,
|
||||
"type": "collective.member.created",
|
||||
"CollectiveId": 281290,
|
||||
"data": {
|
||||
"member": {
|
||||
"role": "BACKER",
|
||||
"description": null,
|
||||
"since": "2021-06-21T17:25:24.332Z",
|
||||
"memberCollective": {
|
||||
"id": 280138,
|
||||
"type": "USER",
|
||||
"slug": "leyteris-kyriazanos",
|
||||
"name": "Λευτέρης Κυριαζάνος",
|
||||
"company": null,
|
||||
"website": null,
|
||||
"twitterHandle": null,
|
||||
"githubHandle": null,
|
||||
"description": null,
|
||||
"previewImage": null
|
||||
}
|
||||
},
|
||||
"order": {
|
||||
"id": 183773,
|
||||
"totalAmount": 100,
|
||||
"currency": "EUR",
|
||||
"description": "Financial contribution to Test-Webhooks",
|
||||
"interval": null,
|
||||
"createdAt": "2021-06-21T17:25:17.968Z",
|
||||
"quantity": 1,
|
||||
"formattedAmount": "€1.00",
|
||||
"formattedAmountWithInterval": "€1.00"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"createdAt": "2021-04-30T19:20:04.346Z",
|
||||
"id": 1121199,
|
||||
"type": "collective.member.created",
|
||||
"CollectiveId": 30312,
|
||||
"data": {
|
||||
"member": {
|
||||
"role": "BACKER",
|
||||
"description": null,
|
||||
"since": "2021-04-30T19:20:04.314Z",
|
||||
"memberCollective": {
|
||||
"type": "USER",
|
||||
"name": "Incognito",
|
||||
"previewImage": null
|
||||
}
|
||||
},
|
||||
"order": {
|
||||
"id": 168629,
|
||||
"totalAmount": 100,
|
||||
"currency": "USD",
|
||||
"description": "Monthly financial contribution to Zulip",
|
||||
"interval": "month",
|
||||
"createdAt": "2021-04-30T19:19:58.647Z",
|
||||
"quantity": 1,
|
||||
"formattedAmount": "$1.00",
|
||||
"formattedAmountWithInterval": "$1.00 / month"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
27
zerver/webhooks/opencollective/tests.py
Normal file
27
zerver/webhooks/opencollective/tests.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
|
||||
class OpenCollectiveHookTests(WebhookTestCase):
|
||||
# Note: Include a test function per each distinct message condition your integration supports
|
||||
def test_one_time_donation(self) -> None: # test one time donation
|
||||
expected_topic_name = "New Member"
|
||||
expected_message = "@_**Λευτέρης Κυριαζάνος** donated **€1.00**! :tada:"
|
||||
|
||||
self.check_webhook(
|
||||
"one_time_donation",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
|
||||
def test_one_time_incognito_donation(self) -> None: # test one time incognito donation
|
||||
expected_topic_name = "New Member"
|
||||
expected_message = "An **Incognito** member donated **$1.00**! :tada:"
|
||||
|
||||
# use fixture named helloworld_hello
|
||||
self.check_webhook(
|
||||
"one_time_incognito_donation",
|
||||
expected_topic_name,
|
||||
expected_message,
|
||||
content_type="application/x-www-form-urlencoded",
|
||||
)
|
||||
50
zerver/webhooks/opencollective/view.py
Normal file
50
zerver/webhooks/opencollective/view.py
Normal file
@@ -0,0 +1,50 @@
|
||||
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
|
||||
|
||||
MEMBER_NAME_TEMPLATE = "{name}"
|
||||
AMOUNT_TEMPLATE = "{amount}"
|
||||
|
||||
|
||||
@webhook_view("OpenCollective")
|
||||
@typed_endpoint
|
||||
def api_opencollective_webhook(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
*,
|
||||
payload: JsonBodyPayload[WildValue],
|
||||
) -> HttpResponse:
|
||||
name = get_name(payload)
|
||||
amount = get_amount(payload)
|
||||
|
||||
# construct the body of the message
|
||||
body = ""
|
||||
|
||||
if name == "Incognito": # Incognito donation
|
||||
body = f"An **Incognito** member donated **{amount}**! :tada:"
|
||||
else: # non-Incognito donation
|
||||
body = f"@_**{name}** donated **{amount}**! :tada:"
|
||||
|
||||
topic_name = "New Member"
|
||||
|
||||
# send the message
|
||||
check_send_webhook_message(request, user_profile, topic_name, body)
|
||||
|
||||
return json_success(request)
|
||||
|
||||
|
||||
def get_name(payload: WildValue) -> str:
|
||||
return MEMBER_NAME_TEMPLATE.format(
|
||||
name=payload["data"]["member"]["memberCollective"]["name"].tame(check_string)
|
||||
)
|
||||
|
||||
|
||||
def get_amount(payload: WildValue) -> str:
|
||||
return AMOUNT_TEMPLATE.format(
|
||||
amount=payload["data"]["order"]["formattedAmount"].tame(check_string)
|
||||
)
|
||||
Reference in New Issue
Block a user