Search in sources :

Example 46 with ChatMessage

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

the class ThreadManager method prepareRemoveRoleRequest.

public static String prepareRemoveRoleRequest(SetRuleVO request, String uniqueId, String mtypecode, String token, String TOKEN_ISSUER) {
    ArrayList<UserRoleVO> userRoleVOS = new ArrayList<>();
    for (RequestRole requestRole : request.getRoles()) {
        UserRoleVO userRoleVO = new UserRoleVO();
        userRoleVO.setUserId(requestRole.getId());
        userRoleVO.setRoles(requestRole.getRoleTypes());
        userRoleVOS.add(userRoleVO);
    }
    ChatMessage chatMessage = new ChatMessage();
    chatMessage.setContent(App.getGson().toJson(userRoleVOS));
    chatMessage.setSubjectId(request.getThreadId());
    chatMessage.setToken(token);
    chatMessage.setType(ChatMessageType.Constants.REMOVE_ROLE_FROM_USER);
    chatMessage.setTokenIssuer(TOKEN_ISSUER);
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setTypeCode(mtypecode);
    return App.getGson().toJson(chatMessage);
}
Also used : RequestRole(com.fanap.podchat.requestobject.RequestRole) UserRoleVO(com.fanap.podchat.mainmodel.UserRoleVO) ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) ArrayList(java.util.ArrayList)

Example 47 with ChatMessage

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

the class SearchManager method prepareSearchRequest.

public static String prepareSearchRequest(NosqlListMessageCriteriaVO messageCriteriaVO, String uniqueId, String typecode, String token) {
    if (messageCriteriaVO.getCount() == 0)
        messageCriteriaVO.setCount(25);
    String content = App.getGson().toJson(messageCriteriaVO);
    ChatMessage chatMessage = new ChatMessage();
    chatMessage.setContent(content);
    chatMessage.setType(ChatMessageType.Constants.GET_HISTORY);
    chatMessage.setToken(token);
    chatMessage.setTokenIssuer("1");
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setSubjectId(messageCriteriaVO.getMessageThreadId());
    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();
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) JsonObject(com.google.gson.JsonObject)

Example 48 with ChatMessage

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

the class TagManager method createRemoveTagParticipantRequest.

public static String createRemoveTagParticipantRequest(RemoveTagParticipantRequest request, String uniqueId) {
    JsonArray participants = new JsonArray();
    for (Long p : request.getThreadIds()) {
        participants.add(p);
    }
    String content = "[{\"threadId\": 8688 }," + "{\"threadId\": 8730 }," + "{\"threadId\": 8729 }]";
    // String content = App.getGson().toJson(participants);
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.REMOVE_TAG_PARTICIPANT);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    message.setContent(content);
    message.setSubjectId(request.getTagId());
    message.setUniqueId(uniqueId);
    return App.getGson().toJson(message);
}
Also used : JsonArray(com.google.gson.JsonArray) ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage)

Example 49 with ChatMessage

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

the class TagManager method createDeleteTagRequest.

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

Example 50 with ChatMessage

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

the class TagManager method createEditTagRequest.

public static String createEditTagRequest(EditTagRequest request, String uniqueId) {
    JsonObject contentObject = new JsonObject();
    if (request.getName() != null)
        contentObject.addProperty("name", request.getName());
    String content = App.getGson().toJson(contentObject);
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.EDIT_TAG);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    message.setContent(content);
    message.setSubjectId(request.getTagId());
    message.setUniqueId(uniqueId);
    return App.getGson().toJson(message);
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) AsyncMessage(com.fanap.podchat.mainmodel.AsyncMessage) JsonObject(com.google.gson.JsonObject)

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