use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method unMuteThread.
/**
* It Un mutes the thread so notification is on for that thread
*/
public String unMuteThread(RequestMuteThread request, ChatHandler handler) {
String uniqueId;
uniqueId = generateUniqueId();
JsonObject jsonObject = null;
try {
if (chatReady) {
long threadId = request.getThreadId();
String typeCode = request.getTypeCode();
ChatMessage chatMessage = new ChatMessage();
chatMessage.setType(Constants.UN_MUTE_THREAD);
chatMessage.setToken(getToken());
chatMessage.setTokenIssuer("1");
chatMessage.setSubjectId(threadId);
chatMessage.setUniqueId(uniqueId);
jsonObject = (JsonObject) gson.toJsonTree(chatMessage);
jsonObject.remove("contentCount");
jsonObject.remove("systemMetadata");
jsonObject.remove("metadata");
jsonObject.remove("repliedTo");
if (Util.isNullOrEmpty(typeCode)) {
if (Util.isNullOrEmpty(getTypeCode())) {
jsonObject.remove("typeCode");
} else {
jsonObject.addProperty("typeCode", getTypeCode());
}
} else {
jsonObject.addProperty("typeCode", request.getTypeCode());
}
setCallBacks(null, null, null, true, Constants.UN_MUTE_THREAD, null, uniqueId);
sendAsyncMessage(jsonObject.toString(), AsyncAckType.Constants.WITHOUT_ACK, "SEND_UN_MUTE_THREAD");
if (handler != null) {
handler.onUnMuteThread(uniqueId);
}
} else {
captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, uniqueId);
}
} catch (Exception e) {
showErrorLog(e.getMessage());
onUnknownException(uniqueId, e);
}
return uniqueId;
}
use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method getChatMessage.
@NonNull
private ChatMessage getChatMessage(MessageVO jsonMessage) {
ChatMessage message = new ChatMessage();
message.setType(Constants.DELIVERY);
message.setContent(String.valueOf(jsonMessage.getId()));
message.setTokenIssuer("1");
message.setToken(getToken());
message.setUniqueId(generateUniqueId());
message.setTime(1000);
return message;
}
use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method publishNewMessages.
private void publishNewMessages(List<MessageVO> newMessages, long threadId, String uniqueId) {
for (MessageVO messageVO : newMessages) {
try {
// gson.toJson(chatResponse);
ChatResponse<ResultNewMessage> chatResponse = MessageManager.preparepublishNewMessagesResponse(messageVO, threadId);
String json = gson.toJson(chatResponse);
listenerManager.callOnNewMessage(json, chatResponse);
long ownerId = 0;
if (messageVO.getParticipant() != null) {
ownerId = messageVO.getParticipant().getId();
}
showLog("RECEIVED_NEW_MESSAGE", json);
if (ownerId > 0 && ownerId != getUserId()) {
ChatMessage message = getChatMessage(messageVO);
String asyncContent = gson.toJson(message);
async.sendMessage(asyncContent, AsyncAckType.Constants.WITHOUT_ACK);
setThreadCallbacks(threadId, uniqueId);
showLog("SEND_DELIVERY_MESSAGE", asyncContent);
}
} catch (Exception e) {
showErrorLog(e.getMessage());
onUnknownException(uniqueId, e);
}
}
}
use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class ContactManager method prepareGetBlockListRequest.
public static String prepareGetBlockListRequest(Long count, Long offset, String uniqueId, String typecode, String token) {
JsonObject content = new JsonObject();
if (offset != null) {
content.addProperty("offset", offset);
}
if (count != null) {
content.addProperty("count", count);
} else {
content.addProperty("count", 50);
}
ChatMessage chatMessage = new ChatMessage();
chatMessage.setContent(content.toString());
chatMessage.setType(ChatMessageType.Constants.GET_BLOCKED);
chatMessage.setTokenIssuer("1");
chatMessage.setToken(token);
chatMessage.setUniqueId(uniqueId);
JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
if (Util.isNullOrEmpty(typecode)) {
jsonObject.remove("typeCode");
} else {
jsonObject.remove("typeCode");
jsonObject.addProperty("typeCode", typecode);
}
return jsonObject.toString();
}
use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class AssistantManager method createGetBlockedAssistantsRequest.
public static String createGetBlockedAssistantsRequest(GetBlockedAssistantsRequest request, String uniqueId) {
JsonObject content = new JsonObject();
content.addProperty("contactType", request.getTypeCode());
if ((Long) request.getOffset() != null) {
content.addProperty("offset", request.getOffset());
}
if ((Long) request.getCount() != null) {
content.addProperty("count", request.getCount());
} else {
content.addProperty("count", 50);
}
AsyncMessage message = new ChatMessage();
message.setType(ChatMessageType.Constants.GET_BLOCKED_ASSISTANTS);
message.setToken(CoreConfig.token);
message.setTokenIssuer(CoreConfig.tokenIssuer);
message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
message.setContent(App.getGson().toJson(content));
message.setUniqueId(uniqueId);
return App.getGson().toJson(message);
}
Aggregations