|
|
@@ -3,7 +3,9 @@ package com.izouma.awesomeAdmin.web;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
|
|
+import com.izouma.awesomeAdmin.pojo.InboundMessage;
|
|
|
import com.izouma.awesomeAdmin.pojo.InboundMessageNotification;
|
|
|
import com.izouma.awesomeAdmin.utils.CspUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -33,17 +35,19 @@ public class CallbackController {
|
|
|
log.info("InboundMessageNotification for {}: \n{}", chatbotURI, httpEntity.getBody());
|
|
|
|
|
|
XmlMapper xmlMapper = new XmlMapper();
|
|
|
+ xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
try {
|
|
|
- InboundMessageNotification inboundMessage = xmlMapper
|
|
|
+ InboundMessageNotification inboundMessageNotification = xmlMapper
|
|
|
.readValue(httpEntity.getBody(), InboundMessageNotification.class);
|
|
|
+ InboundMessage inboundMessage = inboundMessageNotification.getInboundMessage();
|
|
|
if (StringUtils.isNotEmpty(inboundMessage.getBodyText())) {
|
|
|
String body = new String(Base64.getDecoder()
|
|
|
.decode(inboundMessage.getBodyText()), StandardCharsets.UTF_8);
|
|
|
log.info("bodyText: \n{}", body);
|
|
|
JSONObject jsonObject = JSON.parseObject(body);
|
|
|
- String replyText = jsonObject.getJSONObject("jsonObject").getJSONObject("reply")
|
|
|
+ String replyText = jsonObject.getJSONObject("response").getJSONObject("reply")
|
|
|
.getJSONObject("postback").getString("data");
|
|
|
- if ("联系我们".equals(replyText)) {
|
|
|
+ if ("联系方式".equals(replyText)) {
|
|
|
Pattern pattern = Pattern.compile("sip:(?<phone>.+)@.+");
|
|
|
Matcher matcher = pattern.matcher(inboundMessage.getSenderAddress());
|
|
|
if (matcher.matches()) {
|
|
|
@@ -58,6 +62,7 @@ public class CallbackController {
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
+ log.error("InboundMessageNotification error", e);
|
|
|
}
|
|
|
}
|
|
|
|