REQ-3345: 如果聊天消息只有一个人的情况下,同步发送
This commit is contained in:
parent
8569f32333
commit
6c87f57624
@ -27,7 +27,6 @@ import cn.axzo.im.center.api.vo.resp.MessageUpdateResponse;
|
|||||||
import cn.axzo.im.center.api.vo.resp.UpdatableMessageSendResult;
|
import cn.axzo.im.center.api.vo.resp.UpdatableMessageSendResult;
|
||||||
import cn.axzo.im.center.api.vo.resp.UserAccountResp;
|
import cn.axzo.im.center.api.vo.resp.UserAccountResp;
|
||||||
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
||||||
import cn.axzo.im.channel.netease.dto.MessageDispatchResponse;
|
|
||||||
import cn.axzo.im.entity.AccountRegister;
|
import cn.axzo.im.entity.AccountRegister;
|
||||||
import cn.axzo.im.entity.MessageHistory;
|
import cn.axzo.im.entity.MessageHistory;
|
||||||
import cn.axzo.im.entity.MessageTask;
|
import cn.axzo.im.entity.MessageTask;
|
||||||
@ -289,15 +288,7 @@ public class MessageController implements MessageApi {
|
|||||||
task = messageTaskService.getById(task.getId());
|
task = messageTaskService.getById(task.getId());
|
||||||
List<Long> historyIds = messageTaskService.createMessageHistory(task);
|
List<Long> historyIds = messageTaskService.createMessageHistory(task);
|
||||||
MessageHistory history = messageHistoryService.getById(historyIds.get(0));
|
MessageHistory history = messageHistoryService.getById(historyIds.get(0));
|
||||||
MessageDispatchResponse response = commonSendOneHandler.send(history);
|
commonSendOneHandler.updateSyncSendState(history, commonSendOneHandler.send(history));
|
||||||
if (response.isSuccess()) {
|
|
||||||
messageHistoryService.setSendSuccess(history, response.getMsgid(), null);
|
|
||||||
log.info("sendChatMessage, send success, historyId={}, taskId={}, bizId={}",
|
|
||||||
history.getId(), history.getImMessageTaskId(), history.getBizId());
|
|
||||||
} else {
|
|
||||||
log.warn("sendChatMessage, send failed, historyId={}, taskId={}, bizId={}, failReason={}",
|
|
||||||
history.getId(), history.getImMessageTaskId(), history.getBizId(), response.getDesc());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return task.getId();
|
return task.getId();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,13 +7,16 @@ import cn.axzo.im.channel.netease.dto.MessageDispatchResponse;
|
|||||||
import cn.axzo.im.entity.MessageHistory;
|
import cn.axzo.im.entity.MessageHistory;
|
||||||
import cn.axzo.im.send.MessageHistoryNimLogger;
|
import cn.axzo.im.send.MessageHistoryNimLogger;
|
||||||
import cn.axzo.im.send.SendExecutor;
|
import cn.axzo.im.send.SendExecutor;
|
||||||
|
import cn.axzo.im.service.impl.MessageHistoryServiceImpl;
|
||||||
import cn.axzo.im.utils.ImProperties;
|
import cn.axzo.im.utils.ImProperties;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yanglin
|
* @author yanglin
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CommonSendOneHandler extends SendOneHandler {
|
public class CommonSendOneHandler extends SendOneHandler {
|
||||||
@ -21,6 +24,7 @@ public class CommonSendOneHandler extends SendOneHandler {
|
|||||||
private final ImProperties props;
|
private final ImProperties props;
|
||||||
private final IMChannelProvider imChannelProvider;
|
private final IMChannelProvider imChannelProvider;
|
||||||
private final MessageHistoryNimLogger messageHistoryNimLogger;
|
private final MessageHistoryNimLogger messageHistoryNimLogger;
|
||||||
|
private final MessageHistoryServiceImpl messageHistoryService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAndSubmitUpdate(SendExecutor<MessageHistory> executor, MessageHistory history) {
|
public void sendAndSubmitUpdate(SendExecutor<MessageHistory> executor, MessageHistory history) {
|
||||||
@ -55,6 +59,17 @@ public class CommonSendOneHandler extends SendOneHandler {
|
|||||||
return imChannelProvider.dispatchMessage(sendRequest);
|
return imChannelProvider.dispatchMessage(sendRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateSyncSendState(MessageHistory history, MessageDispatchResponse response) {
|
||||||
|
if (response.isSuccess()) {
|
||||||
|
messageHistoryService.setSendSuccess(history, response.getMsgid(), null);
|
||||||
|
log.info("sync send success, historyId={}, taskId={}, bizId={}",
|
||||||
|
history.getId(), history.getImMessageTaskId(), history.getBizId());
|
||||||
|
} else {
|
||||||
|
log.warn("sync send failed, historyId={}, taskId={}, bizId={}, failReason={}",
|
||||||
|
history.getId(), history.getImMessageTaskId(), history.getBizId(), response.getDesc());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ImProperties getProps() {
|
ImProperties getProps() {
|
||||||
return props;
|
return props;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user