use of com.fanap.podchat.model.ConversationSummery in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method prepareMessageVOs.
private void prepareMessageVOs(List<MessageVO> messageVOS, List<CacheMessageVO> cacheMessageVOS) {
for (CacheMessageVO cacheMessageVO : cacheMessageVOS) {
Participant participant = null;
ReplyInfoVO replyInfoVO = null;
ForwardInfo forwardInfo = null;
ConversationSummery conversationSummery = null;
if (cacheMessageVO.getForwardInfoId() != null) {
cacheMessageVO.setForwardInfo(messageDao.getForwardInfo(cacheMessageVO.getForwardInfoId()));
}
if (cacheMessageVO.getParticipantId() != null) {
CacheParticipant cacheParticipant = messageDao.getParticipant(cacheMessageVO.getParticipantId());
if (cacheParticipant != null) {
ChatProfileVO profileVO = messageDao.getChatProfileVOById(cacheParticipant.getId());
cacheParticipant.setChatProfileVO(profileVO);
participant = cacheToParticipantMapper(cacheParticipant, null, null);
} else {
if (cacheMessageVO.getConversationId() > 0)
messageDao.deleteParticipant(cacheMessageVO.getConversationId(), cacheMessageVO.getParticipantId());
}
}
ThreadVo thread = messageDao.getThreadById(cacheMessageVO.getConversationId());
cacheMessageVO.setConversation(thread);
if (cacheMessageVO.getReplyInfoVOId() != null) {
CacheReplyInfoVO cacheReplyInfoVO = messageDao.getReplyInfo(cacheMessageVO.getReplyInfoVOId());
if (cacheReplyInfoVO != null) {
replyInfoVO = new ReplyInfoVO(cacheReplyInfoVO.getRepliedToMessageId(), cacheReplyInfoVO.getMessageType(), cacheReplyInfoVO.isDeleted(), cacheReplyInfoVO.getRepliedToMessage(), cacheReplyInfoVO.getSystemMetadata(), cacheReplyInfoVO.getMetadata(), cacheReplyInfoVO.getMessage(), cacheReplyInfoVO.getRepliedToMessageTime(), cacheReplyInfoVO.getRepliedToMessageNanos());
if (cacheReplyInfoVO.getParticipantId() > 0) {
CacheParticipant cacheParticipant = messageDao.getParticipant(cacheReplyInfoVO.getParticipantId());
if (cacheParticipant != null) {
Participant replyParticipant = cacheToParticipantMapper(cacheParticipant, false, null);
replyInfoVO.setParticipant(replyParticipant);
}
}
}
}
if (cacheMessageVO.getForwardInfo() != null) {
CacheForwardInfo cacheForwardInfo = messageDao.getForwardInfo(cacheMessageVO.getForwardInfoId());
if (cacheForwardInfo != null) {
if (cacheForwardInfo.getParticipantId() != null) {
CacheParticipant cacheParticipant = messageDao.getParticipant(cacheForwardInfo.getParticipantId());
if (cacheParticipant != null) {
participant = cacheToParticipantMapper(cacheParticipant, null, null);
}
}
if (Util.isNullOrEmpty(cacheForwardInfo.getConversationId())) {
// todo check it again
conversationSummery = messageDao.getConversationSummery(cacheForwardInfo.getConversationId());
}
forwardInfo = new ForwardInfo(participant, conversationSummery);
}
}
Thread msgThread = threadVoToThreadMapper(cacheMessageVO.getConversation(), null);
MessageVO messageVO = cacheMessageVoToMessageVoMapper(participant, replyInfoVO, forwardInfo, cacheMessageVO);
messageVO.setConversation(msgThread);
messageVOS.add(messageVO);
}
}
Aggregations