webhooks: Remove unused imports.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2019-02-02 14:53:55 -08:00 committed by Tim Abbott
parent e984107966
commit 39ac378220
74 changed files with 88 additions and 183 deletions

View File

@ -2,12 +2,11 @@
from typing import Any, Dict from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.models import UserProfile from zerver.models import UserProfile
AIRBRAKE_TOPIC_TEMPLATE = '{project_name}' AIRBRAKE_TOPIC_TEMPLATE = '{project_name}'

View File

@ -1,14 +1,12 @@
from typing import Any, Dict, Iterable, Optional, List from typing import Any, Dict, List
from django.utils.translation import ugettext as _
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.response import json_success, json_error from zerver.lib.response import json_success
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from zerver.models import UserProfile from zerver.models import UserProfile
import ujson
import operator import operator
ANSIBLETOWER_DEFAULT_MESSAGE_TEMPLATE = "{friendly_name}: [#{id} {name}]({url}) {status}\n" ANSIBLETOWER_DEFAULT_MESSAGE_TEMPLATE = "{friendly_name}: [#{id} {name}]({url}) {status}\n"

View File

@ -1,13 +1,12 @@
# Webhooks for external integrations. # Webhooks for external integrations.
import re import re
from typing import Any, Dict, Optional from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -1,15 +1,12 @@
from typing import Any, Dict from typing import Any, Dict
from django.utils.translation import ugettext as _
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.response import json_success, json_error from zerver.lib.response import json_success
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from zerver.models import UserProfile from zerver.models import UserProfile
import ujson
APPVEYOR_TOPIC_TEMPLATE = '{project_name}' APPVEYOR_TOPIC_TEMPLATE = '{project_name}'
APPVEYOR_MESSAGE_TEMPLATE = ('[Build {project_name} {build_version} {status}]({build_url})\n' APPVEYOR_MESSAGE_TEMPLATE = ('[Build {project_name} {build_version} {status}]({build_url})\n'
'Commit [{commit_id}]({commit_url}) by {committer_name}' 'Commit [{commit_id}]({commit_url}) by {committer_name}'

View File

@ -1,4 +1,3 @@
import logging
import re import re
from typing import Any, Dict from typing import Any, Dict
@ -6,7 +5,7 @@ from django.http import HttpRequest, HttpResponse
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -2,7 +2,7 @@
import base64 import base64
from functools import wraps from functools import wraps
from typing import Any, Callable, Dict, Optional, TypeVar from typing import Any, Dict, Optional
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
@ -12,7 +12,7 @@ from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.validator import check_dict from zerver.lib.validator import check_dict
from zerver.models import UserProfile, get_client from zerver.models import UserProfile
from zerver.webhooks.github_legacy.view import build_message_from_gitlog from zerver.webhooks.github_legacy.view import build_message_from_gitlog
# Beanstalk's web hook UI rejects url with a @ in the username section of a url # Beanstalk's web hook UI rejects url with a @ in the username section of a url

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from typing import Dict, Optional, Union from typing import Dict, Union
from mock import MagicMock, patch from mock import MagicMock, patch

View File

@ -9,7 +9,7 @@ from zerver.lib.validator import check_dict
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \ from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \
get_push_commits_event_message get_push_commits_event_message
from zerver.models import UserProfile, get_client from zerver.models import UserProfile
@authenticated_rest_api_view(webhook_client_name="Bitbucket") @authenticated_rest_api_view(webhook_client_name="Bitbucket")
@has_request_variables @has_request_variables

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from typing import Optional
from mock import MagicMock, patch from mock import MagicMock, patch
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase

View File

@ -1,15 +1,14 @@
# Webhooks for external integrations. # Webhooks for external integrations.
import re import re
from functools import partial from functools import partial
from typing import Any, Callable, Dict, List, Optional from typing import Any, Dict, List, Optional
from inspect import signature from inspect import signature
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
validate_extract_webhook_http_header, UnexpectedWebhookEventType validate_extract_webhook_http_header, UnexpectedWebhookEventType
from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \ from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \

View File

@ -2,12 +2,11 @@
from typing import Any, Dict from typing import Any, Dict
import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -1,5 +1,5 @@
from functools import partial from functools import partial
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict, Optional
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse

View File

@ -2,13 +2,11 @@
from typing import Any, Dict from typing import Any, Dict
import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -2,11 +2,10 @@
from typing import Any, Dict from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -1,11 +1,10 @@
from typing import Any, Dict, Optional from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -6,7 +6,7 @@ from zerver.decorator import authenticated_rest_api_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile, get_client from zerver.models import UserProfile
# Desk.com's integrations all make the user supply a template, where it fills # Desk.com's integrations all make the user supply a template, where it fills
# in stuff like {{customer.name}} and posts the result as a "data" parameter. # in stuff like {{customer.name}} and posts the result as a "data" parameter.

View File

@ -1,7 +1,7 @@
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.decorator import has_request_variables, api_key_only_webhook_view
from zerver.models import UserProfile from zerver.models import UserProfile
@api_key_only_webhook_view('Dropbox', notify_bot_owner_on_invalid_json=False) @api_key_only_webhook_view('Dropbox', notify_bot_owner_on_invalid_json=False)

View File

@ -1,9 +1,8 @@
"""Webhooks for external integrations.""" """Webhooks for external integrations."""
import logging import logging
from typing import Any, Dict, List, Optional, Tuple, Union from typing import Any, Dict, List
import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
@ -12,7 +11,7 @@ from zerver.lib.notifications import convert_html_to_markdown
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_error, json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile, get_client from zerver.models import UserProfile
class TicketDict(Dict[str, Any]): class TicketDict(Dict[str, Any]):
""" """

View File

@ -1,4 +1,4 @@
from typing import Any, Dict, Optional, Tuple from typing import Any, Dict, Tuple
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from typing import Optional
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase
class GoogleCodeInTests(WebhookTestCase): class GoogleCodeInTests(WebhookTestCase):

View File

@ -1,11 +1,7 @@
from typing import Dict, Optional
import ujson
from mock import MagicMock, patch from mock import MagicMock, patch
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase
from zerver.lib.webhooks.git import COMMITS_LIMIT from zerver.lib.webhooks.git import COMMITS_LIMIT
from zerver.models import Message
class GithubWebhookTest(WebhookTestCase): class GithubWebhookTest(WebhookTestCase):
STREAM_NAME = 'github' STREAM_NAME = 'github'

View File

@ -1,13 +1,12 @@
import logging
import re import re
from functools import partial from functools import partial
from typing import Any, Callable, Dict, Optional from typing import Any, Dict, Optional
from inspect import signature from inspect import signature
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, JsonableError, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
validate_extract_webhook_http_header, UnexpectedWebhookEventType validate_extract_webhook_http_header, UnexpectedWebhookEventType

View File

@ -1,6 +1,6 @@
import logging import logging
import re import re
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple from typing import Any, Dict, List, Mapping, Optional, Tuple
import ujson import ujson
from django.conf import settings from django.conf import settings

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from typing import Optional
from mock import MagicMock, patch from mock import MagicMock, patch
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase

View File

@ -1,5 +1,5 @@
from functools import partial from functools import partial
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict, Optional
from inspect import signature from inspect import signature
import re import re

View File

@ -1,8 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import urllib
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase
from zerver.models import get_realm, get_user
class GocdHookTests(WebhookTestCase): class GocdHookTests(WebhookTestCase):
STREAM_NAME = 'gocd' STREAM_NAME = 'gocd'

View File

@ -3,16 +3,14 @@
import json import json
import os import os
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.validator import check_dict, check_string
from zerver.models import UserProfile from zerver.models import UserProfile
MESSAGE_TEMPLATE = ( MESSAGE_TEMPLATE = (

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from typing import Optional
from mock import MagicMock, patch from mock import MagicMock, patch
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase

View File

@ -1,13 +1,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim:fenc=utf-8 # vim:fenc=utf-8
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict, Optional
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
validate_extract_webhook_http_header, UnexpectedWebhookEventType validate_extract_webhook_http_header, UnexpectedWebhookEventType
from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \ from zerver.lib.webhooks.git import TOPIC_WITH_BRANCH_TEMPLATE, \

View File

@ -1,11 +1,10 @@
from typing import Any, Dict, Optional from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -1,12 +1,10 @@
from typing import Any, Dict, List from typing import Any, Dict, List
import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -1,11 +1,10 @@
from typing import Any, Dict, List from typing import Any, Dict, List
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -1,14 +1,12 @@
# Webhooks for external integrations. # Webhooks for external integrations.
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict, Iterable
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.validator import check_dict, check_string
from zerver.models import UserProfile from zerver.models import UserProfile
@api_key_only_webhook_view('HelloWorld') @api_key_only_webhook_view('HelloWorld')

View File

@ -1,13 +1,11 @@
from typing import Any, Dict, Iterable, Optional from typing import Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.validator import check_dict, check_string
from zerver.models import UserProfile from zerver.models import UserProfile
@api_key_only_webhook_view('HomeAssistant') @api_key_only_webhook_view('HomeAssistant')

View File

@ -1,4 +1,4 @@
from typing import Any, Callable, Dict from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _

View File

@ -1,14 +1,12 @@
from django.utils.translation import ugettext as _ from zerver.lib.response import json_success
from zerver.lib.response import json_success, json_error
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.decorator import REQ, has_request_variables, \ from zerver.decorator import REQ, has_request_variables, \
api_key_only_webhook_view api_key_only_webhook_view
from zerver.lib.validator import check_dict, check_string
from zerver.models import Client, UserProfile from zerver.models import UserProfile
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from typing import Dict, Any, Iterable, Optional from typing import Dict, Any
import time import time

View File

@ -1,17 +1,13 @@
# Webhooks for external integrations. # Webhooks for external integrations.
import logging
import re import re
from typing import Any, Dict, List, Optional, Tuple from typing import Any, Dict, List, Optional
import ujson
from django.conf import settings
from django.db.models import Q from django.db.models import Q
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType
from zerver.models import Realm, UserProfile, get_user_by_delivery_email from zerver.models import Realm, UserProfile, get_user_by_delivery_email

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import urllib import urllib
from typing import Optional
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase

View File

@ -1,5 +1,5 @@
from datetime import datetime from datetime import datetime
from typing import Any, Callable, Dict, List, Optional, Tuple from typing import Any, Callable, Dict, List, Tuple
import ujson import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse

View File

@ -1,14 +1,12 @@
# Webhooks for external integrations. # Webhooks for external integrations.
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict, Iterable
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.validator import check_dict, check_string
from zerver.models import UserProfile from zerver.models import UserProfile
@api_key_only_webhook_view('Mention') @api_key_only_webhook_view('Mention')

View File

@ -1,8 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf import settings
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase
from zerver.models import get_system_bot
class NetlifyHookTests(WebhookTestCase): class NetlifyHookTests(WebhookTestCase):
STREAM_NAME = 'netlify' STREAM_NAME = 'netlify'

View File

@ -1,14 +1,12 @@
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict, Iterable
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
validate_extract_webhook_http_header, UnexpectedWebhookEventType validate_extract_webhook_http_header, UnexpectedWebhookEventType
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.validator import check_dict, check_string
from zerver.models import UserProfile from zerver.models import UserProfile
EVENTS = ['deploy_failed', 'deploy_locked', 'deploy_unlocked', 'deploy_building', 'deploy_created'] EVENTS = ['deploy_failed', 'deploy_locked', 'deploy_unlocked', 'deploy_building', 'deploy_created']

View File

@ -1,16 +1,15 @@
# Webhooks for external integrations. # Webhooks for external integrations.
from typing import Any, Callable, Dict, Iterable, Optional, Tuple from typing import Any, Dict, Optional
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType
from zerver.lib.validator import check_dict from zerver.lib.validator import check_dict
from zerver.models import Stream, UserProfile from zerver.models import UserProfile
@api_key_only_webhook_view("NewRelic") @api_key_only_webhook_view("NewRelic")
@has_request_variables @has_request_variables

View File

@ -1,5 +1,5 @@
# Webhooks for external integrations. # Webhooks for external integrations.
from typing import Dict, Any, List, Tuple, Union from typing import Dict, Any, List
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
@ -7,7 +7,7 @@ from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile, get_client from zerver.models import UserProfile
subject_types = { subject_types = {
'app': [ # Object type name 'app': [ # Object type name

View File

@ -1,13 +1,11 @@
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.validator import check_dict, check_string
from zerver.models import UserProfile from zerver.models import UserProfile
@api_key_only_webhook_view('OpsGenie') @api_key_only_webhook_view('OpsGenie')

View File

@ -1,6 +1,6 @@
# Webhooks for external integrations. # Webhooks for external integrations.
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict, Iterable
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
@ -9,7 +9,7 @@ from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType
from zerver.models import Client, UserProfile from zerver.models import UserProfile
PAGER_DUTY_EVENT_NAMES = { PAGER_DUTY_EVENT_NAMES = {
'incident.trigger': 'triggered', 'incident.trigger': 'triggered',

View File

@ -1,13 +1,11 @@
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.validator import check_dict, check_string
from zerver.models import UserProfile from zerver.models import UserProfile
@api_key_only_webhook_view('Papertrail') @api_key_only_webhook_view('Papertrail')

View File

@ -1,13 +1,11 @@
# Webhooks pfor external integrations. # Webhooks pfor external integrations.
from typing import Any, Dict from typing import Any, Dict
import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -1,6 +1,5 @@
"""Webhooks for external integrations.""" """Webhooks for external integrations."""
import logging
import re import re
from typing import Any, Dict, List, Optional, Tuple from typing import Any, Dict, List, Optional, Tuple
@ -10,7 +9,7 @@ from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_error, json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType

View File

@ -1,4 +1,4 @@
from typing import Any, Dict, Optional from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from typing import Optional
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase

View File

@ -1,14 +1,12 @@
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict, Iterable
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
validate_extract_webhook_http_header, UnexpectedWebhookEventType validate_extract_webhook_http_header, UnexpectedWebhookEventType
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.validator import check_dict, check_string
from zerver.models import UserProfile from zerver.models import UserProfile
REVIEW_REQUEST_PUBLISHED = """ REVIEW_REQUEST_PUBLISHED = """

View File

@ -2,15 +2,13 @@
from typing import Any, Dict from typing import Any, Dict
import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile, get_client from zerver.models import UserProfile
@api_key_only_webhook_view('Semaphore') @api_key_only_webhook_view('Semaphore')
@has_request_variables @has_request_variables

View File

@ -1,12 +1,10 @@
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.actions import check_send_stream_message, \ from zerver.lib.actions import check_send_stream_message
create_stream_if_needed
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_error, json_success
from zerver.lib.validator import check_int, check_string
from zerver.models import UserProfile from zerver.models import UserProfile
ZULIP_MESSAGE_TEMPLATE = u"**{message_sender}**: `{text}`" ZULIP_MESSAGE_TEMPLATE = u"**{message_sender}**: `{text}`"

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import urllib
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase
class SolanoHookTests(WebhookTestCase): class SolanoHookTests(WebhookTestCase):

View File

@ -3,13 +3,12 @@
from typing import Any, Dict from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import Client, UserProfile from zerver.models import UserProfile
@api_key_only_webhook_view('SolanoLabs') @api_key_only_webhook_view('SolanoLabs')
@has_request_variables @has_request_variables

View File

@ -1,14 +1,12 @@
# Webhooks for external integrations. # Webhooks for external integrations.
from typing import Any, Dict, Iterable, Optional from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.lib.validator import check_dict, check_string
from zerver.models import MAX_TOPIC_NAME_LENGTH, UserProfile from zerver.models import MAX_TOPIC_NAME_LENGTH, UserProfile
@api_key_only_webhook_view('Splunk') @api_key_only_webhook_view('Splunk')

View File

@ -1,9 +1,8 @@
# Webhooks for external integrations. # Webhooks for external integrations.
from django.utils.translation import ugettext as _
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from zerver.models import get_client, UserProfile from zerver.models import UserProfile
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from typing import Dict, Any from typing import Dict, Any

View File

@ -1,14 +1,12 @@
# Webhooks for external integrations. # Webhooks for external integrations.
import time import time
from datetime import datetime
from typing import Any, Dict, List, Optional, Tuple from typing import Any, Dict, List, Optional, Tuple
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.timestamp import timestamp_to_datetime from zerver.lib.timestamp import timestamp_to_datetime
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType

View File

@ -9,13 +9,11 @@ should be in bold.
from typing import Any, Dict, List, Mapping, Optional, Tuple from typing import Any, Dict, List, Mapping, Optional, Tuple
import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -3,7 +3,6 @@
import logging import logging
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
import ujson
from django.db.models import Q from django.db.models import Q
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
@ -12,7 +11,7 @@ from zerver.lib.actions import check_send_private_message, \
send_rate_limited_pm_notification_to_bot_owner send_rate_limited_pm_notification_to_bot_owner
from zerver.lib.send_email import FromAddress from zerver.lib.send_email import FromAddress
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import Realm, UserProfile from zerver.models import Realm, UserProfile

View File

@ -2,11 +2,10 @@
from typing import Optional from typing import Optional
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType
from zerver.models import UserProfile from zerver.models import UserProfile

View File

@ -2,7 +2,6 @@
import urllib import urllib
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase
from zerver.models import get_realm, get_user
class TravisHookTests(WebhookTestCase): class TravisHookTests(WebhookTestCase):
STREAM_NAME = 'travis' STREAM_NAME = 'travis'

View File

@ -2,7 +2,6 @@
from typing import Dict from typing import Dict
import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view

View File

@ -1,10 +1,9 @@
# Webhooks for external integrations. # Webhooks for external integrations.
import ujson import ujson
from typing import Mapping, Any, Tuple, Optional from typing import Mapping, Any, Tuple, Optional
from django.utils.translation import ugettext as _
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from zerver.decorator import api_key_only_webhook_view, return_success_on_head_request from zerver.decorator import api_key_only_webhook_view, return_success_on_head_request
from zerver.lib.response import json_success, json_error from zerver.lib.response import json_success
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType

View File

@ -1,4 +1,4 @@
from typing import Any, Dict, Mapping, MutableMapping, Optional, Tuple from typing import Any, Dict, Mapping, Optional, Tuple
from .exceptions import UnknownUpdateBoardAction from .exceptions import UnknownUpdateBoardAction

View File

@ -1,5 +1,4 @@
from datetime import datetime from typing import Any, Dict, Mapping, Optional, Tuple
from typing import Any, Dict, Mapping, MutableMapping, Optional, Tuple
from .exceptions import UnknownUpdateCardAction from .exceptions import UnknownUpdateCardAction

View File

@ -1,18 +1,15 @@
# Webhooks for external integrations. # Webhooks for external integrations.
import re import re
from datetime import datetime
from typing import Any, Dict, List from typing import Any, Dict, List
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view
from zerver.lib.exceptions import JsonableError
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message, \ from zerver.lib.webhooks.common import check_send_webhook_message, \
UnexpectedWebhookEventType UnexpectedWebhookEventType
from zerver.models import Client, UserProfile from zerver.models import UserProfile
TOPIC_TEMPLATE = "{service_url}" TOPIC_TEMPLATE = "{service_url}"

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from zerver.lib.test_classes import WebhookTestCase from zerver.lib.test_classes import WebhookTestCase
from zerver.models import get_realm, get_user
class WordPressHookTests(WebhookTestCase): class WordPressHookTests(WebhookTestCase):
STREAM_NAME = 'wordpress' STREAM_NAME = 'wordpress'

View File

@ -6,7 +6,7 @@ from zerver.decorator import api_key_only_webhook_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_error, json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile, get_client from zerver.models import UserProfile
PUBLISH_POST_OR_PAGE_TEMPLATE = 'New {type} published.\n[{title}]({url})' PUBLISH_POST_OR_PAGE_TEMPLATE = 'New {type} published.\n[{title}]({url})'
USER_REGISTER_TEMPLATE = 'New blog user registered.\nName: {name}\nemail: {email}' USER_REGISTER_TEMPLATE = 'New blog user registered.\nName: {name}\nemail: {email}'

View File

@ -1,7 +1,6 @@
# Webhooks for external integrations. # Webhooks for external integrations.
from typing import Optional from typing import Optional
import ujson
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from zerver.decorator import api_key_only_webhook_view from zerver.decorator import api_key_only_webhook_view

View File

@ -10,8 +10,6 @@ from zerver.lib.send_email import FromAddress
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from zerver.models import UserProfile from zerver.models import UserProfile
import ujson
MISCONFIGURED_PAYLOAD_ERROR_MESSAGE = """ MISCONFIGURED_PAYLOAD_ERROR_MESSAGE = """
Hi there! Your bot {bot_name} just received a Zabbix payload that is missing Hi there! Your bot {bot_name} just received a Zabbix payload that is missing
some data that Zulip requires. This usually indicates a configuration issue some data that Zulip requires. This usually indicates a configuration issue

View File

@ -1,4 +1,4 @@
from typing import Any, Callable, Dict from typing import Any, Dict
from django.http import HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _

View File

@ -6,7 +6,7 @@ from zerver.decorator import authenticated_rest_api_view
from zerver.lib.request import REQ, has_request_variables from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.webhooks.common import check_send_webhook_message from zerver.lib.webhooks.common import check_send_webhook_message
from zerver.models import UserProfile, get_client from zerver.models import UserProfile
def truncate(string: str, length: int) -> str: def truncate(string: str, length: int) -> str:
if len(string) > length: if len(string) > length: