integrations: Move get_setup_webhook_message to common.py.

Move `get_setup_webhook_message` to
`zerver/lib/webhooks/common.py` so multiple integrations can use this
rather than just those which import `zerver/lib/webhooks/git.py`. Also
added the documentation for this.
This commit is contained in:
Adam Birds
2021-05-06 14:02:36 +00:00
committed by Tim Abbott
parent c598a84dd6
commit c72ef7be12
4 changed files with 19 additions and 12 deletions

View File

@@ -32,10 +32,21 @@ but didn't correctly configure the webhook to send data in the JSON format
that this integration expects!
"""
SETUP_MESSAGE_TEMPLATE = "{integration} webhook has been successfully configured"
SETUP_MESSAGE_USER_PART = " by {user_name}"
# Django prefixes all custom HTTP headers with `HTTP_`
DJANGO_HTTP_PREFIX = "HTTP_"
def get_setup_webhook_message(integration: str, user_name: Optional[str] = None) -> str:
content = SETUP_MESSAGE_TEMPLATE.format(integration=integration)
if user_name:
content += SETUP_MESSAGE_USER_PART.format(user_name=user_name)
content = f"{content}."
return content
def notify_bot_owner_about_invalid_json(
user_profile: UserProfile, webhook_client_name: str
) -> None: