REQ-2010: 如果未测试IM账号, 返回对应的错误信息
This commit is contained in:
parent
eb77ac18f4
commit
5db9681d03
@ -64,4 +64,9 @@ public class MessageDispatchResp {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 失败原因
|
||||||
|
*/
|
||||||
|
private String sendFailCause;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,15 +29,6 @@ import cn.axzo.im.entity.MessageHistory;
|
|||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
@ -50,6 +41,18 @@ import org.springframework.core.env.Environment;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* im-center
|
* im-center
|
||||||
*
|
*
|
||||||
@ -121,7 +124,10 @@ public class MessageService {
|
|||||||
log.info("sendBatchMessage批量发送消息:" + JSONUtil.toJsonStr(messageInfo));
|
log.info("sendBatchMessage批量发送消息:" + JSONUtil.toJsonStr(messageInfo));
|
||||||
messageDispatchRespList = sendBatchMessage(messageInfo, messageRequest);
|
messageDispatchRespList = sendBatchMessage(messageInfo, messageRequest);
|
||||||
}
|
}
|
||||||
insertImMessage(messageDispatchRespList, messageRequest.getBody());
|
List<MessageDispatchResp> saveRespList = messageDispatchRespList.stream()
|
||||||
|
.filter(i -> StringUtils.isBlank(i.getSendFailCause()))
|
||||||
|
.collect(toList());
|
||||||
|
insertImMessage(saveRespList, messageRequest.getBody());
|
||||||
return messageDispatchRespList;
|
return messageDispatchRespList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,6 +219,14 @@ public class MessageService {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
log.warn("发送IM消息异常,不存在personId=[" + sourcePersonId + "]的IM账户");
|
log.warn("发送IM消息异常,不存在personId=[" + sourcePersonId + "]的IM账户");
|
||||||
|
MessageDispatchResp resp = new MessageDispatchResp();
|
||||||
|
resp.setAppType(appType);
|
||||||
|
resp.setTimetag(System.currentTimeMillis());
|
||||||
|
resp.setFromImAccount(messageRequest.getFrom());
|
||||||
|
resp.setToImAccount(messageRequest.getTo());
|
||||||
|
resp.setPersonId(sourcePersonId);
|
||||||
|
resp.setSendFailCause(sourcePersonId + " 未注册IM账户");
|
||||||
|
messageDispatchRespList.add(resp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<List<String>> personPage = Lists.partition(toPersonIMList, msgSendPersonOfOneBatch);
|
List<List<String>> personPage = Lists.partition(toPersonIMList, msgSendPersonOfOneBatch);
|
||||||
@ -300,6 +314,14 @@ public class MessageService {
|
|||||||
messageRequest.getFrom(), null,
|
messageRequest.getFrom(), null,
|
||||||
personId, appType.getCode(), 0L, "unregistered");
|
personId, appType.getCode(), 0L, "unregistered");
|
||||||
log.warn("用户personId=[" + personId + "],appType[" + appType.getCode() + "],未注册IM账户,不进行消息发送!");
|
log.warn("用户personId=[" + personId + "],appType[" + appType.getCode() + "],未注册IM账户,不进行消息发送!");
|
||||||
|
MessageDispatchResp resp = new MessageDispatchResp();
|
||||||
|
resp.setAppType(appType.getCode());
|
||||||
|
resp.setTimetag(System.currentTimeMillis());
|
||||||
|
resp.setFromImAccount(messageRequest.getFrom());
|
||||||
|
resp.setToImAccount(messageRequest.getTo());
|
||||||
|
resp.setPersonId(personId);
|
||||||
|
resp.setSendFailCause(personId + " 未注册IM账户");
|
||||||
|
messageDispatchRespList.add(resp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
accountRegisterList.forEach(accountRegister -> {
|
accountRegisterList.forEach(accountRegister -> {
|
||||||
@ -442,7 +464,7 @@ public class MessageService {
|
|||||||
messageHistory.setCreateAt(new Date());
|
messageHistory.setCreateAt(new Date());
|
||||||
messageHistory.setUpdateAt(new Date());
|
messageHistory.setUpdateAt(new Date());
|
||||||
return messageHistory;
|
return messageHistory;
|
||||||
}).collect(Collectors.toList());
|
}).collect(toList());
|
||||||
try {
|
try {
|
||||||
messageHistoryDao.saveOrUpdateBatch(histories);
|
messageHistoryDao.saveOrUpdateBatch(histories);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user