actions: Split out zerver.actions.message_send.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-04-14 14:50:10 -07:00
parent ec6355389a
commit 975066e3f0
38 changed files with 1755 additions and 1716 deletions

View File

@ -971,7 +971,8 @@ def update_sponsorship_status(
def approve_sponsorship(realm: Realm, *, acting_user: Optional[UserProfile]) -> None:
from zerver.lib.actions import do_change_realm_plan_type, internal_send_private_message
from zerver.actions.message_send import internal_send_private_message
from zerver.lib.actions import do_change_realm_plan_type
do_change_realm_plan_type(realm, Realm.PLAN_TYPE_STANDARD_FREE, acting_user=acting_user)
customer = get_customer_by_realm(realm)

View File

@ -71,12 +71,12 @@ This section details the ways in which it is different:
`apply_markdown` and `client_gravatar` features in our
[events API docs](https://zulip.com/api/register-queue)).
- Following our standard naming convention, input validation is done
inside the `check_message` function in `zerver/lib/actions.py`, which is responsible for
inside the `check_message` function in `zerver/actions/message_send.py`, which is responsible for
validating the user can send to the recipient,
[rendering the Markdown](markdown.md), etc. --
basically everything that can fail due to bad user input.
- The core `do_send_messages` function (which handles actually sending
the message) in `zerver/lib/actions.py` is one of the most optimized and thus complex parts of
the message) in `zerver/actions/message_send.py` is one of the most optimized and thus complex parts of
the system. But in short, its job is to atomically do a few key
things:
- Store a `Message` row in the database.

View File

@ -23,7 +23,7 @@ def zerver.lib.avatar_hash.user_avatar_path_from_ids(user_profile_id, realm_id)
# This function creates a list of 'UserMessageLite' objects, which contain only
# integral IDs and flags. These should safe for use with SQL and other
# operations.
def zerver.lib.actions.create_user_messages(
def zerver.actions.message_send.create_user_messages(
message,
um_eligible_user_ids,
long_term_idle_user_ids,

View File

@ -378,7 +378,7 @@ python_rules = RuleList(
"exclude_line": {
# This one in check_message is kinda terrible, since it's
# how most instances are written, but better to exclude something than nothing
("zerver/lib/actions.py", "stream = get_stream(stream_name, realm)"),
("zerver/actions/message_send.py", "stream = get_stream(stream_name, realm)"),
},
"description": "Please use access_stream_by_*() to fetch Stream objects",
},

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ from django.conf import settings
from django.utils.translation import gettext as _
from zulip_bots.lib import BotIdentity, RateLimit
from zerver.lib.actions import (
from zerver.actions.message_send import (
internal_send_huddle_message,
internal_send_private_message,
internal_send_stream_message_by_name,

View File

@ -9,7 +9,7 @@ from django.conf import settings
from django.utils.timezone import now as timezone_now
from django.utils.timezone import timedelta
from zerver.lib.actions import (
from zerver.actions.message_send import (
check_send_message,
internal_send_huddle_message,
internal_send_private_message,

View File

@ -5,8 +5,8 @@ from typing import Any, Dict
from django.conf import settings
from django.core.mail import mail_admins
from zerver.actions.message_send import internal_send_stream_message
from zerver.filters import clean_data_from_query_parameters
from zerver.lib.actions import internal_send_stream_message
from zerver.models import get_realm, get_stream, get_system_bot

View File

@ -5,13 +5,12 @@ from django.db import transaction
from django.db.models import Count
from django.utils.translation import gettext as _
from zerver.lib.actions import (
do_add_reaction,
from zerver.actions.message_send import (
do_send_messages,
internal_prep_stream_message_by_name,
internal_send_private_message,
setup_realm_internal_bots,
)
from zerver.lib.actions import do_add_reaction, setup_realm_internal_bots
from zerver.lib.emoji import emoji_name_to_emoji_code
from zerver.lib.message import SendMessageRequest
from zerver.models import Message, Realm, UserProfile, get_system_bot

View File

@ -10,7 +10,7 @@ from django.utils.translation import gettext as _
from requests import Response
from version import ZULIP_VERSION
from zerver.lib.actions import check_send_message
from zerver.actions.message_send import check_send_message
from zerver.lib.exceptions import JsonableError
from zerver.lib.message import MessageDict
from zerver.lib.outgoing_http import OutgoingSession

View File

@ -47,12 +47,11 @@ from fakeldap import MockLDAP
from two_factor.models import PhoneDevice
from corporate.models import Customer, CustomerPlan, LicenseLedger
from zerver.actions.message_send import check_send_message, check_send_stream_message
from zerver.decorator import do_two_factor_login
from zerver.lib.actions import (
bulk_add_subscriptions,
bulk_remove_subscriptions,
check_send_message,
check_send_stream_message,
do_set_realm_property,
)
from zerver.lib.cache import bounce_key_prefix_for_testing

View File

@ -7,7 +7,7 @@ from urllib.parse import unquote
from django.http import HttpRequest
from django.utils.translation import gettext as _
from zerver.lib.actions import (
from zerver.actions.message_send import (
check_send_private_message,
check_send_stream_message,
check_send_stream_message_by_id,

View File

@ -8,7 +8,7 @@ from django.core.management.base import BaseCommand
from django.db import transaction
from django.utils.timezone import now as timezone_now
from zerver.lib.actions import build_message_send_dict, do_send_messages
from zerver.actions.message_send import build_message_send_dict, do_send_messages
from zerver.lib.logging_util import log_to_file
from zerver.lib.message import SendMessageRequest
from zerver.models import Message, ScheduledMessage, get_user_by_delivery_email

View File

@ -8,9 +8,10 @@ from django.http import HttpRequest, HttpResponse
from django.utils.timezone import now as timezone_now
from version import API_FEATURE_LEVEL, ZULIP_MERGE_BASE, ZULIP_VERSION
from zerver.actions.message_send import check_send_message
from zerver.actions.presence import do_update_user_presence
from zerver.actions.users import do_change_user_role
from zerver.lib.actions import check_send_message, do_set_realm_property
from zerver.lib.actions import do_set_realm_property
from zerver.lib.event_schema import check_restart_event
from zerver.lib.events import fetch_initial_state_data
from zerver.lib.exceptions import AccessDeniedError

View File

@ -420,7 +420,7 @@ class PreviewTestCase(ZulipTestCase):
self, sender: UserProfile, queue_should_run: bool = True, relative_url: bool = False
) -> Message:
url = "http://test.org/"
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
with mock_queue_publish("zerver.actions.message_send.queue_json_publish") as patched:
msg_id = self.send_personal_message(
sender,
self.example_user("cordelia"),
@ -462,7 +462,7 @@ class PreviewTestCase(ZulipTestCase):
self.login_user(user)
original_url = "http://test.org/"
edited_url = "http://edited.org/"
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
with mock_queue_publish("zerver.actions.message_send.queue_json_publish") as patched:
msg_id = self.send_stream_message(
user, "Denmark", topic_name="foo", content=original_url
)
@ -573,7 +573,7 @@ class PreviewTestCase(ZulipTestCase):
user = self.example_user("hamlet")
self.login_user(user)
url = "http://test.org/"
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
with mock_queue_publish("zerver.actions.message_send.queue_json_publish") as patched:
msg_id = self.send_stream_message(user, "Denmark", topic_name="foo", content=url)
patched.assert_called_once()
queue = patched.call_args[0][0]
@ -606,7 +606,7 @@ class PreviewTestCase(ZulipTestCase):
@override_settings(INLINE_URL_EMBED_PREVIEW=True)
def test_inline_relative_url_embed_preview(self) -> None:
# Relative URLs should not be sent for URL preview.
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
with mock_queue_publish("zerver.actions.message_send.queue_json_publish") as patched:
self.send_personal_message(
self.example_user("prospero"),
self.example_user("cordelia"),
@ -677,7 +677,7 @@ class PreviewTestCase(ZulipTestCase):
user = self.example_user("hamlet")
self.login_user(user)
url = "http://test.org/audio.mp3"
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
with mock_queue_publish("zerver.actions.message_send.queue_json_publish") as patched:
msg_id = self.send_stream_message(user, "Denmark", topic_name="foo", content=url)
patched.assert_called_once()
queue = patched.call_args[0][0]
@ -709,7 +709,7 @@ class PreviewTestCase(ZulipTestCase):
user = self.example_user("hamlet")
self.login_user(user)
url = "http://test.org/foo.html"
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
with mock_queue_publish("zerver.actions.message_send.queue_json_publish") as patched:
msg_id = self.send_stream_message(user, "Denmark", topic_name="foo", content=url)
patched.assert_called_once()
queue = patched.call_args[0][0]
@ -744,7 +744,7 @@ class PreviewTestCase(ZulipTestCase):
user = self.example_user("hamlet")
self.login_user(user)
url = "http://test.org/foo.html"
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
with mock_queue_publish("zerver.actions.message_send.queue_json_publish") as patched:
msg_id = self.send_stream_message(user, "Denmark", topic_name="foo", content=url)
patched.assert_called_once()
queue = patched.call_args[0][0]
@ -782,7 +782,7 @@ class PreviewTestCase(ZulipTestCase):
user = self.example_user("hamlet")
self.login_user(user)
url = "http://test.org/foo.html"
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
with mock_queue_publish("zerver.actions.message_send.queue_json_publish") as patched:
msg_id = self.send_stream_message(user, "Denmark", topic_name="foo", content=url)
patched.assert_called_once()
queue = patched.call_args[0][0]
@ -819,7 +819,7 @@ class PreviewTestCase(ZulipTestCase):
user = self.example_user("hamlet")
self.login_user(user)
url = "http://test.org/"
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
with mock_queue_publish("zerver.actions.message_send.queue_json_publish") as patched:
msg_id = self.send_stream_message(user, "Denmark", topic_name="foo", content=url)
patched.assert_called_once()
queue = patched.call_args[0][0]
@ -847,7 +847,7 @@ class PreviewTestCase(ZulipTestCase):
@override_settings(INLINE_URL_EMBED_PREVIEW=True)
def test_valid_content_type_error_get_data(self) -> None:
url = "http://test.org/"
with mock_queue_publish("zerver.lib.actions.queue_json_publish"):
with mock_queue_publish("zerver.actions.message_send.queue_json_publish"):
msg_id = self.send_personal_message(
self.example_user("hamlet"),
self.example_user("cordelia"),
@ -891,7 +891,7 @@ class PreviewTestCase(ZulipTestCase):
def test_invalid_url(self) -> None:
url = "http://test.org/"
error_url = "http://test.org/x"
with mock_queue_publish("zerver.lib.actions.queue_json_publish"):
with mock_queue_publish("zerver.actions.message_send.queue_json_publish"):
msg_id = self.send_personal_message(
self.example_user("hamlet"),
self.example_user("cordelia"),
@ -927,7 +927,7 @@ class PreviewTestCase(ZulipTestCase):
@override_settings(INLINE_URL_EMBED_PREVIEW=True)
def test_safe_oembed_html_url(self) -> None:
url = "http://test.org/"
with mock_queue_publish("zerver.lib.actions.queue_json_publish"):
with mock_queue_publish("zerver.actions.message_send.queue_json_publish"):
msg_id = self.send_personal_message(
self.example_user("hamlet"),
self.example_user("cordelia"),
@ -969,7 +969,7 @@ class PreviewTestCase(ZulipTestCase):
@override_settings(INLINE_URL_EMBED_PREVIEW=True)
def test_youtube_url_title_replaces_url(self) -> None:
url = "https://www.youtube.com/watch?v=eSJTXC7Ixgg"
with mock_queue_publish("zerver.lib.actions.queue_json_publish"):
with mock_queue_publish("zerver.actions.message_send.queue_json_publish"):
msg_id = self.send_personal_message(
self.example_user("hamlet"),
self.example_user("cordelia"),
@ -1005,7 +1005,7 @@ class PreviewTestCase(ZulipTestCase):
@override_settings(INLINE_URL_EMBED_PREVIEW=True)
def test_custom_title_replaces_youtube_url_title(self) -> None:
url = "[YouTube link](https://www.youtube.com/watch?v=eSJTXC7Ixgg)"
with mock_queue_publish("zerver.lib.actions.queue_json_publish"):
with mock_queue_publish("zerver.actions.message_send.queue_json_publish"):
msg_id = self.send_personal_message(
self.example_user("hamlet"),
self.example_user("cordelia"),

View File

@ -10,17 +10,11 @@ from django.http import HttpResponse
from django.test import override_settings
from django.utils.timezone import now as timezone_now
from zerver.actions.users import do_change_can_forge_sender, do_deactivate_user
from zerver.lib.actions import (
from zerver.actions.message_send import (
build_message_send_dict,
check_message,
check_send_stream_message,
do_add_realm_domain,
do_change_stream_post_policy,
do_create_realm,
do_create_user,
do_send_messages,
do_set_realm_property,
extract_private_recipients,
extract_stream_indicator,
internal_prep_private_message,
@ -31,6 +25,14 @@ from zerver.lib.actions import (
internal_send_stream_message_by_name,
send_rate_limited_pm_notification_to_bot_owner,
)
from zerver.actions.users import do_change_can_forge_sender, do_deactivate_user
from zerver.lib.actions import (
do_add_realm_domain,
do_change_stream_post_policy,
do_create_realm,
do_create_user,
do_set_realm_property,
)
from zerver.lib.addressee import Addressee
from zerver.lib.cache import cache_delete, get_stream_cache_key
from zerver.lib.exceptions import JsonableError

View File

@ -3,7 +3,7 @@ from typing import List
from django.utils.timezone import now as timezone_now
from zerver.lib.actions import get_active_presence_idle_user_ids
from zerver.actions.message_send import get_active_presence_idle_user_ids
from zerver.lib.test_classes import ZulipTestCase
from zerver.models import (
Message,

View File

@ -4,7 +4,7 @@ from unittest import mock
from django.db import IntegrityError
from django.utils.timezone import now as timezone_now
from zerver.lib.actions import create_mirror_user_if_needed
from zerver.actions.message_send import create_mirror_user_if_needed
from zerver.lib.create_user import create_user_profile
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import reset_emails_in_zulip_realm
@ -172,7 +172,7 @@ class MirroredMessageUsersTest(ZulipTestCase):
create_user_profile(**kwargs).save()
raise IntegrityError()
with mock.patch("zerver.lib.actions.create_user", side_effect=create_user) as m:
with mock.patch("zerver.actions.message_send.create_user", side_effect=create_user) as m:
mirror_fred_user = create_mirror_user_if_needed(
realm,
email,

View File

@ -254,7 +254,7 @@ class UserPresenceTests(ZulipTestCase):
def test_filter_presence_idle_user_ids(self) -> None:
user_profile = self.example_user("hamlet")
from zerver.lib.actions import filter_presence_idle_user_ids
from zerver.actions.message_send import filter_presence_idle_user_ids
self.login("hamlet")

View File

@ -5,13 +5,9 @@ from unittest import mock
from django.conf import settings
from django.utils.timezone import now as timezone_now
from zerver.actions.message_send import internal_send_private_message
from zerver.actions.submessage import do_add_submessage
from zerver.lib.actions import (
do_create_realm,
do_delete_messages,
do_set_realm_property,
internal_send_private_message,
)
from zerver.lib.actions import do_create_realm, do_delete_messages, do_set_realm_property
from zerver.lib.retention import (
archive_messages,
clean_archived_data,

View File

@ -6,7 +6,8 @@ import orjson
from django.conf import settings
from django.test import override_settings
from zerver.lib.actions import do_create_user, get_service_bot_events
from zerver.actions.message_send import get_service_bot_events
from zerver.lib.actions import do_create_user
from zerver.lib.bot_config import ConfigError, load_bot_config_template, set_bot_config
from zerver.lib.bot_lib import EmbeddedBotEmptyRecipientsList, EmbeddedBotHandler, StateHandler
from zerver.lib.bot_storage import StateError
@ -452,7 +453,7 @@ class TestServiceBotEventTriggers(ZulipTestCase):
)
@for_all_bot_types
@patch_queue_publish("zerver.lib.actions.queue_json_publish")
@patch_queue_publish("zerver.actions.message_send.queue_json_publish")
def test_trigger_on_stream_mention_from_user(self, mock_queue_json_publish: mock.Mock) -> None:
content = "@**FooBot** foo bar!!!"
recipient = "Denmark"
@ -478,7 +479,7 @@ class TestServiceBotEventTriggers(ZulipTestCase):
self.send_stream_message(self.user_profile, "Denmark", content)
self.assertTrue(mock_queue_json_publish.called)
@patch_queue_publish("zerver.lib.actions.queue_json_publish")
@patch_queue_publish("zerver.actions.message_send.queue_json_publish")
def test_no_trigger_on_stream_message_without_mention(
self, mock_queue_json_publish: mock.Mock
) -> None:
@ -487,7 +488,7 @@ class TestServiceBotEventTriggers(ZulipTestCase):
self.assertFalse(mock_queue_json_publish.called)
@for_all_bot_types
@patch_queue_publish("zerver.lib.actions.queue_json_publish")
@patch_queue_publish("zerver.actions.message_send.queue_json_publish")
def test_no_trigger_on_stream_mention_from_bot(
self, mock_queue_json_publish: mock.Mock
) -> None:
@ -495,7 +496,7 @@ class TestServiceBotEventTriggers(ZulipTestCase):
self.assertFalse(mock_queue_json_publish.called)
@for_all_bot_types
@patch_queue_publish("zerver.lib.actions.queue_json_publish")
@patch_queue_publish("zerver.actions.message_send.queue_json_publish")
def test_trigger_on_personal_message_from_user(
self, mock_queue_json_publish: mock.Mock
) -> None:
@ -525,7 +526,7 @@ class TestServiceBotEventTriggers(ZulipTestCase):
self.assertTrue(mock_queue_json_publish.called)
@for_all_bot_types
@patch_queue_publish("zerver.lib.actions.queue_json_publish")
@patch_queue_publish("zerver.actions.message_send.queue_json_publish")
def test_no_trigger_on_personal_message_from_bot(
self, mock_queue_json_publish: mock.Mock
) -> None:
@ -535,7 +536,7 @@ class TestServiceBotEventTriggers(ZulipTestCase):
self.assertFalse(mock_queue_json_publish.called)
@for_all_bot_types
@patch_queue_publish("zerver.lib.actions.queue_json_publish")
@patch_queue_publish("zerver.actions.message_send.queue_json_publish")
def test_trigger_on_huddle_message_from_user(self, mock_queue_json_publish: mock.Mock) -> None:
self.second_bot_profile.bot_type = self.bot_profile.bot_type
self.second_bot_profile.save()
@ -563,7 +564,7 @@ class TestServiceBotEventTriggers(ZulipTestCase):
self.assertEqual(mock_queue_json_publish.call_count, 2)
@for_all_bot_types
@patch_queue_publish("zerver.lib.actions.queue_json_publish")
@patch_queue_publish("zerver.actions.message_send.queue_json_publish")
def test_no_trigger_on_huddle_message_from_bot(
self, mock_queue_json_publish: mock.Mock
) -> None:

View File

@ -1,6 +1,6 @@
from django.conf import settings
from zerver.lib.actions import internal_send_private_message
from zerver.actions.message_send import internal_send_private_message
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import message_stream_count, most_recent_message
from zerver.models import UserProfile, get_system_bot

View File

@ -19,16 +19,12 @@ from django_sendfile.utils import _get_sendfile
from PIL import Image
import zerver.lib.upload
from zerver.actions.message_send import internal_send_private_message
from zerver.actions.realm_icon import do_change_icon_source
from zerver.actions.realm_logo import do_change_logo_source
from zerver.actions.uploads import do_delete_old_unclaimed_attachments
from zerver.actions.user_settings import do_delete_avatar_image
from zerver.lib.actions import (
do_change_realm_plan_type,
do_create_realm,
do_set_realm_property,
internal_send_private_message,
)
from zerver.lib.actions import do_change_realm_plan_type, do_create_realm, do_set_realm_property
from zerver.lib.avatar import avatar_url, get_avatar_field
from zerver.lib.avatar_hash import user_avatar_path
from zerver.lib.cache import cache_get, get_realm_used_upload_space_cache_key

View File

@ -13,6 +13,7 @@ from django.utils.timezone import now as timezone_now
from confirmation.models import Confirmation
from zerver.actions.invites import do_create_multiuse_invite_link, do_invite_users
from zerver.actions.message_send import get_recipient_info
from zerver.actions.users import (
change_user_is_active,
do_change_can_create_users,
@ -25,7 +26,6 @@ from zerver.lib.actions import (
do_mute_user,
do_reactivate_user,
do_set_realm_property,
get_recipient_info,
)
from zerver.lib.avatar import avatar_url, get_gravatar_url
from zerver.lib.bulk_create import create_users

View File

@ -8,7 +8,7 @@ from django.http import HttpRequest, HttpResponse
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from zerver.lib.actions import (
from zerver.actions.message_send import (
check_schedule_message,
check_send_message,
compute_irc_user_fullname,

View File

@ -21,6 +21,11 @@ from zerver.actions.default_streams import (
do_remove_streams_from_default_stream_group,
get_default_streams_for_realm,
)
from zerver.actions.message_send import (
do_send_messages,
internal_prep_private_message,
internal_prep_stream_message,
)
from zerver.context_processors import get_valid_realm_from_request
from zerver.decorator import (
authenticated_json_view,
@ -39,10 +44,7 @@ from zerver.lib.actions import (
do_deactivate_stream,
do_delete_messages,
do_rename_stream,
do_send_messages,
get_subscriber_ids,
internal_prep_private_message,
internal_prep_stream_message,
)
from zerver.lib.exceptions import (
ErrorCode,

View File

@ -3,8 +3,8 @@ from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from zerver.actions.message_send import check_send_private_message
from zerver.decorator import webhook_view
from zerver.lib.actions import check_send_private_message
from zerver.lib.request import REQ, RequestNotes, has_request_variables
from zerver.lib.response import json_success
from zerver.models import UserProfile, get_user

View File

@ -4,8 +4,8 @@ import dateutil.parser
from django.http import HttpRequest, HttpResponse
from django.utils.translation import gettext as _
from zerver.actions.message_send import send_rate_limited_pm_notification_to_bot_owner
from zerver.decorator import webhook_view
from zerver.lib.actions import send_rate_limited_pm_notification_to_bot_owner
from zerver.lib.exceptions import JsonableError
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success

View File

@ -2,8 +2,8 @@ from django.http import HttpRequest
from django.http.response import HttpResponse
from django.utils.translation import gettext as _
from zerver.actions.message_send import check_send_stream_message
from zerver.decorator import webhook_view
from zerver.lib.actions import check_send_stream_message
from zerver.lib.exceptions import JsonableError
from zerver.lib.request import REQ, RequestNotes, has_request_variables
from zerver.lib.response import json_success

View File

@ -5,11 +5,11 @@ from typing import Any, Dict, List, Optional
from django.db.models import Q
from django.http import HttpRequest, HttpResponse
from zerver.decorator import webhook_view
from zerver.lib.actions import (
from zerver.actions.message_send import (
check_send_private_message,
send_rate_limited_pm_notification_to_bot_owner,
)
from zerver.decorator import webhook_view
from zerver.lib.request import REQ, RequestNotes, has_request_variables
from zerver.lib.response import json_success
from zerver.lib.send_email import FromAddress

View File

@ -3,8 +3,8 @@ from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from django.utils.translation import gettext as _
from zerver.actions.message_send import send_rate_limited_pm_notification_to_bot_owner
from zerver.decorator import webhook_view
from zerver.lib.actions import send_rate_limited_pm_notification_to_bot_owner
from zerver.lib.exceptions import JsonableError
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success

View File

@ -3,8 +3,8 @@ from typing import Optional
from django.http import HttpRequest, HttpResponse
from zerver.actions.message_send import check_send_private_message
from zerver.decorator import webhook_view
from zerver.lib.actions import check_send_private_message
from zerver.lib.request import REQ, RequestNotes, has_request_variables
from zerver.lib.response import json_success
from zerver.models import UserProfile, get_user

View File

@ -3,8 +3,8 @@ from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from django.utils.translation import gettext as _
from zerver.actions.message_send import send_rate_limited_pm_notification_to_bot_owner
from zerver.decorator import webhook_view
from zerver.lib.actions import send_rate_limited_pm_notification_to_bot_owner
from zerver.lib.exceptions import JsonableError
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success

View File

@ -47,16 +47,12 @@ from sentry_sdk import add_breadcrumb, configure_scope
from zulip_bots.lib import extract_query_without_mention
from zerver.actions.invites import do_send_confirmation_email
from zerver.actions.message_send import internal_send_private_message, render_incoming_message
from zerver.actions.presence import do_update_user_presence
from zerver.actions.realm_export import notify_realm_export
from zerver.actions.user_activity import do_update_user_activity, do_update_user_activity_interval
from zerver.context_processors import common_context
from zerver.lib.actions import (
do_mark_stream_messages_as_read,
do_update_embedded_data,
internal_send_private_message,
render_incoming_message,
)
from zerver.lib.actions import do_mark_stream_messages_as_read, do_update_embedded_data
from zerver.lib.bot_lib import EmbeddedBotHandler, EmbeddedBotQuitException, get_bot_handler
from zerver.lib.context_managers import lockfile
from zerver.lib.db import reset_queries

View File

@ -2,14 +2,9 @@ from typing import Any, Dict, List
from django.core.management.base import BaseCommand
from zerver.actions.message_send import do_send_messages, internal_prep_stream_message
from zerver.actions.user_settings import do_change_avatar_fields
from zerver.lib.actions import (
bulk_add_subscriptions,
do_add_reaction,
do_create_user,
do_send_messages,
internal_prep_stream_message,
)
from zerver.lib.actions import bulk_add_subscriptions, do_add_reaction, do_create_user
from zerver.lib.emoji import emoji_name_to_emoji_code
from zerver.lib.streams import ensure_stream
from zerver.lib.upload import upload_avatar_image

View File

@ -23,9 +23,10 @@ from zerver.actions.custom_profile_fields import (
try_add_realm_custom_profile_field,
try_add_realm_default_custom_profile_field,
)
from zerver.actions.message_send import build_message_send_dict, do_send_messages
from zerver.actions.realm_emoji import check_add_realm_emoji
from zerver.actions.users import do_change_user_role
from zerver.lib.actions import build_message_send_dict, do_create_realm, do_send_messages
from zerver.lib.actions import do_create_realm
from zerver.lib.bulk_create import bulk_create_streams
from zerver.lib.cache import cache_set
from zerver.lib.generate_test_data import create_test_data, generate_topics

View File

@ -469,7 +469,7 @@ OUTGOING_WEBHOOK_TIMEOUT_SECONDS = 10
# Maximum length of message content allowed.
# Any message content exceeding this limit will be truncated.
# See: `_internal_prep_message` function in zerver/lib/actions.py.
# See: `_internal_prep_message` function in zerver/actions/message_send.py.
MAX_MESSAGE_LENGTH = 10000
# The maximum number of drafts to send in the response to /register.