use of com.fanap.podchat.chat.user.profile.ChatProfileVO in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method saveCallParticipant.
private void saveCallParticipant(Participant participant, long callId) {
CacheCallParticipant callParticipant = new CacheCallParticipant().fromParticipant(participant, callId);
messageDao.insertCallParticipant(callParticipant);
if (callParticipant.getChatProfileVO() != null) {
ChatProfileVO chatProfileVO = callParticipant.getChatProfileVO();
chatProfileVO.setId(callParticipant.getId());
messageDao.insertChatProfile(chatProfileVO);
}
// CacheParticipantRoles cpr = new CacheParticipantRoles();
//
// cpr.setId(participant.getId());
//
// cpr.setThreadId(callId);
//
// cpr.setRoles(participant.getRoles());
//
// messageDao.insertRoles(cpr);
}
use of com.fanap.podchat.chat.user.profile.ChatProfileVO in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method saveParticipant.
public void saveParticipant(@NonNull CacheParticipant participant, long threadId, int expireSecond) {
worker(() -> {
participant.setThreadId(threadId);
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.SECOND, expireSecond);
String expireDate = format.format(c.getTime());
messageDao.insertParticipant(participant);
CacheThreadParticipant ctp = new CacheThreadParticipant();
ctp.setExpireDate(expireDate);
ctp.setParticipantId(participant.getId());
ctp.setThreadId(threadId);
messageDao.insertThreadParticipant(ctp);
if (!Util.isNullOrEmpty(participant.getRoles())) {
CacheParticipantRoles cpr = new CacheParticipantRoles();
cpr.setId(participant.getId());
cpr.setThreadId(threadId);
cpr.setRoles(participant.getRoles());
Log.d("MTAG", "SAVE CPR: " + cpr);
messageDao.insertRoles(cpr);
}
if (participant.getChatProfileVO() != null) {
ChatProfileVO chatProfileVO = participant.getChatProfileVO();
chatProfileVO.setId(participant.getId());
messageDao.insertChatProfile(chatProfileVO);
}
});
}
use of com.fanap.podchat.chat.user.profile.ChatProfileVO in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method saveParticipants.
/**
* Cache participant
*/
public void saveParticipants(@NonNull List<CacheParticipant> participants, long threadId, int expireSecond) {
worker(() -> {
for (CacheParticipant participant : participants) {
participant.setThreadId(threadId);
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss", Locale.getDefault());
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.SECOND, expireSecond);
String expireDate = format.format(c.getTime());
messageDao.insertParticipant(participant);
CacheThreadParticipant ctp = new CacheThreadParticipant();
ctp.setExpireDate(expireDate);
ctp.setParticipantId(participant.getId());
ctp.setThreadId(threadId);
messageDao.insertThreadParticipant(ctp);
if (!Util.isNullOrEmpty(participant.getRoles())) {
CacheParticipantRoles cpr = new CacheParticipantRoles();
cpr.setId(participant.getId());
cpr.setThreadId(threadId);
cpr.setRoles(participant.getRoles());
Log.d("MTAG", "SAVE CPR: " + cpr);
messageDao.insertRoles(cpr);
}
if (participant.getChatProfileVO() != null) {
ChatProfileVO chatProfileVO = participant.getChatProfileVO();
chatProfileVO.setId(participant.getId());
messageDao.insertChatProfile(chatProfileVO);
}
}
});
}
use of com.fanap.podchat.chat.user.profile.ChatProfileVO in project pod-chat-android-sdk by FanapSoft.
the class MessageDatabaseHelper method updateChatProfile.
public void updateChatProfile(ResultUpdateProfile result) {
worker(() -> {
UserInfo userInfo = getUserInfo();
ChatProfileVO chatProfileVO = new ChatProfileVO();
chatProfileVO.setId(userInfo.getId());
chatProfileVO.setBio(result.getBio());
userInfo.setChatProfileVO(chatProfileVO);
messageDao.insertChatProfile(chatProfileVO);
messageDao.insertUserInfo(userInfo);
});
}
use of com.fanap.podchat.chat.user.profile.ChatProfileVO 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