lib: Rename *topic local variables to *topic_name.

This is preparatory work towards adding a Topic model.
We plan to use the local variable name as 'topic' for
the Topic model objects.

Currently, we use *topic as the local variable name for
topic names.

We rename local variables of the form *topic to *topic_name
so that we don't need to think about type collisions in
individual code paths where we might want to talk about both
Topic objects and strings for the topic name.
This commit is contained in:
Prakhar Pratyush
2024-01-14 19:08:50 +05:30
committed by Tim Abbott
parent bc66eaee7d
commit b7e56ccbdc
11 changed files with 61 additions and 59 deletions

View File

@@ -52,12 +52,12 @@ def further_validated_draft_dict(
raise JsonableError(_("Timestamp must not be negative."))
last_edit_time = timestamp_to_datetime(timestamp)
topic = ""
topic_name = ""
recipient_id = None
to = draft_dict.to
if draft_dict.type == "stream":
topic = truncate_topic(draft_dict.topic)
if "\0" in topic:
topic_name = truncate_topic(draft_dict.topic)
if "\0" in topic_name:
raise JsonableError(_("Topic must not contain null bytes"))
if len(to) != 1:
raise JsonableError(_("Must specify exactly 1 stream ID for stream messages"))
@@ -72,7 +72,7 @@ def further_validated_draft_dict(
return {
"recipient_id": recipient_id,
"topic": topic,
"topic": topic_name,
"content": content,
"last_edit_time": last_edit_time,
}