use of com.fanap.podchat.mainmodel.ResultDeleteMessage in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method findDeletedMessages.
private void findDeletedMessages(List<MessageVO> messagesFromCache, List<MessageVO> newMessagesFromServer, String uniqueId, long threadId) {
for (MessageVO msg : messagesFromCache) {
if (!newMessagesFromServer.contains(msg)) {
ChatResponse<ResultDeleteMessage> chatResponse = MessageManager.prepareDeleteMessageResponseForFind(msg, uniqueId, threadId);
String jsonDeleteMsg = gson.toJson(chatResponse);
listenerManager.callOnDeleteMessage(jsonDeleteMsg, chatResponse);
showLog("RECEIVE_DELETE_MESSAGE", jsonDeleteMsg);
if (cache) {
dataSource.deleteMessage(msg, threadId);
messageDatabaseHelper.deleteMessage(msg.getId(), threadId);
showLog("Delete message from database with this messageId" + " " + msg.getId(), "");
}
}
}
}
use of com.fanap.podchat.mainmodel.ResultDeleteMessage in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method prepareDeleteMessageResponseForFind.
public static ChatResponse<ResultDeleteMessage> prepareDeleteMessageResponseForFind(MessageVO msg, String uniqueId, long threadId) {
ChatResponse<ResultDeleteMessage> chatResponse = new ChatResponse<>();
chatResponse.setUniqueId(uniqueId);
ResultDeleteMessage resultDeleteMessage = new ResultDeleteMessage();
DeleteMessageContent deleteMessage = new DeleteMessageContent();
deleteMessage.setId(msg.getId());
resultDeleteMessage.setDeletedMessage(deleteMessage);
chatResponse.setResult(resultDeleteMessage);
chatResponse.setSubjectId(threadId);
return chatResponse;
}
use of com.fanap.podchat.mainmodel.ResultDeleteMessage in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method prepareDeleteMessageResponse.
public static ChatResponse<ResultDeleteMessage> prepareDeleteMessageResponse(ChatMessage chatMessage, long messageId) {
ChatResponse<ResultDeleteMessage> chatResponse = new ChatResponse<>();
chatResponse.setUniqueId(chatMessage.getUniqueId());
ResultDeleteMessage resultDeleteMessage = new ResultDeleteMessage();
DeleteMessageContent deleteMessage = new DeleteMessageContent();
deleteMessage.setId(messageId);
resultDeleteMessage.setDeletedMessage(deleteMessage);
chatResponse.setResult(resultDeleteMessage);
chatResponse.setSubjectId(chatMessage.getSubjectId());
return chatResponse;
}
use of com.fanap.podchat.mainmodel.ResultDeleteMessage in project pod-chat-android-sdk by FanapSoft.
the class ThreadCacheTest method sendMessageAndDelete.
public void sendMessageAndDelete() {
populateThreadsFromServer();
Collections.shuffle(threadsInServer);
Thread thread = threadsInServer.get(0);
Assert.assertNotNull(thread);
ArrayList<Long> msgIds = new ArrayList<>();
// send new message
chatListeners = new ChatListener() {
@Override
public void onNewMessage(String content, ChatResponse<ResultNewMessage> response) {
resumeProcess();
msgIds.add(response.getResult().getMessageVO().getId());
System.out.println("new message sent -> msg : " + content);
chat.removeListener(chatListeners);
}
@Override
public void onError(String content, ErrorOutPut error) {
resumeProcess();
System.out.println("Error: " + content);
Assert.assertEquals(0, 1);
chat.removeListener(chatListeners);
}
};
chat.addListener(chatListeners);
RequestMessage request = new RequestMessage.Builder("Message for test delete :" + thread.getId(), thread.getId()).messageType(TextMessageType.Constants.TEXT).build();
chat.sendTextMessage(request, null);
pauseProcess();
// delete last message
chatListeners = new ChatListener() {
@Override
public void onDeleteMessage(String content, ChatResponse<ResultDeleteMessage> response) {
resumeProcess();
System.out.println("Deleted: " + content);
chat.removeListener(chatListeners);
}
@Override
public void onError(String content, ErrorOutPut error) {
resumeProcess();
System.out.println("Error: " + content);
Assert.assertEquals(0, 1);
chat.removeListener(chatListeners);
}
};
chat.addListener(chatListeners);
RequestDeleteMessage requestDeleteMessage = new RequestDeleteMessage.Builder().messageIds(msgIds).deleteForAll(true).build();
presenter.deleteMessage(requestDeleteMessage, null);
pauseProcess();
}
Aggregations