diff --git a/src/main/java/com/company/agentfoundation/integration/wecom/WecomCallbackController.java b/src/main/java/com/company/agentfoundation/integration/wecom/WecomCallbackController.java index 3aca6af..4ad246b 100644 --- a/src/main/java/com/company/agentfoundation/integration/wecom/WecomCallbackController.java +++ b/src/main/java/com/company/agentfoundation/integration/wecom/WecomCallbackController.java @@ -73,13 +73,6 @@ public class WecomCallbackController { msg == null ? null : msg.getMsgType(), preview(msg == null ? null : msg.getContent())); log.info("wecom callback current user FromUserName={}", msg == null ? null : msg.getFromUserName()); - if (msg != null && msg.getFromUserName() != null && !msg.getFromUserName().isBlank()) { - WecomUserInfoResponse userInfo = wecomClient.getUserInfo(msg.getFromUserName()); - if (userInfo != null && userInfo.success()) { - log.info("wecom callback resolved member userid={} name={} department={}", - userInfo.userId(), userInfo.name(), userInfo.department()); - } - } if (msg == null || msg.getMsgType() == null || !"text".equalsIgnoreCase(msg.getMsgType())) { log.info("wecom callback ignored non-text message"); return "success"; diff --git a/src/main/java/com/company/agentfoundation/integration/wecom/WecomClient.java b/src/main/java/com/company/agentfoundation/integration/wecom/WecomClient.java index 298ee54..f3c7cf5 100644 --- a/src/main/java/com/company/agentfoundation/integration/wecom/WecomClient.java +++ b/src/main/java/com/company/agentfoundation/integration/wecom/WecomClient.java @@ -48,28 +48,6 @@ public class WecomClient { log.info("wecom sendText success toUser={}", toUser); } - public WecomUserInfoResponse getUserInfo(String userId) { - log.info("wecom user/get start userid={}", userId); - String token = getAccessToken(); - WecomUserInfoResponse response = webClient.get() - .uri(uriBuilder -> uriBuilder.path("/cgi-bin/user/get") - .queryParam("access_token", token) - .queryParam("userid", userId) - .build()) - .retrieve() - .bodyToMono(WecomUserInfoResponse.class) - .block(); - - if (response == null || !response.success()) { - log.warn("wecom user/get failed userid={} err={}", userId, response == null ? "null" : response.errmsg()); - return response; - } - - log.info("wecom user/get success userid={} name={} department={} mobile={} position={}", - response.userId(), response.name(), response.department(), maskMobile(response.mobile()), response.position()); - return response; - } - private String getAccessToken() { if (cachedToken != null && Instant.now().isBefore(tokenExpireAt)) { log.info("wecom gettoken use cached token expireAt={}", tokenExpireAt); @@ -104,10 +82,4 @@ public class WecomClient { return text.length() <= 80 ? text : text.substring(0, 80) + "..."; } - private String maskMobile(String mobile) { - if (mobile == null || mobile.length() < 7) { - return ""; - } - return mobile.substring(0, 3) + "****" + mobile.substring(mobile.length() - 4); - } } diff --git a/src/main/java/com/company/agentfoundation/integration/wecom/WecomUserInfoResponse.java b/src/main/java/com/company/agentfoundation/integration/wecom/WecomUserInfoResponse.java deleted file mode 100644 index d1b9cf3..0000000 --- a/src/main/java/com/company/agentfoundation/integration/wecom/WecomUserInfoResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.company.agentfoundation.integration.wecom; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public record WecomUserInfoResponse( - Integer errcode, - String errmsg, - @JsonProperty("userid") String userId, - String name, - List department, - String mobile, - String position -) { - public boolean success() { - return errcode != null && errcode == 0; - } -}