|
|
@@ -6,6 +6,7 @@ import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
+import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.common.util.TicketCodeCommonUtil;
|
|
|
import com.cyksj.service.mail.CommonMailService;
|
|
|
@@ -33,6 +34,8 @@ public class CommonMailServiceImpl implements CommonMailService {
|
|
|
|
|
|
private final YhMailService yhMailService;
|
|
|
|
|
|
+ //GPT修改密码匹配
|
|
|
+ private final static String GPT_RESET_PWD_LINK_REGEX = "https://auth0.openai.com/u/reset-verify";
|
|
|
@Override
|
|
|
public String getTicketMailCode(Long goodsId, String account, String relateEmail, String emailPwd, Date emailCreatedTime, Integer type, Integer linkType, Boolean isReturnDeviceUrl) throws Exception {
|
|
|
if (StrUtil.isEmpty(relateEmail)) {
|
|
|
@@ -45,11 +48,16 @@ public class CommonMailServiceImpl implements CommonMailService {
|
|
|
HttpRequest post = HttpUtil.createGet(url);
|
|
|
HttpResponse execute = post.execute();
|
|
|
List<JSONObject> jsonObjects = Jsons.parseList(execute.body(), JSONObject.class);
|
|
|
- for (JSONObject jsonObject : jsonObjects) {
|
|
|
- String str = jsonObject.getStr("content");
|
|
|
- if (str.contains("Your ChatGPT code is")) {
|
|
|
- String code = TicketCodeCommonUtil.getTicketCodeStr(str, goodsId);
|
|
|
- return code;
|
|
|
+ if (jsonObjects.size() > 0) {
|
|
|
+ int size = jsonObjects.size();
|
|
|
+ //获取前10封邮件
|
|
|
+ jsonObjects = jsonObjects.subList(0, size > 10 ? 10 : size);
|
|
|
+ for (JSONObject jsonObject : jsonObjects) {
|
|
|
+ String str = jsonObject.getStr("content");
|
|
|
+ if (str.contains("Your ChatGPT code is")) {
|
|
|
+ String code = TicketCodeCommonUtil.getTicketCodeStr(str, goodsId);
|
|
|
+ return code;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -69,4 +77,29 @@ public class CommonMailServiceImpl implements CommonMailService {
|
|
|
//银河域名邮件
|
|
|
return yhMailService.getVerifyCode(account, relateEmail, goodsId, type, linkType, false);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getGptChangePwdLink(String email, String password) throws Exception {
|
|
|
+ String url = "https://ms.lqqq.cc/" + email + "----" + password;
|
|
|
+ HttpRequest post = HttpUtil.createGet(url);
|
|
|
+ HttpResponse execute = post.execute();
|
|
|
+ String body = execute.body();
|
|
|
+ try {
|
|
|
+ List<JSONObject> jsonObjects = Jsons.parseList(body, JSONObject.class);
|
|
|
+ if (jsonObjects.size() > 0) {
|
|
|
+ Integer size = jsonObjects.size();
|
|
|
+ //获取前10封邮件
|
|
|
+ jsonObjects = jsonObjects.subList(0, size > 10 ? 10 : size);
|
|
|
+ for (JSONObject jsonObject : jsonObjects) {
|
|
|
+ String str = jsonObject.getStr("content");
|
|
|
+ if (str.contains(GPT_RESET_PWD_LINK_REGEX)) {
|
|
|
+ return TicketCodeCommonUtil.extractUrl(str, GPT_RESET_PWD_LINK_REGEX).replaceAll(">", "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw BusinessRuntimeException.getInstance("邮箱或密码错误");
|
|
|
+ }
|
|
|
+ throw BusinessRuntimeException.getInstance("未收到重置密码链接");
|
|
|
+ }
|
|
|
}
|