feat:REQ-1419 fixbug 消息发送异常
This commit is contained in:
parent
f00b64f327
commit
216d7ed46e
@ -45,4 +45,9 @@ public class MessageDispatchResp {
|
||||
* 接收人IM账户
|
||||
*/
|
||||
private String toImAccount;
|
||||
|
||||
/**
|
||||
* 接收人personId
|
||||
*/
|
||||
private String personId;
|
||||
}
|
||||
|
||||
@ -132,22 +132,30 @@ public class MessageService {
|
||||
toPersonImList.add(accountRegister.getImAccount());
|
||||
});
|
||||
if (CollectionUtils.isEmpty(toPersonImList)) {
|
||||
throw new ServiceException("接收端所有用户无IM账户[" + JSONUtil.toJsonStr(messageInfo.getToPersonIdList()) + "]");
|
||||
String errorMsg = "接收端[" + appType.getCode() + "]所有用户无IM账户[" + JSONUtil.toJsonStr(messageInfo.getToPersonIdList()) + "]";
|
||||
log.warn(errorMsg);
|
||||
throw new ServiceException(errorMsg);
|
||||
}
|
||||
//目前仅支持单个用户进行IM消息发送
|
||||
messageRequest.setTo(toPersonImList.get(0));
|
||||
MessageDispatchResponse response = imChannel.dispatchMessage(messageRequest);
|
||||
MessageDispatchResp messageDispatchResp = BeanMapper.map(response.getData(), MessageDispatchResp.class);
|
||||
if (StringUtils.isNotBlank(response.getDesc())) {
|
||||
if (messageDispatchResp == null) {
|
||||
messageDispatchResp = new MessageDispatchResp();
|
||||
//目前支持单个用户进行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);
|
||||
}
|
||||
messageDispatchResp.setDesc(response.getDesc());
|
||||
}
|
||||
messageDispatchResp.setAppType(appType.getCode());
|
||||
messageDispatchResp.setFromImAccount(messageRequest.getFrom());
|
||||
messageDispatchResp.setToImAccount(messageRequest.getTo());
|
||||
messageDispatchRespList.add(messageDispatchResp);
|
||||
});
|
||||
});
|
||||
insertImMessage(messageDispatchRespList, body);
|
||||
return messageDispatchRespList;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user