mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
python: Sort imports in webhooks.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
# Webhooks for external integrations.
|
||||
from typing import Dict, Any, Text
|
||||
from typing import Any, Dict, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
AIRBRAKE_SUBJECT_TEMPLATE = '{project_name}'
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from zerver.webhooks.appfollow.view import convert_markdown
|
||||
|
||||
class AppFollowHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
# Webhooks for external integrations.
|
||||
import re
|
||||
from typing import Any, Dict, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
from typing import Dict, Any, Text
|
||||
|
||||
@api_key_only_webhook_view("AppFollow")
|
||||
@has_request_variables
|
||||
def api_appfollow_webhook(request, user_profile, stream=REQ(default="appfollow"),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class BasecampHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import re
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Dict, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
from .support_event import SUPPORT_EVENTS
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from mock import patch, MagicMock
|
||||
from typing import Dict, Text
|
||||
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
|
||||
class BeanstalkHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'commits'
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
# Webhooks for external integrations.
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from zerver.decorator import authenticated_rest_api_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.validator import check_dict
|
||||
from zerver.models import get_client, UserProfile
|
||||
|
||||
import base64
|
||||
from functools import wraps
|
||||
from typing import Any, Callable, Dict, Optional, Text, TypeVar
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import authenticated_rest_api_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.str_utils import force_bytes, force_str
|
||||
from zerver.lib.validator import check_dict
|
||||
from zerver.models import UserProfile, get_client
|
||||
from zerver.webhooks.github.view import build_message_from_gitlog
|
||||
|
||||
from typing import Any, Callable, Dict, TypeVar, Optional, Text
|
||||
from zerver.lib.str_utils import force_str, force_bytes
|
||||
|
||||
ViewFuncT = TypeVar('ViewFuncT', bound=Callable[..., HttpResponse])
|
||||
|
||||
# Beanstalk's web hook UI rejects url with a @ in the username section of a url
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from mock import patch, MagicMock
|
||||
from typing import Dict, Union, Text, Optional
|
||||
from typing import Dict, Optional, Text, Union
|
||||
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
from typing import Any, Mapping, Text, Optional
|
||||
from typing import Any, Mapping, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import authenticated_rest_api_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.validator import check_dict
|
||||
from zerver.lib.webhooks.git import get_push_commits_event_message, SUBJECT_WITH_BRANCH_TEMPLATE
|
||||
from zerver.models import get_client, UserProfile
|
||||
|
||||
from zerver.lib.webhooks.git import SUBJECT_WITH_BRANCH_TEMPLATE, \
|
||||
get_push_commits_event_message
|
||||
from zerver.models import UserProfile, get_client
|
||||
|
||||
@authenticated_rest_api_view(is_webhook=True)
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from mock import patch, MagicMock
|
||||
from typing import Optional, Text
|
||||
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class Bitbucket2HookTests(WebhookTestCase):
|
||||
|
||||
@@ -2,18 +2,21 @@
|
||||
import re
|
||||
from functools import partial
|
||||
from typing import Any, Callable, Dict, List, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.webhooks.git import SUBJECT_WITH_BRANCH_TEMPLATE, \
|
||||
SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE, \
|
||||
get_commits_comment_action_message, get_force_push_commits_event_message, \
|
||||
get_issue_event_message, get_pull_request_event_message, \
|
||||
get_push_commits_event_message, get_push_tag_event_message, \
|
||||
get_remove_branch_event_message
|
||||
from zerver.models import UserProfile
|
||||
from zerver.lib.webhooks.git import get_push_commits_event_message, SUBJECT_WITH_BRANCH_TEMPLATE,\
|
||||
get_force_push_commits_event_message, get_remove_branch_event_message, get_pull_request_event_message,\
|
||||
SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE, get_issue_event_message, get_commits_comment_action_message,\
|
||||
get_push_tag_event_message
|
||||
|
||||
|
||||
BITBUCKET_SUBJECT_TEMPLATE = '{repository_name}'
|
||||
USER_PART = 'User {display_name}(login: {username})'
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
# Webhooks for external integrations.
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Any, Dict, Text
|
||||
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
import ujson
|
||||
|
||||
|
||||
CIRCLECI_SUBJECT_TEMPLATE = u'{repository_name}'
|
||||
CIRCLECI_MESSAGE_TEMPLATE = u'[Build]({build_url}) triggered by {username} on {branch} branch {status}.'
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
# Webhooks for external integrations.
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Any, Dict
|
||||
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
import ujson
|
||||
|
||||
|
||||
CODESHIP_SUBJECT_TEMPLATE = '{project_name}'
|
||||
CODESHIP_MESSAGE_TEMPLATE = '[Build]({build_url}) triggered by {committer} on {branch} branch {status}.'
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
# Webhooks for external integrations.
|
||||
from typing import Any, Dict, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
CRASHLYTICS_SUBJECT_TEMPLATE = '{display_id}: {title}'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class DelightedHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Optional
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
def body_template(score: int) -> str:
|
||||
if score >= 7:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
# Tests for the Desk.com webhook integration.
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Webhooks for external integrations.
|
||||
from typing import Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import authenticated_rest_api_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import get_client, UserProfile
|
||||
|
||||
from typing import Text
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.models import UserProfile, get_client
|
||||
|
||||
# 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.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class FreshdeskHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
"""Webhooks for external integrations."""
|
||||
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional, Text, Tuple, Union
|
||||
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import authenticated_rest_api_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.notifications import convert_html_to_markdown
|
||||
from zerver.models import get_client, UserProfile
|
||||
|
||||
import logging
|
||||
import ujson
|
||||
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union, Text
|
||||
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile, get_client
|
||||
|
||||
class TicketDict(Dict[str, Any]):
|
||||
"""
|
||||
|
||||
@@ -3,7 +3,6 @@ from typing import Optional, Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
|
||||
class GoogleCodeInTests(WebhookTestCase):
|
||||
STREAM_NAME = 'gci'
|
||||
URL_TEMPLATE = "/api/v1/external/gci?&api_key={api_key}&stream={stream}"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Optional, Text
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
GCI_MESSAGE_TEMPLATE = u'**{actor}** {action} the task [{task_name}]({task_url}).'
|
||||
GCI_SUBJECT_TEMPLATE = u'Task: {task_name}'
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import ujson
|
||||
from typing import Dict, Optional, Text
|
||||
|
||||
from zerver.models import Message
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
import ujson
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
from zerver.models import Message
|
||||
|
||||
class GithubV1HookTests(WebhookTestCase):
|
||||
STREAM_NAME = None # type: Optional[Text]
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
from django.conf import settings
|
||||
from zerver.decorator import authenticated_api_view, to_non_negative_int, flexible_boolean
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.validator import check_dict
|
||||
from zerver.lib.webhooks.git import get_push_commits_event_message,\
|
||||
SUBJECT_WITH_BRANCH_TEMPLATE, get_force_push_commits_event_message, \
|
||||
get_remove_branch_event_message, get_pull_request_event_message,\
|
||||
get_issue_event_message, SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE,\
|
||||
get_commits_comment_action_message
|
||||
from zerver.models import get_client, UserProfile
|
||||
from zerver.views.messages import send_message_backend
|
||||
|
||||
import logging
|
||||
import re
|
||||
import ujson
|
||||
from typing import Any, Dict, List, Mapping, Optional, Sequence, Text, Tuple
|
||||
|
||||
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple, Text
|
||||
from zerver.lib.str_utils import force_str
|
||||
import ujson
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import authenticated_api_view, \
|
||||
flexible_boolean, to_non_negative_int
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.str_utils import force_str
|
||||
from zerver.lib.validator import check_dict
|
||||
from zerver.lib.webhooks.git import SUBJECT_WITH_BRANCH_TEMPLATE, \
|
||||
SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE, \
|
||||
get_commits_comment_action_message, get_force_push_commits_event_message, \
|
||||
get_issue_event_message, get_pull_request_event_message, \
|
||||
get_push_commits_event_message, get_remove_branch_event_message
|
||||
from zerver.models import UserProfile, get_client
|
||||
from zerver.views.messages import send_message_backend
|
||||
|
||||
ZULIP_TEST_REPO_NAME = 'zulip-test'
|
||||
ZULIP_TEST_REPO_ID = 6893087
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from .github_webhook.view import api_github_webhook
|
||||
|
||||
from .github.view import api_github_landing
|
||||
from .github_webhook.view import api_github_webhook
|
||||
|
||||
# Since this dispatcher is an API-style endpoint, it needs to be
|
||||
# explicitly marked as CSRF-exempt
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import ujson
|
||||
from mock import patch, MagicMock
|
||||
from typing import Dict, Optional, Text
|
||||
|
||||
from zerver.models import Message
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
import ujson
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
from zerver.models import Message
|
||||
|
||||
class GithubWebhookTest(WebhookTestCase):
|
||||
STREAM_NAME = 'github'
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
import re
|
||||
import logging
|
||||
import re
|
||||
from functools import partial
|
||||
from typing import Any, Callable, Text, Dict, Optional
|
||||
from typing import Any, Callable, Dict, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, JsonableError, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import JsonableError, REQ, has_request_variables
|
||||
from zerver.lib.webhooks.git import CONTENT_MESSAGE_TEMPLATE, \
|
||||
SUBJECT_WITH_BRANCH_TEMPLATE, SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE, \
|
||||
get_commits_comment_action_message, get_issue_event_message, \
|
||||
get_pull_request_event_message, get_push_commits_event_message, \
|
||||
get_push_tag_event_message, get_setup_webhook_message
|
||||
from zerver.models import UserProfile
|
||||
|
||||
from zerver.lib.webhooks.git import get_issue_event_message, SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE,\
|
||||
get_pull_request_event_message, SUBJECT_WITH_BRANCH_TEMPLATE,\
|
||||
get_push_commits_event_message, CONTENT_MESSAGE_TEMPLATE,\
|
||||
get_commits_comment_action_message, get_push_tag_event_message, \
|
||||
get_setup_webhook_message
|
||||
|
||||
class UnknownEventType(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from mock import patch, MagicMock
|
||||
from typing import Optional, Text
|
||||
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
|
||||
class GitlabHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'gitlab'
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
from functools import partial
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.webhooks.git import get_push_commits_event_message, EMPTY_SHA,\
|
||||
get_remove_branch_event_message, get_pull_request_event_message,\
|
||||
get_issue_event_message, SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE,\
|
||||
get_commits_comment_action_message, get_push_tag_event_message
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Iterable, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Iterable, Optional, Text
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.webhooks.git import EMPTY_SHA, \
|
||||
SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE, \
|
||||
get_commits_comment_action_message, get_issue_event_message, \
|
||||
get_pull_request_event_message, get_push_commits_event_message, \
|
||||
get_push_tag_event_message, get_remove_branch_event_message
|
||||
from zerver.models import UserProfile
|
||||
|
||||
class UnknownEventType(Exception):
|
||||
pass
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from mock import patch, MagicMock
|
||||
from typing import Text, Optional
|
||||
from typing import Optional, Text
|
||||
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
from zerver.lib.webhooks.git import COMMITS_LIMIT
|
||||
|
||||
class GogsHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'commits'
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim:fenc=utf-8
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.webhooks.git import get_push_commits_event_message, \
|
||||
get_pull_request_event_message, get_create_branch_event_message, \
|
||||
SUBJECT_WITH_BRANCH_TEMPLATE, SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Iterable, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Iterable, Optional, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.webhooks.git import SUBJECT_WITH_BRANCH_TEMPLATE, \
|
||||
SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE, get_create_branch_event_message, \
|
||||
get_pull_request_event_message, get_push_commits_event_message
|
||||
from zerver.models import UserProfile
|
||||
|
||||
def format_push_event(payload: Dict[str, Any]) -> Text:
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class GoSquaredHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Optional, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
BODY_TEMPLATE = '[{website_name}]({website_url}) has {user_num} visitors online.'
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class GreenhouseHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
import ujson
|
||||
|
||||
MESSAGE_TEMPLATE = "Applying for role:\n{}\n**Emails:**\n{}\n\n>**Attachments:**\n{}"
|
||||
|
||||
def dict_list_to_string(some_list: List[Any]) -> str:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class HelloSignHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Any, Dict, List
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
def format_body(signatories: List[Dict[str, Any]], model_payload: Dict[str, Any]) -> str:
|
||||
def append_separator(i: int) -> None:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class HelloWorldHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
# Webhooks for external integrations.
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Iterable, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Iterable, Optional, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import UserProfile
|
||||
|
||||
@api_key_only_webhook_view('HelloWorld')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class HerokuHookTests(WebhookTestCase):
|
||||
|
||||
@@ -5,11 +5,10 @@ from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
|
||||
@api_key_only_webhook_view("Heroku")
|
||||
@has_request_variables
|
||||
def api_heroku_webhook(request, user_profile, stream=REQ(default="heroku"),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class HomeAssistantHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'homeassistant'
|
||||
URL_TEMPLATE = "/api/v1/external/homeassistant?&api_key={api_key}"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Iterable, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Iterable, Optional, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import UserProfile
|
||||
|
||||
@api_key_only_webhook_view('HomeAssistant')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from typing import Any, Callable, Dict
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
|
||||
@api_key_only_webhook_view('IFTTT')
|
||||
@has_request_variables
|
||||
def api_iftt_app_webhook(request, user_profile,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class JiraHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
# Webhooks for external integrations.
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Dict, List, Optional, Text, Tuple
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.db.models import Q
|
||||
import ujson
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import UserProfile, get_user, Realm
|
||||
|
||||
import logging
|
||||
import re
|
||||
import ujson
|
||||
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import Realm, UserProfile, get_user
|
||||
|
||||
IGNORED_EVENTS = [
|
||||
'comment_created', # we handle issue_update event instead
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import urllib
|
||||
from typing import Optional, Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class LibratoHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Callable, Tuple, Text
|
||||
|
||||
from django.utils.timezone import utc as timezone_utc
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Callable, Dict, List, Optional, Text, Tuple
|
||||
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.timezone import utc as timezone_utc
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
ALERT_CLEAR = 'clear'
|
||||
ALERT_VIOLATION = 'violations'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class MentionHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
# Webhooks for external integrations.
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Iterable, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Iterable, Optional, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import UserProfile
|
||||
|
||||
@api_key_only_webhook_view('Mention')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class NewRelicHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
# Webhooks for external integrations.
|
||||
from typing import Any, Callable, Dict, Iterable, Optional, Tuple, Text
|
||||
from typing import Any, Callable, Dict, Iterable, Optional, Text, Tuple
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_dict
|
||||
from zerver.models import UserProfile, Stream
|
||||
|
||||
from zerver.models import Stream, UserProfile
|
||||
|
||||
@api_key_only_webhook_view("NewRelic")
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class OpsGenieHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Iterable, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Iterable, Optional, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import UserProfile
|
||||
|
||||
@api_key_only_webhook_view('OpsGenie')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class PagerDutyHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
# Webhooks for external integrations.
|
||||
|
||||
import pprint
|
||||
from typing import Any, Dict, Iterable, Optional, Text
|
||||
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.models import Client, UserProfile
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
import pprint
|
||||
import ujson
|
||||
from typing import Dict, Any, Iterable, Optional, Text
|
||||
|
||||
|
||||
PAGER_DUTY_EVENT_NAMES = {
|
||||
'incident.trigger': 'triggered',
|
||||
'incident.acknowledge': 'acknowledged',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class PapertrailHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'papertrail'
|
||||
URL_TEMPLATE = "/api/v1/external/papertrail?&api_key={api_key}"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict, Iterable, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Iterable, Optional, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import UserProfile
|
||||
|
||||
@api_key_only_webhook_view('Papertrail')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
# Webhooks pfor external integrations.
|
||||
from typing import Any, Dict, Text
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
import ujson
|
||||
|
||||
|
||||
PINGDOM_SUBJECT_TEMPLATE = '{name} status.'
|
||||
PINGDOM_MESSAGE_TEMPLATE = ('Service {service_url} changed its {type} status'
|
||||
' from {previous_state} to {current_state}.')
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class PivotalV3HookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
"""Webhooks for external integrations."""
|
||||
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Dict, List, Optional, Text, Tuple
|
||||
|
||||
import ujson
|
||||
from defusedxml.ElementTree import fromstring as xml_fromstring
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
from defusedxml.ElementTree import fromstring as xml_fromstring
|
||||
|
||||
import logging
|
||||
import re
|
||||
import ujson
|
||||
from typing import Dict, List, Optional, Tuple, Text, Any
|
||||
|
||||
|
||||
def api_pivotal_webhook_v3(request: HttpRequest, user_profile: UserProfile,
|
||||
stream: Text) -> Tuple[Text, Text]:
|
||||
payload = xml_fromstring(request.body)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class SemaphoreHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
# Webhooks for external integrations.
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile, get_client
|
||||
import ujson
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
@api_key_only_webhook_view('Semaphore')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
# Webhooks for external integrations.
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.models import UserProfile
|
||||
from typing import Any, Dict
|
||||
|
||||
@api_key_only_webhook_view('Sentry')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
|
||||
class SlackWebhookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'slack'
|
||||
URL_TEMPLATE = "/api/v1/external/slack?stream={stream}&api_key={api_key}"
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message, create_stream_if_needed
|
||||
from zerver.lib.response import json_success, json_error
|
||||
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.validator import check_string, check_int
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_int, check_string
|
||||
from zerver.models import UserProfile
|
||||
|
||||
ZULIP_MESSAGE_TEMPLATE = u"**{message_sender}**: `{text}`"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
import urllib
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class SolanoHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
# Webhooks for external integrations.
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import UserProfile, Client
|
||||
|
||||
from typing import Any, Dict
|
||||
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import Client, UserProfile
|
||||
|
||||
@api_key_only_webhook_view('SolanoLabs')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class SplunkHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
# Webhooks for external integrations.
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import UserProfile, MAX_SUBJECT_LENGTH
|
||||
from typing import Any, Dict, Iterable, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Iterable, Optional, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.models import MAX_SUBJECT_LENGTH, UserProfile
|
||||
|
||||
@api_key_only_webhook_view('Splunk')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
import mock
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class StripeHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'test'
|
||||
URL_TEMPLATE = "/api/v1/external/stripe?&api_key={api_key}"
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# Webhooks for external integrations.
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import UserProfile
|
||||
import time
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Optional, Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Dict, Any, Optional, Text
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from datetime import datetime
|
||||
import time
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
@api_key_only_webhook_view('Stripe')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class TaigaHookTests(WebhookTestCase):
|
||||
|
||||
@@ -18,19 +18,18 @@ value should always be in bold; otherwise the subject of US/task
|
||||
should be in bold.
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, List, Mapping, Optional, Tuple, Text
|
||||
from typing import Any, Dict, List, Mapping, Optional, Text, Tuple
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
import ujson
|
||||
|
||||
@api_key_only_webhook_view('Taiga')
|
||||
@has_request_variables
|
||||
def api_taiga_webhook(request, user_profile, message=REQ(argument_type='body'),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import ujson
|
||||
from zerver.models import Recipient
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from zerver.models import Recipient
|
||||
|
||||
class TeamcityHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'teamcity'
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
# Webhooks for teamcity integration
|
||||
|
||||
from django.db.models import Q
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
import logging
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_private_message, check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import UserProfile, Realm
|
||||
|
||||
import logging
|
||||
import ujson
|
||||
from django.db.models import Q
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_private_message, \
|
||||
check_send_stream_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import Realm, UserProfile
|
||||
|
||||
def guess_zulip_user_from_teamcity(teamcity_username: str, realm: Realm) -> Optional[UserProfile]:
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Any, Dict, Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class TransifexHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# Webhooks for external integrations.
|
||||
from django.utils.translation import ugettext as _
|
||||
from typing import Optional
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
from typing import Optional
|
||||
|
||||
@api_key_only_webhook_view('Transifex')
|
||||
@has_request_variables
|
||||
def api_transifex_webhook(request, user_profile,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Text
|
||||
import urllib
|
||||
from typing import Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from zerver.models import get_realm, get_user
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# Webhooks for external integrations.
|
||||
|
||||
from typing import Dict
|
||||
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.validator import check_dict, check_string, check_bool
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.validator import check_bool, check_dict, check_string
|
||||
from zerver.models import UserProfile
|
||||
from typing import Dict
|
||||
|
||||
import ujson
|
||||
|
||||
GOOD_STATUSES = ['Passed', 'Fixed']
|
||||
BAD_STATUSES = ['Failed', 'Broken', 'Still Failing']
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from mock import patch, MagicMock
|
||||
|
||||
class TrelloHookTests(WebhookTestCase):
|
||||
STREAM_NAME = 'trello'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Any, Dict, Optional, Mapping, MutableMapping, Text, Tuple
|
||||
from typing import Any, Dict, Mapping, MutableMapping, Optional, Text, Tuple
|
||||
|
||||
from .exceptions import UnknownUpdateBoardAction
|
||||
|
||||
SUPPORTED_BOARD_ACTIONS = [
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from typing import Dict, Tuple, Any, Optional, MutableMapping, Mapping, Text
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, Mapping, MutableMapping, Optional, Text, Tuple
|
||||
|
||||
from .exceptions import UnknownUpdateCardAction
|
||||
|
||||
SUPPORTED_CARD_ACTIONS = [
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
import re
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import UserProfile, Client
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import Client, UserProfile
|
||||
|
||||
SUBJECT_TEMPLATE = "{service_url}"
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# Webhooks for external integrations.
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import get_client, UserProfile
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile, get_client
|
||||
|
||||
PUBLISH_POST_OR_PAGE_TEMPLATE = 'New {type} published.\n[{title}]({url})'
|
||||
USER_REGISTER_TEMPLATE = 'New blog user registered.\nName: {name}\nemail: {email}'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Any, Dict, Text
|
||||
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
|
||||
class YoHookTests(WebhookTestCase):
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
# Webhooks for external integrations.
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_private_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import get_user, UserProfile
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Optional
|
||||
|
||||
import ujson
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_private_message
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.models import UserProfile, get_user
|
||||
|
||||
@api_key_only_webhook_view('Yo')
|
||||
@has_request_variables
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
from typing import Any, Callable, Dict
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import api_key_only_webhook_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
|
||||
@api_key_only_webhook_view('Zapier')
|
||||
@has_request_variables
|
||||
def api_zapier_webhook(request, user_profile,
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
# Webhooks for external integrations.
|
||||
from typing import Text
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
|
||||
from zerver.decorator import authenticated_rest_api_view
|
||||
from zerver.lib.actions import check_send_stream_message
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.models import get_client, UserProfile
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from typing import Text
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.models import UserProfile, get_client
|
||||
|
||||
def truncate(string: Text, length: int) -> Text:
|
||||
if len(string) > length:
|
||||
|
||||
Reference in New Issue
Block a user