dong_dl 1 年間 前
コミット
66c3dda856
3 ファイル変更15 行追加8 行削除
  1. 1 1
      inc/proto/ProtoParser.h
  2. 2 1
      src/proto/ProtoParser.cpp
  3. 12 6
      src/proto/jsonUtils.cpp

+ 1 - 1
inc/proto/ProtoParser.h

@@ -186,7 +186,7 @@ public:
     std::string searchGroups(std::string keyword);
     std::string getConversationInfo(std::string request);
     std::string getMessages(std::string request);
-    std::string getMessage(uint64_t id);
+    std::string getMessage(std::string id);
     std::string getGroupMembers(std::string id);
     std::string searchConversation(std::string keyword, std::string types, std::string lines);
 

+ 2 - 1
src/proto/ProtoParser.cpp

@@ -1932,8 +1932,9 @@ std::string ProtoParser::getGroupMembers(std::string id)
     return ret;
 }
 
-std::string ProtoParser::getMessage(uint64_t id)
+std::string ProtoParser::getMessage(std::string str)
 {
+    uint64_t                                   id = atoll(str.c_str());
     rapidjson::StringBuffer                    buffer;
     rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
     p->getMessage(id, [&](const auto &item) {

+ 12 - 6
src/proto/jsonUtils.cpp

@@ -49,12 +49,18 @@ void copy(MessageContent &content, rapidjson::Value &mem)
             content.set_content(mem["content"].GetString());
         if (mem.HasMember("binaryContent"))
         {
-            auto   bin      = mem["binaryContent"].GetString();
-            int    len     = base64DecodeLength(bin, strlen(bin));
-            uint8_t *cbytes   = new uint8_t[len + 1];
-            size_t   retLen   = base64Decode(cbytes, len, (const uint8_t*)bin, strlen(bin));
-            content.set_data(cbytes, retLen);
-            delete[] cbytes;
+            auto bin = mem["binaryContent"].GetString();
+            if (bin != nullptr)
+            {
+                int len = base64DecodeLength(bin, strlen(bin));
+                if (len > 0)
+                {
+                    uint8_t *cbytes = new uint8_t[len + 1];
+                    size_t   retLen = base64Decode(cbytes, len, (const uint8_t *)bin, strlen(bin));
+                    content.set_data(cbytes, retLen);
+                    delete[] cbytes;
+                }
+            }
         }
         if (mem.HasMember("mediaType"))
             content.set_mediatype(mem["mediaType"].GetInt());