Search in sources :

Example 51 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class PinThread method pinThread.

public static String pinThread(RequestPinThread request, String uniqueId) {
    long threadId = request.getThreadId();
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.PIN_THREAD);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    message.setSubjectId(threadId);
    message.setUniqueId(uniqueId);
    return App.getGson().toJson(message);
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage)

Example 52 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class PinThread method unPinThread.

public static String unPinThread(RequestPinThread request, String uniqueId) {
    long threadId = request.getThreadId();
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.UNPIN_THREAD);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    message.setSubjectId(threadId);
    message.setUniqueId(uniqueId);
    return App.getGson().toJson(message);
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage)

Example 53 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class ContactManager method prepareBlockRequest.

public static String prepareBlockRequest(Long contactId, Long userId, Long threadId, String uniqueId, String mtypecode, String token) {
    JsonObject contentObject = new JsonObject();
    if (!Util.isNullOrEmpty(contactId)) {
        contentObject.addProperty("contactId", contactId);
    }
    if (!Util.isNullOrEmpty(userId)) {
        contentObject.addProperty("userId", userId);
    }
    if (!Util.isNullOrEmpty(threadId)) {
        contentObject.addProperty("threadId", threadId);
    }
    String json = contentObject.toString();
    ChatMessage chatMessage = new ChatMessage();
    chatMessage.setContent(json);
    chatMessage.setToken(token);
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setTokenIssuer("1");
    chatMessage.setType(ChatMessageType.Constants.BLOCK);
    chatMessage.setTypeCode(mtypecode);
    JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
    if (Util.isNullOrEmpty(mtypecode)) {
        jsonObject.remove("typeCode");
    } else {
        jsonObject.remove("typeCode");
        jsonObject.addProperty("typeCode", mtypecode);
    }
    return jsonObject.toString();
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) JsonObject(com.google.gson.JsonObject)

Example 54 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class ContactManager method prepareUnBlockRequest.

public static String prepareUnBlockRequest(Long blockId, Long userId, Long threadId, Long contactId, String uniqueId, String mtypecode, String token) {
    ChatMessage chatMessage = new ChatMessage();
    JsonObject contentObject = new JsonObject();
    if (!Util.isNullOrEmpty(contactId)) {
        contentObject.addProperty("contactId", contactId);
    }
    if (!Util.isNullOrEmpty(userId)) {
        contentObject.addProperty("userId", userId);
    }
    if (!Util.isNullOrEmpty(threadId)) {
        contentObject.addProperty("threadId", threadId);
    }
    String jsonContent = contentObject.toString();
    chatMessage.setContent(jsonContent);
    chatMessage.setToken(token);
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setTokenIssuer("1");
    chatMessage.setType(ChatMessageType.Constants.UNBLOCK);
    JsonObject jsonObject = (JsonObject) App.getGson().toJsonTree(chatMessage);
    jsonObject.remove("contentCount");
    jsonObject.remove("systemMetadata");
    jsonObject.remove("metadata");
    jsonObject.remove("repliedTo");
    if (Util.isNullOrEmpty(blockId)) {
        jsonObject.remove("subjectId");
    } else {
        jsonObject.remove("subjectId");
        jsonObject.addProperty("subjectId", blockId);
    }
    if (Util.isNullOrEmpty(mtypecode)) {
        jsonObject.remove("typeCode");
    } else {
        jsonObject.remove("typeCode");
        jsonObject.addProperty("typeCode", mtypecode);
    }
    return jsonObject.toString();
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) JsonObject(com.google.gson.JsonObject)

Example 55 with ChatMessage

use of com.fanap.podchat.mainmodel.ChatMessage in project pod-chat-android-sdk by FanapSoft.

the class ContactManager method createAddContactRequest.

public static String createAddContactRequest(String uniqueId, String typeCode, List<String> firstNames, List<String> lastNames, List<String> userNames, List<String> cellNumbers, List<String> emails, List<String> uniqIds) {
    AddContactVO addContactVO = new AddContactVO().setEmailList(emails).setFirstNameList(firstNames).setLastNameList(lastNames).setUserNameList(userNames).setCellphoneNumberList(cellNumbers).setUniqueIdList(uniqIds);
    String content = App.getGson().toJson(addContactVO);
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.ADD_CONTACT);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setTypeCode(typeCode != null ? typeCode : CoreConfig.typeCode);
    message.setContent(content);
    message.setUniqueId(uniqueId);
    return App.getGson().toJson(message);
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) AddContactVO(com.fanap.podchat.chat.contact.model.AddContactVO)

Aggregations

ChatMessage (com.fanap.podchat.mainmodel.ChatMessage)56 JsonObject (com.google.gson.JsonObject)33 AsyncMessage (com.fanap.podchat.mainmodel.AsyncMessage)20 RoomIntegrityException (com.fanap.podchat.persistance.RoomIntegrityException)9 PodChatException (com.fanap.podchat.util.PodChatException)9 JsonSyntaxException (com.google.gson.JsonSyntaxException)9 SentryException (io.sentry.core.protocol.SentryException)9 IOException (java.io.IOException)9 JSONException (org.json.JSONException)9 ArrayList (java.util.ArrayList)5 ChatResponse (com.fanap.podchat.model.ChatResponse)4 JsonArray (com.google.gson.JsonArray)4 NonNull (android.support.annotation.NonNull)3 CacheMessageVO (com.fanap.podchat.cachemodel.CacheMessageVO)3 GapMessageVO (com.fanap.podchat.cachemodel.GapMessageVO)3 MessageVO (com.fanap.podchat.mainmodel.MessageVO)3 ResultNewMessage (com.fanap.podchat.model.ResultNewMessage)3 JsonElement (com.google.gson.JsonElement)3 TypeToken (com.google.gson.reflect.TypeToken)3 SendingQueueCache (com.fanap.podchat.cachemodel.queue.SendingQueueCache)2