diff --git a/include/ircd/m/push.h b/include/ircd/m/push.h index 662b80daa..cf8a4c9fd 100644 --- a/include/ircd/m/push.h +++ b/include/ircd/m/push.h @@ -28,8 +28,8 @@ namespace ircd::m::push path make_path(const string_view &type, const string_view &state_key); path make_path(const event &); - // true on "notify" or "coalesce" - bool notifying(const rule &); + bool highlighting(const rule &); // true for highlight tweak + bool notifying(const rule &); // true on "notify" or "coalesce" extern log::log log; } diff --git a/matrix/push.cc b/matrix/push.cc index 3ee292749..8031b0f5d 100644 --- a/matrix/push.cc +++ b/matrix/push.cc @@ -590,6 +590,46 @@ ircd::m::push::notifying(const rule &rule) return false; } +bool +ircd::m::push::highlighting(const rule &rule) +{ + const json::array &actions + { + json::get<"actions"_>(rule) + }; + + for(const string_view &action : actions) + { + if(json::type(action, std::nothrow) != json::OBJECT) + continue; + + const json::object &object + { + action + }; + + const json::string set_tweak + { + object["set_tweak"] + }; + + if(set_tweak != "highlight") + continue; + + const auto &value + { + object["value"] + }; + + // Spec sez: If a highlight tweak is given with no value, its value is + // defined to be true. If no highlight tweak is given at all then the + // value of highlight is defined to be false. + return !value || value == "true"; + } + + return false; +} + // // path //