0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 10:08:56 +02:00

ircd:Ⓜ️:event: Fallback to JSON query for keys in the get() suite.

This commit is contained in:
Jason Volk 2019-02-12 10:02:37 -08:00
parent 4077c5faa3
commit df8cee0b47

View file

@ -646,7 +646,33 @@ ircd::m::get(std::nothrow_t,
dbs::event_column.at(column_idx)
};
return column(column_key, std::nothrow, closure);
if(column)
return column(column_key, std::nothrow, closure);
// If the event property being sought doesn't have its own column we
// fall back to fetching the full JSON and closing over the property.
bool ret{false};
dbs::event_json(column_key, std::nothrow, [&closure, &key, &ret]
(const json::object &event)
{
string_view value
{
event[key]
};
if(!value)
return;
// The user expects an unquoted string to their closure, the same as
// if this value was found in its own column.
if(json::type(value) == json::STRING)
value = unquote(value);
ret = true;
closure(value);
});
return ret;
}
///////////////////////////////////////////////////////////////////////////////