Search in sources :

Example 1 with Admin

use of com.fanap.podchat.model.Admin in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method handleRemoveRole.

private void handleRemoveRole(ChatMessage chatMessage) {
    ChatResponse<ResultSetAdmin> chatResponse = new ChatResponse<>();
    ResultSetAdmin resultSetAdmin = new ResultSetAdmin();
    ArrayList<Admin> admins = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<Admin>>() {
    }.getType());
    resultSetAdmin.setAdmins(admins);
    chatResponse.setResult(resultSetAdmin);
    chatResponse.setUniqueId(chatMessage.getUniqueId());
    chatResponse.setSubjectId(chatMessage.getSubjectId());
    String responseJson = gson.toJson(chatResponse);
    OutputSetRoleToUser output = new OutputSetRoleToUser();
    output.setResultSetAdmin(resultSetAdmin);
    long threadId = chatMessage.getSubjectId();
    if (cache) {
        dataSource.updateParticipantRoles(admins, threadId);
    }
    if (sentryResponseLog) {
        showLog("RECEIVE_REMOVE_ROLE", responseJson);
    } else {
        showLog("RECEIVE_REMOVE_ROLE");
    }
    listenerManager.callOnRemoveRoleFromUser(responseJson, chatResponse);
}
Also used : ResultSetAdmin(com.fanap.podchat.model.ResultSetAdmin) TypeToken(com.google.gson.reflect.TypeToken) ChatResponse(com.fanap.podchat.model.ChatResponse) OutputSetRoleToUser(com.fanap.podchat.model.OutputSetRoleToUser) Admin(com.fanap.podchat.model.Admin) RequestSetAdmin(com.fanap.podchat.requestobject.RequestSetAdmin) RequestGetAdmin(com.fanap.podchat.requestobject.RequestGetAdmin) ResultSetAdmin(com.fanap.podchat.model.ResultSetAdmin)

Example 2 with Admin

use of com.fanap.podchat.model.Admin in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method handleSetRole.

private void handleSetRole(ChatMessage chatMessage) {
    ChatResponse<ResultSetAdmin> chatResponse = new ChatResponse<>();
    ResultSetAdmin resultSetAdmin = new ResultSetAdmin();
    ArrayList<Admin> admins = gson.fromJson(chatMessage.getContent(), new TypeToken<ArrayList<Admin>>() {
    }.getType());
    resultSetAdmin.setAdmins(admins);
    chatResponse.setResult(resultSetAdmin);
    chatResponse.setUniqueId(chatMessage.getUniqueId());
    chatResponse.setSubjectId(chatMessage.getSubjectId());
    String responseJson = gson.toJson(chatResponse);
    OutputSetRoleToUser output = new OutputSetRoleToUser();
    output.setResultSetAdmin(resultSetAdmin);
    long threadId = chatMessage.getSubjectId();
    if (ThreadManager.hasSetAdminSubscriber(chatResponse)) {
        if (sentryResponseLog) {
            showLog("RECEIVE_SET_ROLE_FOR_SAFE_LEAVE", responseJson);
        } else {
            showLog("RECEIVE_SET_ROLE_FOR_SAFE_LEAVE");
        }
        return;
    }
    if (cache) {
        dataSource.updateParticipantRoles(admins, threadId);
    }
    showLog("RECEIVE_SET_ROLE", responseJson);
    listenerManager.callOnSetRoleToUser(responseJson, chatResponse);
}
Also used : ResultSetAdmin(com.fanap.podchat.model.ResultSetAdmin) TypeToken(com.google.gson.reflect.TypeToken) ChatResponse(com.fanap.podchat.model.ChatResponse) OutputSetRoleToUser(com.fanap.podchat.model.OutputSetRoleToUser) Admin(com.fanap.podchat.model.Admin) RequestSetAdmin(com.fanap.podchat.requestobject.RequestSetAdmin) RequestGetAdmin(com.fanap.podchat.requestobject.RequestGetAdmin) ResultSetAdmin(com.fanap.podchat.model.ResultSetAdmin)

Aggregations

Admin (com.fanap.podchat.model.Admin)2 ChatResponse (com.fanap.podchat.model.ChatResponse)2 OutputSetRoleToUser (com.fanap.podchat.model.OutputSetRoleToUser)2 ResultSetAdmin (com.fanap.podchat.model.ResultSetAdmin)2 RequestGetAdmin (com.fanap.podchat.requestobject.RequestGetAdmin)2 RequestSetAdmin (com.fanap.podchat.requestobject.RequestSetAdmin)2 TypeToken (com.google.gson.reflect.TypeToken)2