🎨 #2853 【企业微信】配置类中增加会话存档secret的配置项

This commit is contained in:
Alixhan 2022-10-25 17:01:50 +08:00 committed by GitHub
parent 512975fb86
commit 48a22a0e60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 3 deletions

View File

@ -78,9 +78,12 @@ public class WxCpMsgAuditServiceImpl implements WxCpMsgAuditService {
Finance.loadingLibraries(osLib, prefixPath); Finance.loadingLibraries(osLib, prefixPath);
long sdk = Finance.NewSdk(); long sdk = Finance.NewSdk();
//因为会话存档单独有个secret,优先使用会话存档的secret
long ret = Finance.Init(sdk, cpService.getWxCpConfigStorage().getCorpId(), String msgAuditSecret = cpService.getWxCpConfigStorage().getMsgAuditSecret();
cpService.getWxCpConfigStorage().getCorpSecret()); if(StringUtils.isEmpty(msgAuditSecret)) {
msgAuditSecret = cpService.getWxCpConfigStorage().getCorpSecret();
}
long ret = Finance.Init(sdk, cpService.getWxCpConfigStorage().getCorpId(),msgAuditSecret);
if (ret != 0) { if (ret != 0) {
Finance.DestroySdk(sdk); Finance.DestroySdk(sdk);
throw new WxErrorException("init sdk err ret " + ret); throw new WxErrorException("init sdk err ret " + ret);

View File

@ -257,4 +257,10 @@ public interface WxCpConfigStorage {
* @return key webhook key * @return key webhook key
*/ */
String getWebhookKey(); String getWebhookKey();
/**
* 获取会话存档的secret
* @return msg audit secret
*/
String getMsgAuditSecret();
} }

View File

@ -46,6 +46,7 @@ public class WxCpDefaultConfigImpl implements WxCpConfigStorage, Serializable {
/** /**
* 会话存档私钥以及sdk路径 * 会话存档私钥以及sdk路径
*/ */
private volatile String msgAuditSecret;
private volatile String msgAuditPriKey; private volatile String msgAuditPriKey;
private volatile String msgAuditLibPath; private volatile String msgAuditLibPath;
private volatile String oauth2redirectUri; private volatile String oauth2redirectUri;
@ -435,4 +436,18 @@ public class WxCpDefaultConfigImpl implements WxCpConfigStorage, Serializable {
this.webhookKey = webhookKey; this.webhookKey = webhookKey;
return this; return this;
} }
@Override
public String getMsgAuditSecret() {
return this.msgAuditSecret;
}
/**
* 设置会话存档secret
* @param msgAuditSecret
*/
public WxCpDefaultConfigImpl setMsgAuditSecret(String msgAuditSecret) {
this.msgAuditSecret = msgAuditSecret;
return this;
}
} }

View File

@ -466,4 +466,8 @@ public class WxCpRedisConfigImpl implements WxCpConfigStorage {
return this.getWebhookKey(); return this.getWebhookKey();
} }
@Override
public String getMsgAuditSecret() {
return null;
}
} }