mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	filter: Validate and parse sender:me when turning into a pill.
Fixes #31315. We want to parse sender:me with the email when turning it into a pill, but not before then so that "Sent by me" is still the search string in the suggestions.
This commit is contained in:
		@@ -1405,8 +1405,8 @@ test("parse", () => {
 | 
			
		||||
    let string;
 | 
			
		||||
    let terms;
 | 
			
		||||
 | 
			
		||||
    function _test() {
 | 
			
		||||
        const result = Filter.parse(string);
 | 
			
		||||
    function _test(for_pills = false) {
 | 
			
		||||
        const result = Filter.parse(string, for_pills);
 | 
			
		||||
        assert_same_terms(result, terms);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -1444,6 +1444,14 @@ test("parse", () => {
 | 
			
		||||
    terms = [{operator: "sender", operand: "leo+test@zulip.com"}];
 | 
			
		||||
    _test();
 | 
			
		||||
 | 
			
		||||
    string = "sender:me";
 | 
			
		||||
    terms = [{operator: "sender", operand: `${me.email}`}];
 | 
			
		||||
    _test(true);
 | 
			
		||||
 | 
			
		||||
    string = "-sender:me";
 | 
			
		||||
    terms = [{operator: "sender", operand: `${me.email}`, negated: true}];
 | 
			
		||||
    _test(true);
 | 
			
		||||
 | 
			
		||||
    string = "https://www.google.com";
 | 
			
		||||
    terms = [{operator: "search", operand: "https://www.google.com"}];
 | 
			
		||||
    _test();
 | 
			
		||||
@@ -1964,6 +1972,7 @@ test("is_valid_search_term", () => {
 | 
			
		||||
        ["topic:GhostTown", true],
 | 
			
		||||
        ["dm-including:alice@example.com", true],
 | 
			
		||||
        ["sender:ghost@zulip.com", false],
 | 
			
		||||
        ["sender:me", true],
 | 
			
		||||
        ["dm:alice@example.com,ghost@example.com", false],
 | 
			
		||||
        ["dm:alice@example.com,joe@example.com", true],
 | 
			
		||||
    ];
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user