0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

ircd:Ⓜ️:push: Add tool to determine if rule has highlight tweak set.

This commit is contained in:
Jason Volk 2020-03-22 20:04:16 -07:00
parent c4c1c47351
commit 98562fe488
2 changed files with 42 additions and 2 deletions

View file

@ -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;
}

View file

@ -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
//