Skip to content

Commit 120913b

Browse files
rewrite find_my_msg function
1 parent 273c535 commit 120913b

File tree

3 files changed

+111
-97
lines changed

3 files changed

+111
-97
lines changed

msg_controller.cc

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,9 @@ void chat(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)
5151
}
5252
void check(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback)
5353
{
54-
auto body = req->getBody();
55-
Json::Value req_json, res_json;
54+
Json::Value res_json;
5655
Json::Reader reader;
57-
std::string bodyStr(body);
58-
if (!reader.parse(bodyStr, req_json))
59-
{
60-
callback(HttpResponse::newHttpResponse());
61-
return;
62-
}
63-
std::string me, who_send_me;
56+
std::string me;
6457
Json::FastWriter writer;
6558
std::string authHeader = req->getHeader("Authorization");
6659
if (authHeader.substr(0, 7) == "Bearer ")
@@ -85,8 +78,7 @@ void check(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &
8578

8679
auto res = HttpResponse::newHttpResponse();
8780
res->addHeader("Access-Control-Allow-Origin", "*");
88-
who_send_me = req_json["person"].asString();
89-
auto output = writer.write(sql_find_my_msg(me, who_send_me));
81+
auto output = writer.write(sql_find_my_msg(me));
9082
res->setBody(output);
9183
callback(res);
9284
}
@@ -166,7 +158,7 @@ void info(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)
166158
auto res = HttpResponse::newHttpResponse();
167159
res->addHeader("Access-Control-Allow-Origin", "*");
168160
if(req_json["person"].asString()==""){
169-
res->setBody(writer.write(get_chat_info(me)));
161+
res->setBody(writer.write(get_chat_info(me,"")));
170162
callback(res);
171163
}else{
172164
who_send_me = req_json["person"].asString();

0 commit comments

Comments
 (0)