Skip to content

Commit

Permalink
Merge pull request yaphone#34 from Jray616/master
Browse files Browse the repository at this point in the history
新增手机端主动新增好友网页版同步好友信息
  • Loading branch information
yaphone committed Jun 22, 2017
2 parents a20af6c + 8b646d3 commit 9b16c9a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/main/java/cn/zhouyafeng/itchat4j/core/MsgCenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,15 @@ public static void handleMsg(IMsgHandlerFace msgHandler) {
if (msg.getString("Type") != null) {
try {
if (msg.getString("Type").equals(MsgTypeEnum.TEXT.getType())) {
String result = msgHandler.textMsgHandle(msg);
MessageTools.sendMsgById(result, core.getMsgList().get(0).getString("FromUserName"));
//存在主动加好友之后的同步联系人到本地
String text = msg.getString("Text");
if (text.contains("我通过了你的朋友验证请求,现在我们可以开始聊天了")) {
JSONObject userInfo = msg.getJSONObject("userInfo");
core.getContactList().add(userInfo);
}else {
String result = msgHandler.textMsgHandle(msg);
MessageTools.sendMsgById(result, core.getMsgList().get(0).getString("FromUserName"));
}
} else if (msg.getString("Type").equals(MsgTypeEnum.PIC.getType())) {
String result = msgHandler.picMsgHandle(msg);
MessageTools.sendMsgById(result, core.getMsgList().get(0).getString("FromUserName"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,29 @@ public void run() {
webWxSync();
} else if (selector.equals("4")) {
continue;
} else if (selector.equals("3") || selector.equals("6")) {
} else if (selector.equals("3")) {
continue;
}else if (selector.equals("6")) {
if (msgObj != null) {
try {
JSONArray msgList = new JSONArray();
msgList = msgObj.getJSONArray("AddMsgList");
JSONArray modContactList = msgObj.getJSONArray("ModContactList"); //存有删除或者新增的好友信息
msgList = MsgCenter.produceMsg(msgList);
for (int j = 0; j < msgList.size(); j++) {

JSONObject msg = msgList.getJSONObject(j);
JSONObject userInfo = modContactList.getJSONObject(j);
msg.put("userInfo",userInfo);

core.getMsgList().add(msg);

}
} catch (Exception e) {
LOG.info(e.getMessage());
}
}

}
} else {
JSONObject obj = webWxSync();
Expand Down

0 comments on commit 9b16c9a

Please sign in to comment.