mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
modules/client/search: Add case key command; case-insensitive by default.
This commit is contained in:
parent
96097045a1
commit
5600e28ebc
2 changed files with 16 additions and 1 deletions
|
@ -60,6 +60,7 @@ struct ircd::m::search::query
|
|||
size_t limit {-1UL};
|
||||
ushort before_limit {0};
|
||||
ushort after_limit {0};
|
||||
bool case_sensitive {false};
|
||||
};
|
||||
|
||||
struct ircd::m::search::result
|
||||
|
|
|
@ -189,6 +189,12 @@ try
|
|||
json::get<"not_senders"_>(room_event_filter) = not_senders;
|
||||
});
|
||||
|
||||
bool case_sensitive {false};
|
||||
when({"case", "ci"}, [&](const auto &key, const auto &val)
|
||||
{
|
||||
case_sensitive = key == "case";
|
||||
});
|
||||
|
||||
const string_view search_term
|
||||
{
|
||||
kvs.second?: kvs.first
|
||||
|
@ -225,6 +231,7 @@ try
|
|||
.limit = limit,
|
||||
.before_limit = event_context.get("before_limit", context_default),
|
||||
.after_limit = event_context.get("after_limit", context_default),
|
||||
.case_sensitive = case_sensitive,
|
||||
};
|
||||
|
||||
log::logf
|
||||
|
@ -402,10 +409,17 @@ try
|
|||
content["body"]
|
||||
};
|
||||
|
||||
const bool match_term
|
||||
{
|
||||
false
|
||||
|| (query.case_sensitive && has(body, query.search_term))
|
||||
|| (!query.case_sensitive && ihas(body, query.search_term))
|
||||
};
|
||||
|
||||
const bool match
|
||||
{
|
||||
true
|
||||
&& has(body, query.search_term)
|
||||
&& match_term
|
||||
&& m::match(query.filter, result.event_idx)
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue