REQ-2010: 如果未测试IM账号, 返回对应的错误信息
This commit is contained in:
parent
eb77ac18f4
commit
5db9681d03
@ -64,4 +64,9 @@ public class MessageDispatchResp {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
private String sendFailCause;
|
||||
}
|
||||
|
||||
@ -29,15 +29,6 @@ import cn.axzo.im.entity.MessageHistory;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
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.extern.slf4j.Slf4j;
|
||||
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.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
|
||||
*
|
||||
@ -121,7 +124,10 @@ public class MessageService {
|
||||
log.info("sendBatchMessage批量发送消息:" + JSONUtil.toJsonStr(messageInfo));
|
||||
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;
|
||||
}
|
||||
|
||||
@ -213,6 +219,14 @@ public class MessageService {
|
||||
});
|
||||
} else {
|
||||
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);
|
||||
@ -300,6 +314,14 @@ public class MessageService {
|
||||
messageRequest.getFrom(), null,
|
||||
personId, appType.getCode(), 0L, "unregistered");
|
||||
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;
|
||||
}
|
||||
accountRegisterList.forEach(accountRegister -> {
|
||||
@ -442,7 +464,7 @@ public class MessageService {
|
||||
messageHistory.setCreateAt(new Date());
|
||||
messageHistory.setUpdateAt(new Date());
|
||||
return messageHistory;
|
||||
}).collect(Collectors.toList());
|
||||
}).collect(toList());
|
||||
try {
|
||||
messageHistoryDao.saveOrUpdateBatch(histories);
|
||||
} catch (Exception e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user