Skip to content
Snippets Groups Projects
Commit b1a978ab authored by Loren Burkholder's avatar Loren Burkholder
Browse files

Don't throw error if content is empty

If an Unknown message is being constructed for sending, the content
may be empty, since the msgtype and body are exposed as C++ properties.
Previously, the to_json function assumed that the content could be
parsed as valid json, when in fact an empty content would throw an error.
parent 9a202832
No related branches found
No related tags found
No related merge requests found
Pipeline #4555 passed
......@@ -22,7 +22,8 @@ from_json(const json &obj, Unknown &content)
void
to_json(json &obj, const Unknown &content)
{
obj = json::parse(content.content);
if (!content.content.empty())
obj = json::parse(content.content);
obj["msgtype"] = content.msgtype;
obj["body"] = content.body;
common::apply_relations(obj, content.relations);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment