Skip to content

Commit

Permalink
🎨 #2853 【企业微信】配置类中增加会话存档secret的配置项
Browse files Browse the repository at this point in the history
  • Loading branch information
Alixhan authored Oct 25, 2022
1 parent 512975f commit 48a22a0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ public WxCpChatDatas getChatDatas(long seq, @NonNull long limit, String proxy, S

Finance.loadingLibraries(osLib, prefixPath);
long sdk = Finance.NewSdk();

long ret = Finance.Init(sdk, cpService.getWxCpConfigStorage().getCorpId(),
cpService.getWxCpConfigStorage().getCorpSecret());
//因为会话存档单独有个secret,优先使用会话存档的secret
String msgAuditSecret = cpService.getWxCpConfigStorage().getMsgAuditSecret();
if(StringUtils.isEmpty(msgAuditSecret)) {
msgAuditSecret = cpService.getWxCpConfigStorage().getCorpSecret();
}
long ret = Finance.Init(sdk, cpService.getWxCpConfigStorage().getCorpId(),msgAuditSecret);
if (ret != 0) {
Finance.DestroySdk(sdk);
throw new WxErrorException("init sdk err ret " + ret);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,10 @@ public interface WxCpConfigStorage {
* @return key webhook key
*/
String getWebhookKey();

/**
* 获取会话存档的secret
* @return msg audit secret
*/
String getMsgAuditSecret();
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class WxCpDefaultConfigImpl implements WxCpConfigStorage, Serializable {
/**
* 会话存档私钥以及sdk路径
*/
private volatile String msgAuditSecret;
private volatile String msgAuditPriKey;
private volatile String msgAuditLibPath;
private volatile String oauth2redirectUri;
Expand Down Expand Up @@ -435,4 +436,18 @@ public WxCpDefaultConfigImpl setWebhookKey(String webhookKey) {
this.webhookKey = webhookKey;
return this;
}

@Override
public String getMsgAuditSecret() {
return this.msgAuditSecret;
}

/**
* 设置会话存档secret
* @param msgAuditSecret
*/
public WxCpDefaultConfigImpl setMsgAuditSecret(String msgAuditSecret) {
this.msgAuditSecret = msgAuditSecret;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,8 @@ public String getWebhookKey() {
return this.getWebhookKey();
}

@Override
public String getMsgAuditSecret() {
return null;
}
}

0 comments on commit 48a22a0

Please sign in to comment.