Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow_filter: Add negation support for in:home narrow filter.
whilstsomebody8356a9d9e488
diff --git a/zerver/lib/narrow.py b/zerver/lib/narrow.pyindex fe6ca5879ab..d5f1ec4f3e9 100644--- a/zerver/lib/narrow.py+++ b/zerver/lib/narrow.py@@ -371,8 +371,10 @@ class NarrowBuilder:assert self.user_profile is not Noneif operand == "home":- conditions = exclude_muting_conditions(self.user_profile, [])- return query.where(and_(*conditions))+ conditions = exclude_muting_conditions(+ self.user_profile, [NarrowParameter(operator="in", operand="home")]+ )+ return query.where(maybe_negate(and_(*conditions)))elif operand == "all":return querydiff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.pyindex 6c59a8faaa3..75ad2290abc 100644--- a/zerver/tests/test_message_fetch.py+++ b/zerver/tests/test_message_fetch.py@@ -584,10 +584,9 @@ class NarrowBuilderTest(ZulipTestCase):self._do_add_term_test(term, "WHERE (recipient_id NOT IN (__[POSTCOMPILE_recipient_id_1]))")def test_add_term_using_in_operator_and_negated(self) -> None:- # negated = True should not change anythingmute_channel(self.realm, self.user_profile, "Verona")term = NarrowParameter(operator="in", operand="home", negated=True)- self._do_add_term_test(term, "WHERE (recipient_id NOT IN (__[POSTCOMPILE_recipient_id_1]))")+ self._do_add_term_test(term, "WHERE recipient_id IN (__[POSTCOMPILE_recipient_id_1])")def test_add_term_using_in_operator_and_all_operand(self) -> None:mute_channel(self.realm, self.user_profile, "Verona")