mirror of https://github.com/zulip/zulip.git
actions: Split out zerver.actions.message_edit.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
5d1a5a3877
commit
eda000899b
|
@ -401,7 +401,7 @@ function edit_message($row, raw_content) {
|
|||
// been able to click it at the time the mouse entered the message_row. Also
|
||||
// a buffer in case their computer is slow, or stalled for a second, etc
|
||||
// If you change this number also change edit_limit_buffer in
|
||||
// zerver.lib.actions.check_update_message
|
||||
// zerver.actions.message_edit.check_update_message
|
||||
const seconds_left_buffer = 5;
|
||||
const editability = get_editability(message, seconds_left_buffer);
|
||||
const max_file_upload_size = page_params.max_file_upload_size_mib;
|
||||
|
@ -534,7 +534,7 @@ function edit_message($row, raw_content) {
|
|||
) {
|
||||
// Give them at least 10 seconds.
|
||||
// If you change this number also change edit_limit_buffer in
|
||||
// zerver.lib.actions.check_update_message
|
||||
// zerver.actions.message_edit.check_update_message
|
||||
const min_seconds_to_edit = 10;
|
||||
let seconds_left =
|
||||
page_params.realm_message_content_edit_limit_seconds +
|
||||
|
|
|
@ -8,7 +8,7 @@ export const RESOLVED_TOPIC_PREFIX = "✔ ";
|
|||
*/
|
||||
// The class has the same characters as RESOLVED_TOPIC_PREFIX.
|
||||
// It's designed to remove a weird "✔ ✔✔ " prefix, if present.
|
||||
// Compare maybe_send_resolve_topic_notifications in zerver/lib/actions.py.
|
||||
// Compare maybe_send_resolve_topic_notifications in zerver/actions/message_edit.py.
|
||||
const RESOLVED_TOPIC_PREFIX_RE = /^✔ [ ✔]*/;
|
||||
|
||||
export function is_resolved(topic_name) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -45,6 +45,11 @@ from zerver.actions.invites import (
|
|||
do_revoke_multi_use_invite,
|
||||
do_revoke_user_invite,
|
||||
)
|
||||
from zerver.actions.message_edit import (
|
||||
do_delete_messages,
|
||||
do_update_embedded_data,
|
||||
do_update_message,
|
||||
)
|
||||
from zerver.actions.message_flags import do_update_message_flags
|
||||
from zerver.actions.muted_users import do_mute_user, do_unmute_user
|
||||
from zerver.actions.presence import do_update_user_presence, do_update_user_status
|
||||
|
@ -99,7 +104,6 @@ from zerver.lib.actions import (
|
|||
do_change_realm_domain,
|
||||
do_change_realm_plan_type,
|
||||
do_deactivate_realm,
|
||||
do_delete_messages,
|
||||
do_remove_realm_domain,
|
||||
do_set_realm_authentication_methods,
|
||||
do_set_realm_message_editing,
|
||||
|
@ -107,8 +111,6 @@ from zerver.lib.actions import (
|
|||
do_set_realm_property,
|
||||
do_set_realm_signup_notifications_stream,
|
||||
do_set_realm_user_default_setting,
|
||||
do_update_embedded_data,
|
||||
do_update_message,
|
||||
)
|
||||
from zerver.lib.drafts import do_create_drafts, do_delete_draft, do_edit_draft
|
||||
from zerver.lib.event_schema import (
|
||||
|
|
|
@ -494,7 +494,7 @@ class TestMocking(ZulipTestCase):
|
|||
# that is beyond the limit.
|
||||
#
|
||||
# Notice how mock.patch() is used here to do exactly the above mentioned.
|
||||
# mock.patch() here makes any calls to `timezone_now` in `zerver.lib.actions`
|
||||
# mock.patch() here makes any calls to `timezone_now` in `zerver.actions.message_edit`
|
||||
# to return the value passed to `return_value` in the its context.
|
||||
# You can also use mock.patch() as a decorator depending on the
|
||||
# requirements. Read more at the documentation link provided above.
|
||||
|
@ -504,7 +504,7 @@ class TestMocking(ZulipTestCase):
|
|||
) # There's a buffer time applied to the limit, hence the extra 100s.
|
||||
|
||||
with mock.patch(
|
||||
"zerver.lib.actions.timezone_now",
|
||||
"zerver.actions.message_edit.timezone_now",
|
||||
return_value=time_beyond_edit_limit,
|
||||
):
|
||||
result = self.client_patch(
|
||||
|
|
|
@ -389,7 +389,7 @@ class PreviewTestCase(ZulipTestCase):
|
|||
url = "http://test.org/"
|
||||
self.create_mock_response(url)
|
||||
|
||||
with mock_queue_publish("zerver.lib.actions.queue_json_publish") as patched:
|
||||
with mock_queue_publish("zerver.actions.message_edit.queue_json_publish") as patched:
|
||||
result = self.client_patch(
|
||||
"/json/messages/" + str(msg_id),
|
||||
{
|
||||
|
@ -509,7 +509,7 @@ class PreviewTestCase(ZulipTestCase):
|
|||
)
|
||||
|
||||
with mock_queue_publish(
|
||||
"zerver.lib.actions.queue_json_publish", wraps=wrapped_queue_json_publish
|
||||
"zerver.actions.message_edit.queue_json_publish", wraps=wrapped_queue_json_publish
|
||||
):
|
||||
result = self.client_patch(
|
||||
"/json/messages/" + str(msg_id),
|
||||
|
|
|
@ -8,18 +8,16 @@ from django.db import IntegrityError
|
|||
from django.http import HttpResponse
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
||||
from zerver.actions.message_edit import (
|
||||
check_update_message,
|
||||
do_delete_messages,
|
||||
do_update_message,
|
||||
get_user_info_for_message_updates,
|
||||
)
|
||||
from zerver.actions.reactions import do_add_reaction
|
||||
from zerver.actions.streams import do_change_stream_post_policy, do_deactivate_stream
|
||||
from zerver.actions.users import do_change_user_role
|
||||
from zerver.lib.actions import (
|
||||
check_update_message,
|
||||
do_change_realm_plan_type,
|
||||
do_delete_messages,
|
||||
do_set_realm_property,
|
||||
do_update_message,
|
||||
get_topic_messages,
|
||||
get_user_info_for_message_updates,
|
||||
)
|
||||
from zerver.lib.actions import do_change_realm_plan_type, do_set_realm_property, get_topic_messages
|
||||
from zerver.lib.message import MessageDict, has_message_access, messages_for_ids
|
||||
from zerver.lib.test_classes import ZulipTestCase
|
||||
from zerver.lib.test_helpers import cache_tries_captured, queries_captured
|
||||
|
@ -1163,7 +1161,7 @@ class EditMessageTest(EditMessageTestCase):
|
|||
message.save()
|
||||
do_edit_message_assert_success(id_, "D", "cordelia")
|
||||
|
||||
@mock.patch("zerver.lib.actions.send_event")
|
||||
@mock.patch("zerver.actions.message_edit.send_event")
|
||||
def test_edit_topic_public_history_stream(self, mock_send_event: mock.MagicMock) -> None:
|
||||
stream_name = "Macbeth"
|
||||
hamlet = self.example_user("hamlet")
|
||||
|
@ -1245,7 +1243,7 @@ class EditMessageTest(EditMessageTestCase):
|
|||
users_to_be_notified = list(map(notify, [hamlet.id]))
|
||||
do_update_message_topic_success(hamlet, message, "Change again", users_to_be_notified)
|
||||
|
||||
@mock.patch("zerver.lib.actions.send_event")
|
||||
@mock.patch("zerver.actions.message_edit.send_event")
|
||||
def test_edit_muted_topic(self, mock_send_event: mock.MagicMock) -> None:
|
||||
stream_name = "Stream 123"
|
||||
stream = self.make_stream(stream_name)
|
||||
|
@ -1487,7 +1485,7 @@ class EditMessageTest(EditMessageTestCase):
|
|||
self.assertFalse(topic_is_muted(cordelia, new_public_stream.id, "final topic name"))
|
||||
self.assertFalse(topic_is_muted(aaron, new_public_stream.id, "final topic name"))
|
||||
|
||||
@mock.patch("zerver.lib.actions.send_event")
|
||||
@mock.patch("zerver.actions.message_edit.send_event")
|
||||
def test_wildcard_mention(self, mock_send_event: mock.MagicMock) -> None:
|
||||
stream_name = "Macbeth"
|
||||
hamlet = self.example_user("hamlet")
|
||||
|
@ -2889,7 +2887,7 @@ class DeleteMessageTest(ZulipTestCase):
|
|||
message = self.get_last_message()
|
||||
|
||||
with self.tornado_redirected_to_list([], expected_num_events=1):
|
||||
with mock.patch("zerver.lib.actions.send_event") as m:
|
||||
with mock.patch("zerver.actions.message_edit.send_event") as m:
|
||||
m.side_effect = AssertionError(
|
||||
"Events should be sent only after the transaction commits."
|
||||
)
|
||||
|
|
|
@ -13,9 +13,10 @@ from sqlalchemy.types import Integer
|
|||
|
||||
from analytics.lib.counts import COUNT_STATS
|
||||
from analytics.models import RealmCount
|
||||
from zerver.actions.message_edit import do_update_message
|
||||
from zerver.actions.uploads import do_claim_attachments
|
||||
from zerver.actions.users import do_deactivate_user
|
||||
from zerver.lib.actions import do_set_realm_property, do_update_message
|
||||
from zerver.lib.actions import do_set_realm_property
|
||||
from zerver.lib.avatar import avatar_url
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.lib.mention import MentionBackend, MentionData
|
||||
|
|
|
@ -23,9 +23,9 @@ from requests.models import PreparedRequest
|
|||
|
||||
from analytics.lib.counts import CountStat, LoggingCountStat
|
||||
from analytics.models import InstallationCount, RealmCount
|
||||
from zerver.actions.message_edit import do_delete_messages
|
||||
from zerver.actions.message_flags import do_mark_stream_messages_as_read, do_update_message_flags
|
||||
from zerver.actions.user_settings import do_regenerate_api_key
|
||||
from zerver.lib.actions import do_delete_messages
|
||||
from zerver.lib.avatar import absolute_avatar_url
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.lib.push_notifications import (
|
||||
|
|
|
@ -5,9 +5,10 @@ from unittest import mock
|
|||
from django.conf import settings
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
||||
from zerver.actions.message_edit import do_delete_messages
|
||||
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
|
||||
from zerver.lib.actions import do_create_realm, do_set_realm_property
|
||||
from zerver.lib.retention import (
|
||||
archive_messages,
|
||||
clean_archived_data,
|
||||
|
|
|
@ -8,8 +8,8 @@ from django.http import HttpRequest, HttpResponse
|
|||
from django.utils.timezone import now as timezone_now
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from zerver.actions.message_edit import check_update_message, do_delete_messages
|
||||
from zerver.context_processors import get_valid_realm_from_request
|
||||
from zerver.lib.actions import check_update_message, do_delete_messages
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.lib.html_diff import highlight_html_differences
|
||||
from zerver.lib.message import access_message, access_web_public_message, messages_for_ids
|
||||
|
|
|
@ -21,6 +21,7 @@ from zerver.actions.default_streams import (
|
|||
do_remove_streams_from_default_stream_group,
|
||||
get_default_streams_for_realm,
|
||||
)
|
||||
from zerver.actions.message_edit import do_delete_messages
|
||||
from zerver.actions.message_send import (
|
||||
do_send_messages,
|
||||
internal_prep_private_message,
|
||||
|
@ -45,7 +46,6 @@ from zerver.decorator import (
|
|||
require_post,
|
||||
require_realm_admin,
|
||||
)
|
||||
from zerver.lib.actions import do_delete_messages
|
||||
from zerver.lib.exceptions import (
|
||||
ErrorCode,
|
||||
JsonableError,
|
||||
|
|
|
@ -47,13 +47,13 @@ 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_edit import do_update_embedded_data
|
||||
from zerver.actions.message_flags import do_mark_stream_messages_as_read
|
||||
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_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
|
||||
|
@ -865,7 +865,7 @@ class FetchLinksEmbedData(QueueProcessingWorker):
|
|||
|
||||
message = Message.objects.get(id=event["message_id"])
|
||||
# If the message changed, we will run this task after updating the message
|
||||
# in zerver.lib.actions.check_update_message
|
||||
# in zerver.actions.message_edit.check_update_message
|
||||
if message.content != event["message_content"]:
|
||||
return
|
||||
if message.content is not None:
|
||||
|
|
Loading…
Reference in New Issue