Handle negated streams in ok_to_include_history.

(imported from commit 0a049364e1d14f45db9f8e9aa5392039a01231eb)
This commit is contained in:
Steve Howell 2014-02-13 12:53:51 -05:00
parent 11ba6a17ab
commit fb27cbcd01
2 changed files with 7 additions and 1 deletions

View File

@ -38,6 +38,12 @@ class IncludeHistoryTest(AuthedTestCase):
realm = get_realm('zulip.com')
create_stream_if_needed(realm, 'public_stream')
# Negated stream searches should not include history.
narrow = [
dict(operator='stream', operand='public_stream', negated=True),
]
self.assertFalse(ok_to_include_history(narrow, realm))
# Definitely forbid seeing history on private streams.
narrow = [
dict(operator='stream', operand='private_stream'),

View File

@ -349,7 +349,7 @@ def ok_to_include_history(narrow, realm):
include_history = False
if narrow is not None:
for term in narrow:
if term['operator'] == "stream":
if term['operator'] == "stream" and not term.get('negated', False):
if is_public_stream(term['operand'], realm):
include_history = True
# Disable historical messages if the user is narrowing on anything