Skip to content

Commit 48a22a0

Browse files
authored
🎨 binarywang#2853 【企业微信】配置类中增加会话存档secret的配置项
1 parent 512975f commit 48a22a0

4 files changed

Lines changed: 31 additions & 3 deletions

File tree

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMsgAuditServiceImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,12 @@ public WxCpChatDatas getChatDatas(long seq, @NonNull long limit, String proxy, S
7878

7979
Finance.loadingLibraries(osLib, prefixPath);
8080
long sdk = Finance.NewSdk();
81-
82-
long ret = Finance.Init(sdk, cpService.getWxCpConfigStorage().getCorpId(),
83-
cpService.getWxCpConfigStorage().getCorpSecret());
81+
//因为会话存档单独有个secret,优先使用会话存档的secret
82+
String msgAuditSecret = cpService.getWxCpConfigStorage().getMsgAuditSecret();
83+
if(StringUtils.isEmpty(msgAuditSecret)) {
84+
msgAuditSecret = cpService.getWxCpConfigStorage().getCorpSecret();
85+
}
86+
long ret = Finance.Init(sdk, cpService.getWxCpConfigStorage().getCorpId(),msgAuditSecret);
8487
if (ret != 0) {
8588
Finance.DestroySdk(sdk);
8689
throw new WxErrorException("init sdk err ret " + ret);

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpConfigStorage.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,10 @@ public interface WxCpConfigStorage {
257257
* @return key webhook key
258258
*/
259259
String getWebhookKey();
260+
261+
/**
262+
* 获取会话存档的secret
263+
* @return msg audit secret
264+
*/
265+
String getMsgAuditSecret();
260266
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImpl.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class WxCpDefaultConfigImpl implements WxCpConfigStorage, Serializable {
4646
/**
4747
* 会话存档私钥以及sdk路径
4848
*/
49+
private volatile String msgAuditSecret;
4950
private volatile String msgAuditPriKey;
5051
private volatile String msgAuditLibPath;
5152
private volatile String oauth2redirectUri;
@@ -435,4 +436,18 @@ public WxCpDefaultConfigImpl setWebhookKey(String webhookKey) {
435436
this.webhookKey = webhookKey;
436437
return this;
437438
}
439+
440+
@Override
441+
public String getMsgAuditSecret() {
442+
return this.msgAuditSecret;
443+
}
444+
445+
/**
446+
* 设置会话存档secret
447+
* @param msgAuditSecret
448+
*/
449+
public WxCpDefaultConfigImpl setMsgAuditSecret(String msgAuditSecret) {
450+
this.msgAuditSecret = msgAuditSecret;
451+
return this;
452+
}
438453
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,4 +466,8 @@ public String getWebhookKey() {
466466
return this.getWebhookKey();
467467
}
468468

469+
@Override
470+
public String getMsgAuditSecret() {
471+
return null;
472+
}
469473
}

0 commit comments

Comments
 (0)