integration: Add wekan integration.

Fixes #13086

Co-authored-by: Ganesh Pawar (ganpa3) <pawarg256@gmail.com>
This commit is contained in:
Israel Ebonko
2019-11-14 13:21:38 +01:00
committed by Tim Abbott
parent 544e472ec3
commit 1f286ab283
31 changed files with 477 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -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(

View File

View File

@@ -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)

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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"
}

View File

@@ -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")

View File

@@ -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)