Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

dead code: Remove legacy reaction actions.

Steve Howell2a9cb4c8cf79
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index 1ce1f9a9ad4..43e062224d6 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -83,7 +83,7 @@ from zerver.lib.email_validation import (
get_realm_email_validator,
validate_email_is_valid,
)
-from zerver.lib.emoji import emoji_name_to_emoji_code, get_emoji_file_name
+from zerver.lib.emoji import get_emoji_file_name
from zerver.lib.exceptions import (
ErrorCode,
JsonableError,
@@ -1808,28 +1808,6 @@ def notify_reaction_update(user_profile: UserProfile, message: Message,
ums = UserMessage.objects.filter(message=message.id)
send_event(user_profile.realm, event, [um.user_profile_id for um in ums])
-def do_add_reaction_legacy(user_profile: UserProfile, message: Message, emoji_name: str) -> None:
- (emoji_code, reaction_type) = emoji_name_to_emoji_code(user_profile.realm, emoji_name)
- reaction = Reaction(user_profile=user_profile, message=message,
- emoji_name=emoji_name, emoji_code=emoji_code,
- reaction_type=reaction_type)
- try:
- reaction.save()
- except django.db.utils.IntegrityError: # nocoverage
- # This can happen when a race results in the check in views
- # code not catching an attempt to double-add a reaction, or
- # perhaps if the emoji_name/emoji_code mapping is busted.
- raise JsonableError(_("Reaction already exists."))
-
- notify_reaction_update(user_profile, message, reaction, "add")
-
-def do_remove_reaction_legacy(user_profile: UserProfile, message: Message, emoji_name: str) -> None:
- reaction = Reaction.objects.filter(user_profile=user_profile,
- message=message,
- emoji_name=emoji_name).get()
- reaction.delete()
- notify_reaction_update(user_profile, message, reaction, "remove")
-
def do_add_reaction(user_profile: UserProfile, message: Message,
emoji_name: str, emoji_code: str, reaction_type: str) -> None:
reaction = Reaction(user_profile=user_profile, message=message,
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index 0437572c209..9528abbfd01 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -21,7 +21,6 @@ from zerver.lib.actions import (
do_add_alert_words,
do_add_default_stream,
do_add_reaction,
- do_add_reaction_legacy,
do_add_realm_domain,
do_add_realm_filter,
do_add_streams_to_default_stream_group,
@@ -61,7 +60,6 @@ from zerver.lib.actions import (
do_remove_default_stream,
do_remove_default_stream_group,
do_remove_reaction,
- do_remove_reaction_legacy,
do_remove_realm_domain,
do_remove_realm_emoji,
do_remove_realm_filter,
@@ -591,57 +589,6 @@ class NormalActionsTest(BaseAction):
state_change_expected=True,
)
- def test_add_reaction_legacy(self) -> None:
- schema_checker = check_events_dict([
- ('type', equals('reaction')),
- ('op', equals('add')),
- ('message_id', check_int),
- ('emoji_name', check_string),
- ('emoji_code', check_string),
- ('reaction_type', check_string),
- ('user_id', check_int),
- ('user', check_dict_only([
- ('email', check_string),
- ('full_name', check_string),
- ('user_id', check_int),
- ])),
- ])
-
- message_id = self.send_stream_message(self.example_user("hamlet"), "Verona", "hello")
- message = Message.objects.get(id=message_id)
- events = self.verify_action(
- lambda: do_add_reaction_legacy(
- self.user_profile, message, "tada"),
- state_change_expected=False,
- )
- schema_checker('events[0]', events[0])
-
- def test_remove_reaction_legacy(self) -> None:
- schema_checker = check_events_dict([
- ('type', equals('reaction')),
- ('op', equals('remove')),
- ('message_id', check_int),
- ('emoji_name', check_string),
- ('emoji_code', check_string),
- ('reaction_type', check_string),
- ('user_id', check_int),
- ('user', check_dict_only([
- ('email', check_string),
- ('full_name', check_string),
- ('user_id', check_int),
- ])),
- ])
-
- message_id = self.send_stream_message(self.example_user("hamlet"), "Verona", "hello")
- message = Message.objects.get(id=message_id)
- do_add_reaction_legacy(self.user_profile, message, "tada")
- events = self.verify_action(
- lambda: do_remove_reaction_legacy(
- self.user_profile, message, "tada"),
- state_change_expected=False,
- )
- schema_checker('events[0]', events[0])
-
def test_add_reaction(self) -> None:
schema_checker = check_events_dict([
('type', equals('reaction')),