diff --git a/include/ircd/m/search.h b/include/ircd/m/search.h index f1bfd2bc3..552dbe7b5 100644 --- a/include/ircd/m/search.h +++ b/include/ircd/m/search.h @@ -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 diff --git a/modules/client/search.cc b/modules/client/search.cc index 6183bf9a8..ed6e8f8ea 100644 --- a/modules/client/search.cc +++ b/modules/client/search.cc @@ -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) };