Procházet zdrojové kódy

fix:企微刷新联系人修改

jimmyyem před 1 měsícem
rodič
revize
8bf4bad174

+ 66 - 0
hook/contact.go

@@ -139,6 +139,72 @@ func (h *Hook) TriggerChatroomPush(wxWxid string) error {
 	return nil
 	return nil
 }
 }
 
 
+// TriggerCustomerPushTask 刷新企微联系人
+func (h *Hook) TriggerCustomerPushTask(wxWxid string) error {
+	conn, err := h.connWorkPhone()
+	if err != nil {
+		err = fmt.Errorf("TriggerCustomerPushTask failed")
+		return err
+	}
+	defer func(conn *websocket.Conn) {
+		err = conn.Close()
+		if err != nil {
+			err = fmt.Errorf("TriggerCustomerPushTask failed")
+		}
+	}(conn)
+
+	message := map[string]interface{}{
+		"MsgType": "TriggerCustomerPushTask",
+		"Content": map[string]interface{}{
+			"WxId": wxWxid,
+		},
+	}
+	transportMessageJSON, err := json.Marshal(message)
+	if err != nil {
+		return err
+	}
+	// 发送 JSON 消息
+	err = conn.WriteMessage(websocket.TextMessage, transportMessageJSON)
+	if err != nil {
+		return fmt.Errorf("failed to send message: %v", err)
+	}
+
+	return nil
+}
+
+// TriggerConversationPushTask 刷新企微群组
+func (h *Hook) TriggerConversationPushTask(wxWxid string) error {
+	conn, err := h.connWorkPhone()
+	if err != nil {
+		err = fmt.Errorf("TriggerConversationPushTask failed")
+		return err
+	}
+	defer func(conn *websocket.Conn) {
+		err = conn.Close()
+		if err != nil {
+			err = fmt.Errorf("TriggerConversationPushTask failed")
+		}
+	}(conn)
+
+	message := map[string]interface{}{
+		"MsgType": "TriggerConversationPushTask",
+		"Content": map[string]interface{}{
+			"WxId": wxWxid,
+		},
+	}
+	transportMessageJSON, err := json.Marshal(message)
+	if err != nil {
+		return err
+	}
+	// 发送 JSON 消息
+	err = conn.WriteMessage(websocket.TextMessage, transportMessageJSON)
+	if err != nil {
+		return fmt.Errorf("failed to send message: %v", err)
+	}
+
+	return nil
+}
+
 func (h *Hook) AddFriendInChatRoom(ChatRoomId, wxWxid, friendId, desc string) error {
 func (h *Hook) AddFriendInChatRoom(ChatRoomId, wxWxid, friendId, desc string) error {
 	conn, err := h.connWorkPhone()
 	conn, err := h.connWorkPhone()
 	if err != nil {
 	if err != nil {

+ 8 - 1
internal/logic/Wxhook/get_friends_and_groups_logic.go

@@ -221,7 +221,14 @@ func (l *GetFriendsAndGroupsLogic) GetFriendsAndGroups(req *types.IDReq) (resp *
 			l.Error("GetWechatFriendList 请求失败", err)
 			l.Error("GetWechatFriendList 请求失败", err)
 			return nil, err
 			return nil, err
 		}
 		}
-		_ = hookClient.TriggerChatroomPush(wxInfo.Wxid)
+
+		if wxInfo.Ctype == 3 {
+			_ = hookClient.TriggerCustomerPushTask(wxInfo.Wxid)
+			_ = hookClient.TriggerConversationPushTask(wxInfo.Wxid)
+		} else {
+			_ = hookClient.TriggerChatroomPush(wxInfo.Wxid)
+		}
+
 		for _, friend := range result.Data {
 		for _, friend := range result.Data {
 			friendType := 1
 			friendType := 1
 			if friend.Type == 1 {
 			if friend.Type == 1 {