Search in sources :

Example 6 with ChatMessage

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

the class ThreadManager method createMutaulGroupRequest.

public static String createMutaulGroupRequest(GetMutualGroupRequest request, String uniqueId) {
    JsonObject content = (JsonObject) App.getGson().toJsonTree(request);
    content.remove("useCache");
    AsyncMessage message = new ChatMessage();
    message.setType(ChatMessageType.Constants.MUTUAL_GROUPS);
    message.setToken(CoreConfig.token);
    message.setTokenIssuer(CoreConfig.tokenIssuer);
    message.setContent(content.toString());
    message.setTypeCode(request.getTypeCode() != null ? request.getTypeCode() : CoreConfig.typeCode);
    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)

Example 7 with ChatMessage

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

the class ThreadManager method prepareRenameThreadRequest.

public static String prepareRenameThreadRequest(long threadId, String title, String uniqueId, String mTypeCode, String token) {
    ChatMessage chatMessage = new ChatMessage();
    chatMessage.setType(ChatMessageType.Constants.RENAME);
    chatMessage.setSubjectId(threadId);
    chatMessage.setContent(title);
    chatMessage.setToken(token);
    chatMessage.setTokenIssuer("1");
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setTypeCode(mTypeCode);
    String asyncContent = App.getGson().toJson(chatMessage);
    return asyncContent;
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage)

Example 8 with ChatMessage

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

the class ThreadManager method prepareSetRoleRequest.

public static String prepareSetRoleRequest(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.SET_ROLE_TO_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 9 with ChatMessage

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

the class ThreadManager method createCloseThreadRequest.

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

Example 10 with ChatMessage

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

the class ThreadManager method getChatMessage.

@NonNull
private static ChatMessage getChatMessage(String contentThreadChat, String uniqueId, String typeCode, String token) {
    ChatMessage chatMessage = new ChatMessage();
    chatMessage.setContent(contentThreadChat);
    chatMessage.setType(ChatMessageType.Constants.INVITATION);
    chatMessage.setToken(token);
    chatMessage.setUniqueId(uniqueId);
    chatMessage.setTokenIssuer("1");
    if (typeCode != null && !typeCode.isEmpty()) {
        chatMessage.setTypeCode(typeCode);
    } else {
        chatMessage.setTypeCode(typeCode);
    }
    return chatMessage;
}
Also used : ChatMessage(com.fanap.podchat.mainmodel.ChatMessage) NonNull(android.support.annotation.NonNull)

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