From 3d814b7926776a1862654ebbf6fb73b2fe509269 Mon Sep 17 00:00:00 2001 From: electron128 Date: Sun, 7 Feb 2016 14:23:01 +0100 Subject: [PATCH] libresapi: added chat/send_status usage: $ curl --data "{\"chat_id\":\"\",\"status\":\"Hi there\"}" http:///api/v2/chat/send_status --- libresapi/src/api/ChatHandler.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libresapi/src/api/ChatHandler.cpp b/libresapi/src/api/ChatHandler.cpp index cadaae810..9d4062271 100644 --- a/libresapi/src/api/ChatHandler.cpp +++ b/libresapi/src/api/ChatHandler.cpp @@ -771,9 +771,20 @@ void ChatHandler::handleTypingLabel(Request &/*req*/, Response &/*resp*/) } -void ChatHandler::handleSendStatus(Request &/*req*/, Response &/*resp*/) +void ChatHandler::handleSendStatus(Request &req, Response &resp) { - + std::string chat_id; + std::string status; + req.mStream << makeKeyValueReference("chat_id", chat_id) + << makeKeyValueReference("status", status); + ChatId id(chat_id); + if(id.isNotSet()) + { + resp.setFail("chat_id is invalid"); + return; + } + mRsMsgs->sendStatusString(id, status); + resp.setOk(); } void ChatHandler::handleUnreadMsgs(Request &/*req*/, Response &resp)