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,4 +1,7 @@
from zerver.lib.request import JsonableError
from zerver.lib.topic import (
get_topic_from_message_info,
)
from django.utils.translation import ugettext as _
from typing import Any, Callable, Dict, Iterable, Mapping, Sequence
@@ -38,7 +41,8 @@ def build_narrow_filter(narrow: Iterable[Sequence[str]]) -> Callable[[Mapping[st
elif operator == "topic":
if message["type"] != "stream":
return False
if operand.lower() != message["subject"].lower():
topic_name = get_topic_from_message_info(message)
if operand.lower() != topic_name.lower():
return False
elif operator == "sender":
if operand.lower() != message["sender_email"].lower():