use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method prepareSpamRequest.
public static String prepareSpamRequest(String uniqueId, RequestSpam request, String mtypeCode, String token) {
JsonObject jsonObject;
long threadId = request.getThreadId();
String typeCode = request.getTypeCode();
ChatMessage chatMessage = new ChatMessage();
chatMessage.setType(ChatMessageType.Constants.SPAM_PV_THREAD);
chatMessage.setTokenIssuer("1");
chatMessage.setToken(CoreConfig.token);
chatMessage.setUniqueId(uniqueId);
chatMessage.setSubjectId(threadId);
jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
jsonObject.remove("contentCount");
jsonObject.remove("systemMetadata");
jsonObject.remove("metadata");
jsonObject.remove("repliedTo");
if (Util.isNullOrEmpty(typeCode)) {
if (Util.isNullOrEmpty(mtypeCode)) {
jsonObject.remove("typeCode");
} else {
jsonObject.addProperty("typeCode", CoreConfig.typeCode);
}
} else {
jsonObject.addProperty("typeCode", request.getTypeCode());
}
return jsonObject.toString();
}
use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class MessageManager method prepareSpamRequest.
// for dericated method
public static String prepareSpamRequest(String uniqueId, String mtypeCode, long threadId, String token) {
ChatMessage chatMessage = new ChatMessage();
chatMessage.setType(ChatMessageType.Constants.SPAM_PV_THREAD);
chatMessage.setTokenIssuer("1");
chatMessage.setToken(token);
chatMessage.setUniqueId(uniqueId);
chatMessage.setSubjectId(threadId);
JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
if (Util.isNullOrEmpty(mtypeCode)) {
jsonObject.remove("typeCode");
} else {
jsonObject.remove("typeCode");
jsonObject.addProperty("typeCode", mtypeCode);
}
String asyncContent = jsonObject.toString();
return asyncContent;
}
use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class ThreadManager method prepareGetHIstoryWithUniqueIdsRequest.
public static String prepareGetHIstoryWithUniqueIdsRequest(long threadId, String uniqueId, String[] uniqueIds, String typeCode, String token) {
RequestGetHistory request = new RequestGetHistory.Builder(threadId).offset(0).count(uniqueIds.length).uniqueIds(uniqueIds).build();
String content = App.getGson().toJson(request);
ChatMessage chatMessage = new ChatMessage();
chatMessage.setContent(content);
chatMessage.setType(ChatMessageType.Constants.GET_HISTORY);
chatMessage.setToken(token);
chatMessage.setTokenIssuer("1");
chatMessage.setUniqueId(uniqueId);
chatMessage.setSubjectId(threadId);
JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
if (Util.isNullOrEmpty(typeCode)) {
jsonObject.remove("typeCode");
} else {
jsonObject.remove("typeCode");
jsonObject.addProperty("typeCode", typeCode);
}
String asyncContent = jsonObject.toString();
return asyncContent;
}
use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class ThreadManager method createChangeThreadTypeRequest.
public static String createChangeThreadTypeRequest(ChangeThreadTypeRequest request, String uniqueId) throws PodChatException {
JsonObject content = new JsonObject();
content.addProperty("type", request.getType());
if (request.getUniqname() != null)
content.addProperty("uniqueName", request.getUniqname());
AsyncMessage message = new ChatMessage();
message.setType(ChatMessageType.Constants.CHANGE_THREAD_TYPE);
message.setToken(CoreConfig.token);
message.setTokenIssuer(CoreConfig.tokenIssuer);
message.setContent(content.toString());
message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
message.setSubjectId(request.getThreadId());
message.setUniqueId(uniqueId);
return App.getGson().toJson(message);
}
use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.
the class ThreadManager method prepareCreateThread.
public static String prepareCreateThread(int threadType, Invitee[] invitee, String threadTitle, String description, String image, String metadata, String uniqueId, String typecode, String token) {
List<Invitee> invitees = new ArrayList<Invitee>(Arrays.asList(invitee));
ChatThread chatThread = new ChatThread();
chatThread.setType(threadType);
chatThread.setInvitees(invitees);
chatThread.setTitle(threadTitle);
JsonObject chatThreadObject = (JsonObject) App.getGson().toJsonTree(chatThread);
if (Util.isNullOrEmpty(description)) {
chatThreadObject.remove("description");
} else {
chatThreadObject.remove("description");
chatThreadObject.addProperty("description", description);
}
if (Util.isNullOrEmpty(image)) {
chatThreadObject.remove("image");
} else {
chatThreadObject.remove("image");
chatThreadObject.addProperty("image", image);
}
if (Util.isNullOrEmpty(metadata)) {
chatThreadObject.remove("metadata");
} else {
chatThreadObject.remove("metadata");
chatThreadObject.addProperty("metadata", metadata);
}
String contentThreadChat = chatThreadObject.toString();
ChatMessage chatMessage = getChatMessage(contentThreadChat, uniqueId, typecode, token);
JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
if (Util.isNullOrEmpty(typecode)) {
jsonObject.remove("typeCode");
} else {
jsonObject.remove("typeCode");
jsonObject.addProperty("typeCode", typecode);
}
String asyncContent = jsonObject.toString();
return asyncContent;
}
Aggregations