topic -> subject: Extract get_topic_from_message_info().

This changes files where it's safe to just assume caller
may use either "topic" or "subject", and we prefer "topic"
but support "subject".
This commit is contained in:
Steve Howell
2018-11-10 21:50:28 +00:00
committed by Tim Abbott
parent aa4e9cec2d
commit 27d79352da
7 changed files with 50 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
import urllib
from typing import Any, Dict, List
from zerver.lib.topic import get_topic_from_message_info
from zerver.models import Realm, Stream, UserProfile
def hash_util_encode(string: str) -> str:
@@ -57,7 +58,7 @@ def near_stream_message_url(realm: Realm,
message_id = str(message['id'])
stream_id = message['stream_id']
stream_name = message['display_recipient']
topic_name = message['subject']
topic_name = get_topic_from_message_info(message)
encoded_topic = hash_util_encode(topic_name)
encoded_stream = encode_stream(stream_id=stream_id, stream_name=stream_name)