MCPcopy Create free account
hub / github.com/BlueMatthew/WechatExporter / parseSystem

Method parseSystem

WechatExporter/core/MessageParser.cpp:623–705  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

621}
622
623void MessageParser::parseSystem(const WXMSG& msg, const Session& session, TemplateValues& tv) const
624{
625 tv.setName("notice");
626 if (startsWith(msg.content, "<sysmsg"))
627 {
628 XmlParser xmlParser(msg.content, true);
629 std::string sysMsgType;
630 xmlParser.parseAttributeValue("/sysmsg", "type", sysMsgType);
631 if (sysMsgType == "sysmsgtemplate")
632 {
633 std::string plainText;
634 std::string templateContent;
635 std::string templateType;
636 xmlParser.parseAttributeValue("/sysmsg/sysmsgtemplate/content_template", "type", templateType);
637#ifndef NDEBUG
638 writeFile(combinePath(m_outputPath, "../dbg", "msg_" + std::to_string(msg.type) + "_" + sysMsgType + ".txt"), msg.content);
639#endif
640 if (startsWith(templateType, "tmpl_type_profile") || templateType == "tmpl_type_admin_explain" || templateType == "new_tmpl_type_succeed_contact")
641 {
642 // tmpl_type_profilewithrevokeqrcode
643 // tmpl_type_profilewithrevoke
644 // tmpl_type_profile
645 xmlParser.parseNodeValue("/sysmsg/sysmsgtemplate/content_template/plain", plainText);
646 if (plainText.empty())
647 {
648 xmlParser.parseNodeValue("/sysmsg/sysmsgtemplate/content_template/template", templateContent);
649 WechatTemplateHandler handler(xmlParser, templateContent);
650 if (xmlParser.parseWithHandler("/sysmsg/sysmsgtemplate/content_template/link_list/link", handler))
651 {
652 tv["%%MESSAGE%%"] = handler.getText();
653 }
654 }
655 else
656 {
657 tv["%%MESSAGE%%"] = msg.content;
658 }
659 }
660 else
661 {
662#ifndef NDEBUG
663 writeFile(combinePath(m_outputPath, "../dbg", "msg_" + std::to_string(msg.type) + "_" + sysMsgType + ".txt"), msg.content);
664 assert(false);
665#endif
666 }
667 }
668 else if (sysMsgType == "editrevokecontent")
669 {
670 std::string content;
671 xmlParser.parseNodeValue("/sysmsg/" + sysMsgType + "/text", content);
672 tv["%%MESSAGE%%"] = content;
673 }
674 else
675 {
676 // Try to find plain first
677 std::string plainText;
678 if (xmlParser.parseNodeValue("/sysmsg/" + sysMsgType + "/plain", plainText) && !plainText.empty())
679 {
680 tv["%%MESSAGE%%"] = plainText;

Callers

nothing calls this directly

Calls 9

startsWithFunction · 0.85
writeFileFunction · 0.85
combinePathFunction · 0.85
removeHtmlTagsFunction · 0.85
setNameMethod · 0.80
parseAttributeValueMethod · 0.80
parseNodeValueMethod · 0.80
parseWithHandlerMethod · 0.80
getTextMethod · 0.80

Tested by

no test coverage detected