From 9d93d1e71b3bd7d23892d80dd8109eb7450de734 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 13 Nov 2020 05:20:01 -0800 Subject: [PATCH] modules/client/rooms/send: Use m::room::message for single pass. --- modules/client/rooms/send.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/client/rooms/send.cc b/modules/client/rooms/send.cc index 23e6ae1b5..e39710c1f 100644 --- a/modules/client/rooms/send.cc +++ b/modules/client/rooms/send.cc @@ -141,15 +141,22 @@ put__send(client &client, room_id, &copts }; - const bool cmd + if(type == "m.room.message") { - type == "m.room.message" && - unquote(content.get("msgtype")) == "m.text" && - startswith(unquote(content.get("body")), "\\\\") - }; + const m::room::message message + { + content + }; - if(cmd) - return handle_command(client, request, room); + const bool cmd + { + json::get<"msgtype"_>(message) == "m.text" && + startswith(json::get<"body"_>(message), "\\\\") + }; + + if(cmd) + return handle_command(client, request, room); + } const auto event_id {