feat:REQ-1419 fixbug 消息发送异常
This commit is contained in:
parent
216d7ed46e
commit
d6f96ca959
@ -117,8 +117,7 @@ public class MessageService {
|
||||
throw new ServiceException("当前服务器不支持该appType类型!");
|
||||
}
|
||||
List<String> toPersonList = messageInfo.getToPersonIdList();
|
||||
List<String> toPersonImList = Lists.newArrayList();
|
||||
//进行接收用户IM账户校验
|
||||
//进行接收用户IM账户校验 目前支持单个用户进行IM消息发送,多个IM用户进行消息接收
|
||||
toPersonList.forEach(personId -> {
|
||||
AccountRegister accountRegister = accountRegisterDao.lambdaQuery().eq(AccountRegister::getIsDelete, 0)
|
||||
.eq(AccountRegister::getAccountId, personId)
|
||||
@ -129,32 +128,20 @@ public class MessageService {
|
||||
log.warn("接收用户账户[" + personId + "],appType[" + appType.getCode() + "],未注册IM账户!");
|
||||
return;
|
||||
}
|
||||
toPersonImList.add(accountRegister.getImAccount());
|
||||
});
|
||||
if (CollectionUtils.isEmpty(toPersonImList)) {
|
||||
String errorMsg = "接收端[" + appType.getCode() + "]所有用户无IM账户[" + JSONUtil.toJsonStr(messageInfo.getToPersonIdList()) + "]";
|
||||
log.warn(errorMsg);
|
||||
throw new ServiceException(errorMsg);
|
||||
}
|
||||
//目前支持单个用户进行IM消息发送,多个IM用户进行消息接收
|
||||
toPersonImList.stream().forEach(new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(String personId) {
|
||||
messageRequest.setTo(personId);
|
||||
MessageDispatchResponse response = imChannel.dispatchMessage(messageRequest);
|
||||
MessageDispatchResp messageDispatchResp = BeanMapper.map(response.getData(), MessageDispatchResp.class);
|
||||
if (messageDispatchResp == null) {
|
||||
messageDispatchResp = new MessageDispatchResp();
|
||||
}
|
||||
if (StringUtils.isNotBlank(response.getDesc())) {
|
||||
messageDispatchResp.setDesc(response.getDesc());
|
||||
}
|
||||
messageDispatchResp.setAppType(appType.getCode());
|
||||
messageDispatchResp.setFromImAccount(messageRequest.getFrom());
|
||||
messageDispatchResp.setToImAccount(messageRequest.getTo());
|
||||
messageDispatchResp.setPersonId(personId);
|
||||
messageDispatchRespList.add(messageDispatchResp);
|
||||
messageRequest.setTo(accountRegister.getImAccount());
|
||||
MessageDispatchResponse response = imChannel.dispatchMessage(messageRequest);
|
||||
MessageDispatchResp messageDispatchResp = BeanMapper.map(response.getData(), MessageDispatchResp.class);
|
||||
if (messageDispatchResp == null) {
|
||||
messageDispatchResp = new MessageDispatchResp();
|
||||
}
|
||||
if (StringUtils.isNotBlank(response.getDesc())) {
|
||||
messageDispatchResp.setDesc(response.getDesc());
|
||||
}
|
||||
messageDispatchResp.setAppType(appType.getCode());
|
||||
messageDispatchResp.setFromImAccount(messageRequest.getFrom());
|
||||
messageDispatchResp.setToImAccount(accountRegister.getImAccount());
|
||||
messageDispatchResp.setPersonId(personId);
|
||||
messageDispatchRespList.add(messageDispatchResp);
|
||||
});
|
||||
});
|
||||
insertImMessage(messageDispatchRespList, body);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user