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.

integration: Add wekan integration.

Israel Ebonko1f286ab28326
diff --git a/static/images/integrations/bot_avatars/wekan.png b/static/images/integrations/bot_avatars/wekan.png
new file mode 100644
index 00000000000..f3e1f7af521
Binary files /dev/null and b/static/images/integrations/bot_avatars/wekan.png differ
diff --git a/static/images/integrations/logos/wekan.svg b/static/images/integrations/logos/wekan.svg
new file mode 100644
index 00000000000..1789ed57d4e
--- /dev/null
+++ b/static/images/integrations/logos/wekan.svg
@@ -0,0 +1 @@
+<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 302.5 210.37"><defs><linearGradient id="linear-gradient" x1="-716.13" y1="35.06" x2="-715.13" y2="35.06" gradientTransform="matrix(0 -157.69 -157.69 0 5678.87 -112746.33)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#007c8f"/><stop offset=".37" stop-color="#007088"/><stop offset="1" stop-color="#005377"/></linearGradient><clipPath id="clip-path"><path d="M260.63 180.45H39.9c-7 0-9-2.27-9-9V31.71c0-6.81 2.1-9 9-9h220.73c6.8 0 9 2.13 9 9v139.74c0 6.57-2.08 9-9 9" style="fill:none"/></clipPath><style>.cls-6{fill:#fff}</style></defs><g style="clip-path:url(#clip-path)"><path style="fill:url(#linear-gradient)" d="M30.9 22.76h238.73v157.69H30.9z"/><path d="M225.06 138.25v-.54h-149a2.5 2.5 0 0 1-2.5-2.5v-69a2.5 2.5 0 0 1 2.5-2.5h149a2.5 2.5 0 0 1 2.5 2.5v69.07a2.5 2.5 0 0 1-2.5 2.5v1a3.5 3.5 0 0 0 3.5-3.5v-69.1a3.5 3.5 0 0 0-3.5-3.5h-149a3.5 3.5 0 0 0-3.5 3.5v69.07a3.5 3.5 0 0 0 3.5 3.5h149z" style="fill:#7addfc"/><path d="M143.05 55.9v-.5H75.93a2.5 2.5 0 0 1-2.5-2.5V3.5a2.5 2.5 0 0 1 2.5-2.5h67.12a2.5 2.5 0 0 1 2.5 2.5v49.4a2.5 2.5 0 0 1-2.5 2.5v1a3.5 3.5 0 0 0 3.5-3.5V3.5a3.5 3.5 0 0 0-3.5-3.5H75.93a3.5 3.5 0 0 0-3.5 3.5v49.4a3.5 3.5 0 0 0 3.5 3.5h67.12zm0 145.02v-.5H75.93a2.5 2.5 0 0 1-2.5-2.5v-49.4a2.5 2.5 0 0 1 2.5-2.5h67.12a2.5 2.5 0 0 1 2.5 2.5v49.4a2.5 2.5 0 0 1-2.5 2.5v1a3.5 3.5 0 0 0 3.5-3.5v-49.4a3.5 3.5 0 0 0-3.5-3.5H75.93a3.5 3.5 0 0 0-3.5 3.5v49.4a3.5 3.5 0 0 0 3.5 3.5h67.12zM224.43 55.9v-.5h-67.11a2.5 2.5 0 0 1-2.5-2.5V3.5a2.5 2.5 0 0 1 2.5-2.5h67.12a2.5 2.5 0 0 1 2.5 2.5v49.4a2.5 2.5 0 0 1-2.5 2.5v1a3.5 3.5 0 0 0 3.5-3.5V3.5a3.5 3.5 0 0 0-3.5-3.5h-67.12a3.5 3.5 0 0 0-3.5 3.5v49.4a3.5 3.5 0 0 0 3.5 3.5h67.12zm0 145.02v-.5h-67.11a2.5 2.5 0 0 1-2.5-2.5v-49.4a2.5 2.5 0 0 1 2.5-2.5h67.12a2.5 2.5 0 0 1 2.5 2.5v49.4a2.5 2.5 0 0 1-2.5 2.5v1a3.5 3.5 0 0 0 3.5-3.5v-49.4a3.5 3.5 0 0 0-3.5-3.5h-67.12a3.5 3.5 0 0 0-3.5 3.5v49.4a3.5 3.5 0 0 0 3.5 3.5h67.12zM299 94.93v-.5h-60.84a2.5 2.5 0 0 1-2.5-2.5V5.08a2.5 2.5 0 0 1 2.5-2.5H299a2.5 2.5 0 0 1 2.5 2.5v86.85a2.5 2.5 0 0 1-2.5 2.5v1a3.5 3.5 0 0 0 3.5-3.5V5.08a3.5 3.5 0 0 0-3.5-3.5h-60.84a3.5 3.5 0 0 0-3.5 3.5v86.85a3.5 3.5 0 0 0 3.5 3.5H299zm0 114.94v-.5h-60.84a2.5 2.5 0 0 1-2.5-2.5V105.18a2.5 2.5 0 0 1 2.5-2.5H299a2.5 2.5 0 0 1 2.5 2.5v101.69a2.5 2.5 0 0 1-2.5 2.5v1a3.5 3.5 0 0 0 3.5-3.5V105.18a3.5 3.5 0 0 0-3.5-3.5h-60.84a3.5 3.5 0 0 0-3.5 3.5v101.69a3.5 3.5 0 0 0 3.5 3.5H299zM63 94.93v-.5H3.5a2.5 2.5 0 0 1-2.5-2.5V5.08a2.5 2.5 0 0 1 2.5-2.5H63a2.5 2.5 0 0 1 2.5 2.5v86.85a2.5 2.5 0 0 1-2.5 2.5v1a3.5 3.5 0 0 0 3.5-3.5V5.08a3.5 3.5 0 0 0-3.5-3.5H3.5A3.5 3.5 0 0 0 0 5.08v86.85a3.5 3.5 0 0 0 3.5 3.5H63zm0 114.94v-.5H3.5a2.5 2.5 0 0 1-2.5-2.5V105.18a2.5 2.5 0 0 1 2.5-2.5H63a2.5 2.5 0 0 1 2.5 2.5v101.69a2.5 2.5 0 0 1-2.5 2.5v1a3.5 3.5 0 0 0 3.5-3.5V105.18a3.5 3.5 0 0 0-3.5-3.5H3.5a3.5 3.5 0 0 0-3.5 3.5v101.69a3.5 3.5 0 0 0 3.5 3.5H63z" style="fill:#529fdd"/><path class="cls-6" d="M208.62 108.44a1.51 1.51 0 0 0-.83.33q-3.12 8.16-4.95 7.92c-.35 0-.56-.37-.58-1a10.31 10.31 0 0 1 .31-2.53c.23-1.06.5-2.12.78-3.19s.56-2.28.89-3.61.6-2.38.75-3.14a1.15 1.15 0 0 0-.47-1.28 2.48 2.48 0 0 0-1.89-.06c-3.55.79-6.33 3.92-8.31 9.36q.92-6.36 1.14-7.17c.25-1.11.45-1.82.56-2.14a9.13 9.13 0 0 0-1.81-.11 17.39 17.39 0 0 0-3.45.33c-1.27.24-1.93.54-2 .92-.22 1.92-.24 3.93-.44 5.92s-.32 3.69-.44 5.31a10.85 10.85 0 0 1-1.25 1.69c-.53.55-1 .81-1.42.75-1-.16-.37-3 1.53-8.64 1.45-4.33.71-6.16-5.22-6.2a10.64 10.64 0 0 0-5.47 1.67 12.27 12.27 0 0 0-5.33 7c-.09.31-.16.6-.22.89a13.11 13.11 0 0 1-.83 1.36 6.94 6.94 0 0 1-1.64 1.94 1.67 1.67 0 0 1-1.14.33c-1-.16-2.28-1-3.7-2.58-1-1.09-2.86-3-3.78-4.14 5.64-10.17 20.73-12.5 25.06-12.5 1.36 0 1.41-6.25 0-6.25-17.55 0-25.36 14.85-27.09 20 .15-1.65.27-2.71.5-4.86s.4-3.85.53-5.11.26-2.73.42-4.36.32-2.91.42-3.86.23-2 .36-3.11.23-2 .33-2.69l.31-1.94c.1-.65.18-1.19.28-1.58a.94.94 0 0 0-.69-1.31 5 5 0 0 0-.94-.06 1.87 1.87 0 0 0-.9.26 1.92 1.92 0 0 0-.69.94q-3.71 8.75-6.14 27.17a13.62 13.62 0 0 1-4.25 6 7.65 7.65 0 0 1-5.33 1.86 3.36 3.36 0 0 1-2.83-2.42 9.53 9.53 0 0 1-.19-5.47c.86-4.11 2-6.17 3.33-6.17.91 0 .95 1.54.08 4.64-.66 2.21-1.58 3.69-2.75 4.42-.41.25-.58.46-.53.58s.36.19.92 0a19.09 19.09 0 0 0 5.56-2.31 6.17 6.17 0 0 0 3-3.28 3.08 3.08 0 0 0-1.27-3.25 7.24 7.24 0 0 0-4.33-1.53 11.24 11.24 0 0 0-5.08 1l.11-.19a47.7 47.7 0 0 0 5.75-12q1.73-5.68-.94-8.33a6.8 6.8 0 0 0-2.92-1.25c-2.45-.66-5.21-1.51-3.08 1.25a5.29 5.29 0 0 1 .67 1.61 16.42 16.42 0 0 1-.47 7.47 53.89 53.89 0 0 1-3.42 9.56 56.47 56.47 0 0 1-5 8.83 18.25 18.25 0 0 1-5.25 5.36 3 3 0 0 1-.08-.67 14.41 14.41 0 0 1 0-1.61 9.22 9.22 0 0 1 .11-1.25q.59-3.9 1.5-8.28c.61-2.92 1.21-5.55 1.78-7.92.41-1.49.67-2.61.81-3.33a1.91 1.91 0 0 0-.25-1.61 5 5 0 0 0-1.69-1.22c-.53-.27-1.19-.62-2-1.08-1.65-1-1.76-.93-2.22.75s-1.31 3.68-2.44 6.56-2.38 5.88-3.76 8.94a79 79 0 0 1-4 7.83c-1.27 2.14-2.3 3.24-3.08 3.28a.4.4 0 0 1-.33-.33 2.94 2.94 0 0 1-.08-.72 12.34 12.34 0 0 1 .14-1.61 10.63 10.63 0 0 1 .25-1.25c.35-1.74.83-3.78 1.44-6.14s1.24-4.72 1.89-7 1.19-4.25 1.64-5.83a26 26 0 0 0 1.14-4.06 1.71 1.71 0 0 0-1.11-1.72c-.66-.35-1.68-1-3.11-1.81a2.42 2.42 0 0 0-2.56-.19c-2.66 1-5.33 2.1-8.06 3.39a68.72 68.72 0 0 0-8.39 4.67c-2.39 1.59-3.91 3-4.58 4.31a4.85 4.85 0 0 0 .25 4.78 6.87 6.87 0 0 0 2 2.22c3.24 2.23 2.16.94 2.47-1.64a6.51 6.51 0 0 1 .92-2.64 23.82 23.82 0 0 1 6-6.22 39.51 39.51 0 0 1 9.7-5.58c-.65 2.39-1.34 5-2.08 7.78s-1.46 5.52-2.08 8.11-1.09 4.78-1.39 6.53a10.14 10.14 0 0 0-.22 2.39 4.53 4.53 0 0 0 .88 2.23 6.42 6.42 0 0 0 1.92 1.75 4.29 4.29 0 0 0 2.33.69c1.68-.1 3.32-1.23 4.89-3.36a40.09 40.09 0 0 0 4.36-7.81q2-4.62 3.5-9c-.49 2.37-.94 4.71-1.33 7s-.67 4.33-.86 6.08a11.93 11.93 0 0 0-.08 2.39 4.48 4.48 0 0 0 1 2.28 6.61 6.61 0 0 0 2 1.72 5.7 5.7 0 0 0 2.45.72q2.48 0 6.78-4.42c.7-.71 1.39-1.46 2.08-2.25a5.34 5.34 0 0 0 2.11 4.92 11.11 11.11 0 0 0 6.56 2.25 11 11 0 0 0 7.67-2.69 14.82 14.82 0 0 0 3.06-3.5 19.67 19.67 0 0 0-.17 5.14c0 .25.56.48 1.75.64a21.92 21.92 0 0 0 3.53.17c1.14 0 1.72-.14 1.72-.33-.1-.69-.21-2.2-.3-3.83 2.38 2.53 5.24 4.38 7.42 4.22 1.27-.09 2.8-1.09 4.53-3.06a16.66 16.66 0 0 0 1.08-1.56 4.58 4.58 0 0 0 1.14 2.42 5.15 5.15 0 0 0 4.39 1.89c1.74-.18 3.1-1.57 4.14-4.19a18.21 18.21 0 0 1 1.11-2.42c.67-1.09.52-.37.42.14-.33 1.67-.72 4 .33 5.47a2.64 2.64 0 0 0 2.5 1.33c1-.14 2.16-1 3.42-2.61a5.18 5.18 0 0 0 0 1.47c.1.25.62.47 1.61.61a16.1 16.1 0 0 0 2.86.17c.91 0 1.36-.14 1.36-.33.8-3.5 1.42-6.5 4.28-10.25h.17a.75.75 0 0 1 0 .42 4 4 0 0 1-.14.69c-.05.25-.15.61-.28 1.08s-.23.92-.33 1.33a9.37 9.37 0 0 0-.31 3.61 6.53 6.53 0 0 0 .72 2.28 2.8 2.8 0 0 0 1.33 1.19 4.69 4.69 0 0 0 1.56.42 6 6 0 0 0 1.47-.11c1.17-.25 2.4-1.29 3.69-3.14a23.3 23.3 0 0 0 3.12-6.47v-.08c.08-.15-.04-.22-.3-.19zM180 110.19q-1.81 6-2.81 6c-.46-.06-.63-.57-.53-1.56a30.82 30.82 0 0 1 1.05-4.64c.41-1.33.78-2.43 1.08-3.25s.58-1.53.89-2.17a4.77 4.77 0 0 1 .89-1.33 1.09 1.09 0 0 1 .69-.28.45.45 0 0 1 .5.39v.11a22.08 22.08 0 0 1-1.19 5 15.2 15.2 0 0 0-.57 1.73z"/><rect class="cls-6" x="188.92" y="89.51" width="6.26" height="6.26" rx=".88"/><rect class="cls-6" x="198.58" y="91.85" width="7.67" height="7.67" rx="1.08"/><rect class="cls-6" x="207.5" y="82.3" width="9.08" height="9.08" rx="1.28"/></g></svg>
\ No newline at end of file
diff --git a/static/images/integrations/wekan/001.png b/static/images/integrations/wekan/001.png
new file mode 100644
index 00000000000..faca59863c6
Binary files /dev/null and b/static/images/integrations/wekan/001.png differ
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index 88407d34fa1..3bf7eed77c5 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -464,6 +464,7 @@ WEBHOOK_INTEGRATIONS: List[WebhookIntegration] = [
function="zerver.webhooks.yo.view.api_yo_app_webhook",
display_name="Yo",
),
+ WebhookIntegration("wekan", ["productivity"], display_name="Wekan"),
WebhookIntegration("wordpress", ["marketing"], display_name="WordPress"),
WebhookIntegration("zapier", ["meta-integration"]),
WebhookIntegration("zendesk", ["customer-support"]),
@@ -806,6 +807,7 @@ DOC_SCREENSHOT_CONFIG: Dict[str, List[BaseScreenshotConfig]] = {
"trello": [ScreenshotConfig("adding_comment_to_card.json")],
"updown": [ScreenshotConfig("check_multiple_events.json")],
"uptimerobot": [ScreenshotConfig("uptimerobot_monitor_up.json")],
+ "wekan": [ScreenshotConfig("add_comment.json")],
"wordpress": [ScreenshotConfig("publish_post.txt", "wordpress_post_created.png")],
"yo": [
ScreenshotConfig(
diff --git a/zerver/webhooks/wekan/__init__.py b/zerver/webhooks/wekan/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/zerver/webhooks/wekan/doc.md b/zerver/webhooks/wekan/doc.md
new file mode 100644
index 00000000000..1cde4524abe
--- /dev/null
+++ b/zerver/webhooks/wekan/doc.md
@@ -0,0 +1,16 @@
+Get Wekan notifications in Zulip!
+
+1. {!create-stream.md!}
+
+1. {!create-bot-construct-url.md!}
+
+ {!git-webhook-url-with-branches.md!}
+
+1. Go to Wekan and click on the **Settings** icon.
+ Select **Outgoing Webhooks**.
+
+1. Set **URL** to the URL constructed above and click **Add Webhook**.
+
+{!congrats.md!}
+
+![](/static/images/integrations/wekan/001.png)
diff --git a/zerver/webhooks/wekan/fixtures/add_attachment.json b/zerver/webhooks/wekan/fixtures/add_attachment.json
new file mode 100644
index 00000000000..f6a0217a220
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/add_attachment.json
@@ -0,0 +1,8 @@
+{
+ "text": "JohnFish added attachment \"hGfm5ksud8k\" to card \"Markdown and emoji's\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "description": "act-addAttachment"
+}
diff --git a/zerver/webhooks/wekan/fixtures/add_checklist.json b/zerver/webhooks/wekan/fixtures/add_checklist.json
new file mode 100644
index 00000000000..21ad426210e
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/add_checklist.json
@@ -0,0 +1,8 @@
+{
+ "text": "JohnFish added checklist \"To do\" to card \"Markdown and emoji's\" at list \"Design\" at swimlane \"Default\" at board \"bucked-list\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "description": "act-addChecklist"
+}
diff --git a/zerver/webhooks/wekan/fixtures/add_checklist_item.json b/zerver/webhooks/wekan/fixtures/add_checklist_item.json
new file mode 100644
index 00000000000..e5b229a981f
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/add_checklist_item.json
@@ -0,0 +1,8 @@
+{
+ "text": "JohnFish added checklist item \"merge commit 9dfe\" to checklist \"To do\" at card \"Markdown and emoji's\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "description": "act-addChecklistItem"
+}
diff --git a/zerver/webhooks/wekan/fixtures/add_comment.json b/zerver/webhooks/wekan/fixtures/add_comment.json
new file mode 100644
index 00000000000..1ec417a2523
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/add_comment.json
@@ -0,0 +1,10 @@
+{
+ "text": "JohnFish commented on card \"Markdown and emoji's\": \"This feature is important\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "comment": "This feature is important",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "commentId": "tNko8hJZvMudkX4pt",
+ "description": "act-addComment"
+}
diff --git a/zerver/webhooks/wekan/fixtures/add_label.json b/zerver/webhooks/wekan/fixtures/add_label.json
new file mode 100644
index 00000000000..52a0d0a15c1
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/add_label.json
@@ -0,0 +1,10 @@
+{
+ "text": "JohnFish Added label Language to card \"Markdown & emojis\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/TMmjFnQGuZPsbjXzS",
+ "cardId": "TMmjFnQGuZPsbjXzS",
+ "listId": "m6ZKFcprEbX6hmFGy",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown & emojis",
+ "swimlaneId": "9KQqj2M37hztEr68d",
+ "description": "act-addedLabel"
+}
diff --git a/zerver/webhooks/wekan/fixtures/archived_card.json b/zerver/webhooks/wekan/fixtures/archived_card.json
new file mode 100644
index 00000000000..33eaff0405a
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/archived_card.json
@@ -0,0 +1,10 @@
+{
+ "text": "JohnFish Card \"Markdown and emoji's\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\" moved to Archive\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "listId": "m6ZKFcprEbX6hmFGy",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "swimlaneId": "QxJLobhCKvgwvy4vu",
+ "description": "act-archivedCard"
+}
diff --git a/zerver/webhooks/wekan/fixtures/archived_list.json b/zerver/webhooks/wekan/fixtures/archived_list.json
new file mode 100644
index 00000000000..0cfc9b13c84
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/archived_list.json
@@ -0,0 +1,7 @@
+{
+ "text": "JohnFish List \"Design\" at swimlane \"Default\" at board \"Bucket List\" moved to Archive\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list",
+ "listId": "BB7dtJSo4zB5QBzhY",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "description": "act-archivedList"
+}
diff --git a/zerver/webhooks/wekan/fixtures/archived_swimlane.json b/zerver/webhooks/wekan/fixtures/archived_swimlane.json
new file mode 100644
index 00000000000..07189189732
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/archived_swimlane.json
@@ -0,0 +1,7 @@
+{
+ "text": "JohnFish Swimlane \"Default\" at board \"Bucket List\" moved to Archive\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "swimlaneId": "QxJLobhCKvgwvy4vu",
+ "description": "act-archivedSwimlane"
+}
diff --git a/zerver/webhooks/wekan/fixtures/checked_item.json b/zerver/webhooks/wekan/fixtures/checked_item.json
new file mode 100644
index 00000000000..f34f16e997e
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/checked_item.json
@@ -0,0 +1,8 @@
+{
+ "text": "JohnFish checked To do of checklist \"To do\" at card \"Markdown and emoji's\" at list \"Design\" at swimlane \"Default\" at board \"bucket-list\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "description": "act-checkedItem"
+}
diff --git a/zerver/webhooks/wekan/fixtures/create_card.json b/zerver/webhooks/wekan/fixtures/create_card.json
new file mode 100644
index 00000000000..107b6263038
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/create_card.json
@@ -0,0 +1,10 @@
+{
+ "text": "JohnFish created card \"Markdown and emoji's\" to list \"Development & Implementation\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "listId": "BB7dtJSo4zB5QBzhY",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "swimlaneId": "QxJLobhCKvgwvy4vu",
+ "description": "act-createCard"
+}
diff --git a/zerver/webhooks/wekan/fixtures/create_custom_field.json b/zerver/webhooks/wekan/fixtures/create_custom_field.json
new file mode 100644
index 00000000000..6bcc13b19a6
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/create_custom_field.json
@@ -0,0 +1,6 @@
+{
+ "text": "JohnFish created custom field Language at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "description": "act-createCustomField"
+}
diff --git a/zerver/webhooks/wekan/fixtures/create_list.json b/zerver/webhooks/wekan/fixtures/create_list.json
new file mode 100644
index 00000000000..29ee0795f68
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/create_list.json
@@ -0,0 +1,7 @@
+{
+ "text": "JohnFish added list \"Testing & Maintenance\" to board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list",
+ "listId": "ygpBp4a94TcwTSXP9",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "description": "act-createList"
+}
diff --git a/zerver/webhooks/wekan/fixtures/create_swimlane.json b/zerver/webhooks/wekan/fixtures/create_swimlane.json
new file mode 100644
index 00000000000..2b8e02196f9
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/create_swimlane.json
@@ -0,0 +1,7 @@
+{
+ "text": "JohnFish created swimlane \"Jasper\" to board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "swimlaneId": "ZDyaRSF83EWkkeK5Y",
+ "description": "act-createSwimlane"
+}
diff --git a/zerver/webhooks/wekan/fixtures/delete_attachment.json b/zerver/webhooks/wekan/fixtures/delete_attachment.json
new file mode 100644
index 00000000000..c82ceaaca75
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/delete_attachment.json
@@ -0,0 +1,8 @@
+{
+ "text": "JohnFish deleted attachment \"hGfm5ksud8k.jpg\" at card \"Markdown and emoji's\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "description": "act-deleteAttachment"
+}
diff --git a/zerver/webhooks/wekan/fixtures/join_member.json b/zerver/webhooks/wekan/fixtures/join_member.json
new file mode 100644
index 00000000000..d25d86b8f3b
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/join_member.json
@@ -0,0 +1,10 @@
+{
+ "text": "JohnFish added member kokoboss to card \"Markdown & emojis\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/TMmjFnQGuZPsbjXzS",
+ "cardId": "TMmjFnQGuZPsbjXzS",
+ "listId": "m6ZKFcprEbX6hmFGy",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown & emojis",
+ "swimlaneId": "9KQqj2M37hztEr68d",
+ "description": "act-joinMember"
+}
diff --git a/zerver/webhooks/wekan/fixtures/move_card.json b/zerver/webhooks/wekan/fixtures/move_card.json
new file mode 100644
index 00000000000..7f46eba0528
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/move_card.json
@@ -0,0 +1,11 @@
+{
+ "text": "JohnFish moved card \"Markdown and emoji's\" at board \"Bucket List\" from list \"Development & Implementation\" at swimlane \"Default\" to list \"Design\" at swimlane \"Default\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "listId": "m6ZKFcprEbX6hmFGy",
+ "oldListId": "BB7dtJSo4zB5QBzhY",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "swimlaneId": "QxJLobhCKvgwvy4vu",
+ "description": "act-moveCard"
+}
diff --git a/zerver/webhooks/wekan/fixtures/remove_list.json b/zerver/webhooks/wekan/fixtures/remove_list.json
new file mode 100644
index 00000000000..e5e7964a1d2
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/remove_list.json
@@ -0,0 +1,7 @@
+{
+ "text": "JohnFish act-removeList\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list",
+ "listId": "ksHcqWxZjN6RLEnxd",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "description": "act-removeList"
+}
diff --git a/zerver/webhooks/wekan/fixtures/remove_swimlane.json b/zerver/webhooks/wekan/fixtures/remove_swimlane.json
new file mode 100644
index 00000000000..a75a56cc489
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/remove_swimlane.json
@@ -0,0 +1,7 @@
+{
+ "text": "JohnFish act-removeSwimlane\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "swimlaneId": "QxJLobhCKvgwvy4vu",
+ "description": "act-removeSwimlane"
+}
diff --git a/zerver/webhooks/wekan/fixtures/removed_checklist.json b/zerver/webhooks/wekan/fixtures/removed_checklist.json
new file mode 100644
index 00000000000..ba2b0c766dd
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/removed_checklist.json
@@ -0,0 +1,8 @@
+{
+ "text": "JohnFish removed checklist \"To do\" from card \"Markdown and emoji's\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "description": "act-removeChecklist"
+}
diff --git a/zerver/webhooks/wekan/fixtures/removed_checklist_item.json b/zerver/webhooks/wekan/fixtures/removed_checklist_item.json
new file mode 100644
index 00000000000..365507fdf32
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/removed_checklist_item.json
@@ -0,0 +1,8 @@
+{
+ "text": "JohnFish act-removedChecklistItem\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "description": "act-removedChecklistItem"
+}
diff --git a/zerver/webhooks/wekan/fixtures/restored_card.json b/zerver/webhooks/wekan/fixtures/restored_card.json
new file mode 100644
index 00000000000..e9ffba45250
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/restored_card.json
@@ -0,0 +1,10 @@
+{
+ "text": "JohnFish restored card \"Markdown and emoji's\" to list \"Design\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "listId": "m6ZKFcprEbX6hmFGy",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "swimlaneId": "QxJLobhCKvgwvy4vu",
+ "description": "act-restoredCard"
+}
diff --git a/zerver/webhooks/wekan/fixtures/set_custom_field.json b/zerver/webhooks/wekan/fixtures/set_custom_field.json
new file mode 100644
index 00000000000..45722297908
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/set_custom_field.json
@@ -0,0 +1,8 @@
+{
+ "text": "JohnFish act-setCustomField\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "description": "act-setCustomField"
+}
diff --git a/zerver/webhooks/wekan/fixtures/uncomplete_checklist.json b/zerver/webhooks/wekan/fixtures/uncomplete_checklist.json
new file mode 100644
index 00000000000..129a108264c
--- /dev/null
+++ b/zerver/webhooks/wekan/fixtures/uncomplete_checklist.json
@@ -0,0 +1,8 @@
+{
+ "text": "JohnFish uncompleted checklist To do at card \"Markdown and emoji's\" at list \"Design\" at swimlane \"Default\" at board \"Bucket List\"\nhttp://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL",
+ "cardId": "pMtu7kPZvMuhhC4hL",
+ "boardId": "Jinj4Xj7qnHLRmrTY",
+ "user": "JohnFish",
+ "card": "Markdown and emoji's",
+ "description": "act-uncompleteChecklist"
+}
diff --git a/zerver/webhooks/wekan/tests.py b/zerver/webhooks/wekan/tests.py
new file mode 100644
index 00000000000..981c4d239d3
--- /dev/null
+++ b/zerver/webhooks/wekan/tests.py
@@ -0,0 +1,217 @@
+from zerver.lib.test_classes import WebhookTestCase
+
+
+class WekanHookTests(WebhookTestCase):
+ STREAM_NAME = "wekan"
+ URL_TEMPLATE = "/api/v1/external/wekan?stream={stream}&api_key={api_key}"
+ FIXTURE_DIR_NAME = "wekan"
+
+ def test_add_attachment_message(self) -> None:
+ expected_message = 'JohnFish added attachment "hGfm5ksud8k" to card "Markdown and emoji\'s" at list "Design" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "add_attachment",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_add_checklist_item_message(self) -> None:
+ expected_message = 'JohnFish added checklist item "merge commit 9dfe" to checklist "To do" at card "Markdown and emoji\'s" at list "Design" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "add_checklist_item",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_add_checklist_message(self) -> None:
+ expected_message = 'JohnFish added checklist "To do" to card "Markdown and emoji\'s" at list "Design" at swimlane "Default" at board "bucked-list".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "add_checklist",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_add_label_message(self) -> None:
+ expected_message = 'JohnFish Added label Language to card "Markdown & emojis" at list "Design" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/TMmjFnQGuZPsbjXzS)'
+ self.check_webhook(
+ "add_label",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_archived_swimlane_message(self) -> None:
+ expected_message = 'JohnFish Swimlane "Default" at board "Bucket List" moved to Archive.\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'
+ self.check_webhook(
+ "archived_swimlane",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_archived_card_message(self) -> None:
+ expected_message = 'JohnFish Card "Markdown and emoji\'s" at list "Design" at swimlane "Default" at board "Bucket List" moved to Archive.\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "archived_card",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_archived_list_message(self) -> None:
+ expected_message = 'JohnFish List "Design" at swimlane "Default" at board "Bucket List" moved to Archive.\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'
+ self.check_webhook(
+ "archived_list",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_checked_item_message(self) -> None:
+ expected_message = 'JohnFish checked To do of checklist "To do" at card "Markdown and emoji\'s" at list "Design" at swimlane "Default" at board "bucket-list".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "checked_item",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_add_comment_message(self) -> None:
+ expected_message = 'JohnFish commented on card "Markdown and emoji\'s": "This feature is important" at list "Design" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "add_comment",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_create_card_message(self) -> None:
+ expected_message = 'JohnFish created card "Markdown and emoji\'s" to list "Development & Implementation" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "create_card",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_create_custom_field_message(self) -> None:
+ expected_message = 'JohnFish created custom field Language at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'
+ self.check_webhook(
+ "create_custom_field",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_create_list_message(self) -> None:
+ expected_message = 'JohnFish added list "Testing & Maintenance" to board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'
+ self.check_webhook(
+ "create_list",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_create_swimlane_message(self) -> None:
+ expected_message = 'JohnFish created swimlane "Jasper" to board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)'
+ self.check_webhook(
+ "create_swimlane",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_delete_attachment_message(self) -> None:
+ expected_message = 'JohnFish deleted attachment "hGfm5ksud8k.jpg" at card "Markdown and emoji\'s" at list "Design" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "delete_attachment",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_join_member_message(self) -> None:
+ expected_message = 'JohnFish added member kokoboss to card "Markdown & emojis" at list "Design" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/TMmjFnQGuZPsbjXzS)'
+ self.check_webhook(
+ "join_member",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_move_card_message(self) -> None:
+ expected_message = 'JohnFish moved card "Markdown and emoji\'s" at board "Bucket List" from list "Development & Implementation" at swimlane "Default" to list "Design" at swimlane "Default".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "move_card",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_remove_list_message(self) -> None:
+ expected_message = "JohnFish act-removeList.\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)"
+ self.check_webhook(
+ "remove_list",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_remove_swimlane_message(self) -> None:
+ expected_message = "JohnFish act-removeSwimlane.\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list)"
+ self.check_webhook(
+ "remove_swimlane",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_removed_checklist_item_message(self) -> None:
+ expected_message = "JohnFish act-removedChecklistItem.\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)"
+ self.check_webhook(
+ "removed_checklist_item",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_removed_checklist_message(self) -> None:
+ expected_message = 'JohnFish removed checklist "To do" from card "Markdown and emoji\'s" at list "Design" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "removed_checklist",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_restored_card_message(self) -> None:
+ expected_message = 'JohnFish restored card "Markdown and emoji\'s" to list "Design" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "restored_card",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_set_custom_field_message(self) -> None:
+ expected_message = "JohnFish act-setCustomField.\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)"
+ self.check_webhook(
+ "set_custom_field",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def test_uncomplete_checklist_message(self) -> None:
+ expected_message = 'JohnFish uncompleted checklist To do at card "Markdown and emoji\'s" at list "Design" at swimlane "Default" at board "Bucket List".\n\n[See in Wekan](http://127.0.0.1/b/Jinj4Xj7qnHLRmrTY/bucket-list/pMtu7kPZvMuhhC4hL)'
+ self.check_webhook(
+ "uncomplete_checklist",
+ "Wekan Notification",
+ expected_message,
+ content_type="application/x-www-form-urlencoded",
+ )
+
+ def get_body(self, fixture_name: str) -> str:
+ return self.webhook_fixture_data("wekan", fixture_name, file_type="json")
diff --git a/zerver/webhooks/wekan/view.py b/zerver/webhooks/wekan/view.py
new file mode 100644
index 00000000000..9c2349b0c64
--- /dev/null
+++ b/zerver/webhooks/wekan/view.py
@@ -0,0 +1,50 @@
+from typing import Any, Dict
+
+from django.http import HttpRequest, HttpResponse
+
+from zerver.decorator import webhook_view
+from zerver.lib.request import REQ, has_request_variables
+from zerver.lib.response import json_success
+from zerver.lib.webhooks.common import check_send_webhook_message
+from zerver.models import UserProfile
+
+LINK_TEMPLATE = "[See in Wekan]({url})"
+MESSAGE_TEMPLATE = "{body}\n\n{footer}"
+
+
+def get_url(text: str) -> str:
+ return text.split("\n")[-1]
+
+
+def get_hyperlinked_url(text: str) -> str:
+ url = get_url(text)
+ return LINK_TEMPLATE.format(url=url)
+
+
+def clean_payload_text(text: str) -> str:
+ url = get_url(text)
+ return text.replace(url, "").replace("\n", "")
+
+
+def get_message_body(payload: Dict[str, Any], action: str) -> str:
+ footer = get_hyperlinked_url(payload["text"])
+ body = process_message_data(payload, action)
+ return MESSAGE_TEMPLATE.format(body=body, footer=footer)
+
+
+def process_message_data(payload: Dict[str, Any], action: str) -> str:
+ payload["text"] = clean_payload_text(payload["text"])
+ return "{text}.".format(**payload)
+
+
+@webhook_view("Wekan")
+@has_request_variables
+def api_wekan_webhook(
+ request: HttpRequest,
+ user_profile: UserProfile,
+ payload: Dict[str, Any] = REQ(argument_type="body"),
+) -> HttpResponse:
+ topic = "Wekan Notification"
+ body = get_message_body(payload, payload["description"])
+ check_send_webhook_message(request, user_profile, topic, body)
+ return json_success(request)