mirror of https://github.com/zulip/zulip.git
edit_history: Stop writing prev_subject to the database.
Now that we have code to support reading prev_topic, this is no longer necessary. We'll want to deploy this change to production before running the migration to remove prev_subject from edit history entries, so that prev_subject can be fully purged from the database.
This commit is contained in:
parent
5e819cdebc
commit
a3a9adbfa9
|
@ -6874,7 +6874,6 @@ def do_update_message(
|
||||||
event[ORIG_TOPIC] = orig_topic_name
|
event[ORIG_TOPIC] = orig_topic_name
|
||||||
event[TOPIC_NAME] = topic_name
|
event[TOPIC_NAME] = topic_name
|
||||||
event[TOPIC_LINKS] = topic_links(target_message.sender.realm_id, topic_name)
|
event[TOPIC_LINKS] = topic_links(target_message.sender.realm_id, topic_name)
|
||||||
edit_history_event["prev_subject"] = orig_topic_name
|
|
||||||
edit_history_event["prev_topic"] = orig_topic_name
|
edit_history_event["prev_topic"] = orig_topic_name
|
||||||
edit_history_event["topic"] = topic_name
|
edit_history_event["topic"] = topic_name
|
||||||
|
|
||||||
|
@ -6891,8 +6890,6 @@ def do_update_message(
|
||||||
"timestamp": edit_history_event["timestamp"],
|
"timestamp": edit_history_event["timestamp"],
|
||||||
}
|
}
|
||||||
if topic_name is not None:
|
if topic_name is not None:
|
||||||
# For backwards-compatability, we include this legacy field name.
|
|
||||||
topic_only_edit_history_event["prev_subject"] = edit_history_event["prev_subject"]
|
|
||||||
topic_only_edit_history_event["prev_topic"] = edit_history_event["prev_topic"]
|
topic_only_edit_history_event["prev_topic"] = edit_history_event["prev_topic"]
|
||||||
topic_only_edit_history_event["topic"] = edit_history_event["topic"]
|
topic_only_edit_history_event["topic"] = edit_history_event["topic"]
|
||||||
if new_stream is not None:
|
if new_stream is not None:
|
||||||
|
|
|
@ -23,7 +23,7 @@ from zerver.lib.actions import (
|
||||||
from zerver.lib.message import MessageDict, has_message_access, messages_for_ids
|
from zerver.lib.message import MessageDict, has_message_access, messages_for_ids
|
||||||
from zerver.lib.test_classes import ZulipTestCase
|
from zerver.lib.test_classes import ZulipTestCase
|
||||||
from zerver.lib.test_helpers import cache_tries_captured, queries_captured
|
from zerver.lib.test_helpers import cache_tries_captured, queries_captured
|
||||||
from zerver.lib.topic import LEGACY_PREV_TOPIC, RESOLVED_TOPIC_PREFIX, TOPIC_NAME
|
from zerver.lib.topic import RESOLVED_TOPIC_PREFIX, TOPIC_NAME
|
||||||
from zerver.models import Message, Realm, Stream, UserMessage, UserProfile, get_realm, get_stream
|
from zerver.models import Message, Realm, Stream, UserMessage, UserProfile, get_realm, get_stream
|
||||||
|
|
||||||
|
|
||||||
|
@ -749,13 +749,12 @@ class EditMessageTest(EditMessageTestCase):
|
||||||
)
|
)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
history = orjson.loads(Message.objects.get(id=msg_id).edit_history)
|
history = orjson.loads(Message.objects.get(id=msg_id).edit_history)
|
||||||
self.assertEqual(history[0][LEGACY_PREV_TOPIC], "topic 1")
|
|
||||||
self.assertEqual(history[0]["prev_topic"], "topic 1")
|
self.assertEqual(history[0]["prev_topic"], "topic 1")
|
||||||
self.assertEqual(history[0]["topic"], "topic 2")
|
self.assertEqual(history[0]["topic"], "topic 2")
|
||||||
self.assertEqual(history[0]["user_id"], hamlet.id)
|
self.assertEqual(history[0]["user_id"], hamlet.id)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
set(history[0].keys()),
|
set(history[0].keys()),
|
||||||
{"timestamp", LEGACY_PREV_TOPIC, "prev_topic", "topic", "user_id"},
|
{"timestamp", "prev_topic", "topic", "user_id"},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.login("iago")
|
self.login("iago")
|
||||||
|
@ -783,7 +782,6 @@ class EditMessageTest(EditMessageTestCase):
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
history = orjson.loads(Message.objects.get(id=msg_id).edit_history)
|
history = orjson.loads(Message.objects.get(id=msg_id).edit_history)
|
||||||
self.assertEqual(history[0]["prev_content"], "content 2")
|
self.assertEqual(history[0]["prev_content"], "content 2")
|
||||||
self.assertEqual(history[0][LEGACY_PREV_TOPIC], "topic 2")
|
|
||||||
self.assertEqual(history[0]["prev_topic"], "topic 2")
|
self.assertEqual(history[0]["prev_topic"], "topic 2")
|
||||||
self.assertEqual(history[0]["topic"], "topic 3")
|
self.assertEqual(history[0]["topic"], "topic 3")
|
||||||
self.assertEqual(history[0]["user_id"], hamlet.id)
|
self.assertEqual(history[0]["user_id"], hamlet.id)
|
||||||
|
@ -791,7 +789,6 @@ class EditMessageTest(EditMessageTestCase):
|
||||||
set(history[0].keys()),
|
set(history[0].keys()),
|
||||||
{
|
{
|
||||||
"timestamp",
|
"timestamp",
|
||||||
LEGACY_PREV_TOPIC,
|
|
||||||
"prev_topic",
|
"prev_topic",
|
||||||
"topic",
|
"topic",
|
||||||
"prev_content",
|
"prev_content",
|
||||||
|
@ -822,7 +819,6 @@ class EditMessageTest(EditMessageTestCase):
|
||||||
)
|
)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
history = orjson.loads(Message.objects.get(id=msg_id).edit_history)
|
history = orjson.loads(Message.objects.get(id=msg_id).edit_history)
|
||||||
self.assertEqual(history[0][LEGACY_PREV_TOPIC], "topic 3")
|
|
||||||
self.assertEqual(history[0]["prev_topic"], "topic 3")
|
self.assertEqual(history[0]["prev_topic"], "topic 3")
|
||||||
self.assertEqual(history[0]["topic"], "topic 4")
|
self.assertEqual(history[0]["topic"], "topic 4")
|
||||||
self.assertEqual(history[0]["prev_stream"], stream_2.id)
|
self.assertEqual(history[0]["prev_stream"], stream_2.id)
|
||||||
|
@ -832,7 +828,6 @@ class EditMessageTest(EditMessageTestCase):
|
||||||
set(history[0].keys()),
|
set(history[0].keys()),
|
||||||
{
|
{
|
||||||
"timestamp",
|
"timestamp",
|
||||||
LEGACY_PREV_TOPIC,
|
|
||||||
"prev_topic",
|
"prev_topic",
|
||||||
"topic",
|
"topic",
|
||||||
"prev_stream",
|
"prev_stream",
|
||||||
|
@ -844,9 +839,6 @@ class EditMessageTest(EditMessageTestCase):
|
||||||
# Now, we verify that all of the edits stored in the message.edit_history
|
# Now, we verify that all of the edits stored in the message.edit_history
|
||||||
# have the correct data structure
|
# have the correct data structure
|
||||||
history = orjson.loads(Message.objects.get(id=msg_id).edit_history)
|
history = orjson.loads(Message.objects.get(id=msg_id).edit_history)
|
||||||
self.assertEqual(history[0][LEGACY_PREV_TOPIC], "topic 3")
|
|
||||||
self.assertEqual(history[2][LEGACY_PREV_TOPIC], "topic 2")
|
|
||||||
self.assertEqual(history[4][LEGACY_PREV_TOPIC], "topic 1")
|
|
||||||
|
|
||||||
self.assertEqual(history[0]["prev_topic"], "topic 3")
|
self.assertEqual(history[0]["prev_topic"], "topic 3")
|
||||||
self.assertEqual(history[0]["topic"], "topic 4")
|
self.assertEqual(history[0]["topic"], "topic 4")
|
||||||
|
|
Loading…
Reference in New Issue