Support raw Himalaya query syntax in search
Detect when user types a query starting with Himalaya keywords (from, to, subject, body, date, before, after, flag, not, order by) and pass it through as-is instead of wrapping it in the compound search pattern. This allows both: - Simple searches: 'edson' → searches from/to/subject/body - Raw queries: 'from edson' → uses Himalaya syntax directly
This commit is contained in:
@@ -335,9 +335,33 @@ async def search_envelopes(
|
||||
- Success status (True if operation was successful)
|
||||
"""
|
||||
try:
|
||||
# Himalaya query keywords that indicate the user is writing a raw query
|
||||
query_keywords = (
|
||||
"from ",
|
||||
"to ",
|
||||
"subject ",
|
||||
"body ",
|
||||
"date ",
|
||||
"before ",
|
||||
"after ",
|
||||
"flag ",
|
||||
"not ",
|
||||
"order by ",
|
||||
)
|
||||
|
||||
# Check if user is using raw query syntax
|
||||
query_lower = query.lower()
|
||||
is_raw_query = any(query_lower.startswith(kw) for kw in query_keywords)
|
||||
|
||||
if is_raw_query:
|
||||
# Pass through as-is (user knows what they're doing)
|
||||
search_query = query
|
||||
else:
|
||||
# Build a compound query to search from, to, subject, and body
|
||||
# Himalaya query syntax: from <pattern> or to <pattern> or subject <pattern> or body <pattern>
|
||||
search_query = f"from {query} or to {query} or subject {query} or body {query}"
|
||||
search_query = (
|
||||
f"from {query} or to {query} or subject {query} or body {query}"
|
||||
)
|
||||
|
||||
# Build command with options before the query (query must be at the end, quoted)
|
||||
cmd = "himalaya envelope list -o json"
|
||||
|
||||
Reference in New Issue
Block a user