Search in sources :

Example 1 with SyncCallService

use of com.applozic.mobicomkit.api.conversation.SyncCallService in project Applozic-Android-SDK by AppLozic.

the class ApplozicMqttService method messageArrived.

@Override
public void messageArrived(String s, final MqttMessage mqttMessage) throws Exception {
    Utils.printLog(context, TAG, "Received MQTT message: " + new String(mqttMessage.getPayload()));
    try {
        if (!TextUtils.isEmpty(s) && s.startsWith(TYPINGTOPIC)) {
            String[] typingResponse = mqttMessage.toString().split(",");
            String applicationId = typingResponse[0];
            String userId = typingResponse[1];
            String isTypingStatus = typingResponse[2];
            BroadcastService.sendUpdateTypingBroadcast(context, BroadcastService.INTENT_ACTIONS.UPDATE_TYPING_STATUS.toString(), applicationId, userId, isTypingStatus);
        } else {
            final MqttMessageResponse mqttMessageResponse = (MqttMessageResponse) GsonUtils.getObjectFromJson(mqttMessage.toString(), MqttMessageResponse.class);
            if (mqttMessageResponse != null) {
                if (MobiComPushReceiver.processPushNotificationId(mqttMessageResponse.getId())) {
                    return;
                }
                final SyncCallService syncCallService = SyncCallService.getInstance(context);
                MobiComPushReceiver.addPushNotificationId(mqttMessageResponse.getId());
                Thread thread = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        Utils.printLog(context, TAG, "MQTT message type: " + mqttMessageResponse.getType());
                        if (NOTIFICATION_TYPE.MESSAGE_RECEIVED.getValue().equals(mqttMessageResponse.getType()) || "MESSAGE_RECEIVED".equals(mqttMessageResponse.getType())) {
                            GcmMessageResponse messageResponse = (GcmMessageResponse) GsonUtils.getObjectFromJson(mqttMessage.toString(), GcmMessageResponse.class);
                            if (messageResponse == null) {
                                return;
                            }
                            Message message = messageResponse.getMessage();
                            if (message.getGroupId() != null) {
                                Channel channel = ChannelService.getInstance(context).getChannelByChannelKey(message.getGroupId());
                                if (channel != null && Channel.GroupType.OPEN.getValue().equals(channel.getType())) {
                                    if (!MobiComUserPreference.getInstance(context).getDeviceKeyString().equals(message.getDeviceKeyString())) {
                                        syncCallService.syncMessages(message.getKeyString(), message);
                                    }
                                } else {
                                    syncCallService.syncMessages(null);
                                }
                            } else {
                                syncCallService.syncMessages(null);
                            }
                        }
                        if (NOTIFICATION_TYPE.MESSAGE_DELIVERED.getValue().equals(mqttMessageResponse.getType()) || "MT_MESSAGE_DELIVERED".equals(mqttMessageResponse.getType())) {
                            String[] splitKeyString = (mqttMessageResponse.getMessage()).toString().split(",");
                            String keyString = splitKeyString[0];
                            // String userId = splitKeyString[1];
                            syncCallService.updateDeliveryStatus(keyString);
                        }
                        if (NOTIFICATION_TYPE.MESSAGE_DELIVERED_AND_READ.getValue().equals(mqttMessageResponse.getType()) || "MT_MESSAGE_DELIVERED_READ".equals(mqttMessageResponse.getType())) {
                            String[] splitKeyString = (mqttMessageResponse.getMessage()).toString().split(",");
                            String keyString = splitKeyString[0];
                            syncCallService.updateReadStatus(keyString);
                        }
                        if (NOTIFICATION_TYPE.CONVERSATION_DELIVERED_AND_READ.getValue().equals(mqttMessageResponse.getType())) {
                            String contactId = mqttMessageResponse.getMessage().toString();
                            syncCallService.updateDeliveryStatusForContact(contactId, true);
                        }
                        if (NOTIFICATION_TYPE.CONVERSATION_READ.getValue().equals(mqttMessageResponse.getType())) {
                            syncCallService.updateConversationReadStatus(mqttMessageResponse.getMessage().toString(), false);
                        }
                        if (NOTIFICATION_TYPE.GROUP_CONVERSATION_READ.getValue().equals(mqttMessageResponse.getType())) {
                            InstantMessageResponse instantMessageResponse = (InstantMessageResponse) GsonUtils.getObjectFromJson(mqttMessage.toString(), InstantMessageResponse.class);
                            syncCallService.updateConversationReadStatus(instantMessageResponse.getMessage(), true);
                        }
                        if (NOTIFICATION_TYPE.USER_CONNECTED.getValue().equals(mqttMessageResponse.getType())) {
                            syncCallService.updateConnectedStatus(mqttMessageResponse.getMessage().toString(), new Date(), true);
                        }
                        if (NOTIFICATION_TYPE.USER_DISCONNECTED.getValue().equals(mqttMessageResponse.getType())) {
                            // disconnect comes with timestamp, ranjeet,1449866097000
                            String[] parts = mqttMessageResponse.getMessage().toString().split(",");
                            String userId = parts[0];
                            Date lastSeenAt = new Date();
                            if (parts.length >= 2 && !parts[1].equals("null")) {
                                lastSeenAt = new Date(Long.valueOf(parts[1]));
                            }
                            syncCallService.updateConnectedStatus(userId, lastSeenAt, false);
                        }
                        if (NOTIFICATION_TYPE.CONVERSATION_DELETED.getValue().equals(mqttMessageResponse.getType())) {
                            syncCallService.deleteConversationThread(mqttMessageResponse.getMessage().toString());
                            BroadcastService.sendConversationDeleteBroadcast(context, BroadcastService.INTENT_ACTIONS.DELETE_CONVERSATION.toString(), mqttMessageResponse.getMessage().toString(), 0, "success");
                        }
                        if (NOTIFICATION_TYPE.GROUP_CONVERSATION_DELETED.getValue().equals(mqttMessageResponse.getType())) {
                            InstantMessageResponse instantMessageResponse = (InstantMessageResponse) GsonUtils.getObjectFromJson(mqttMessage.toString(), InstantMessageResponse.class);
                            syncCallService.deleteChannelConversationThread(instantMessageResponse.getMessage());
                            BroadcastService.sendConversationDeleteBroadcast(context, BroadcastService.INTENT_ACTIONS.DELETE_CONVERSATION.toString(), null, Integer.valueOf(instantMessageResponse.getMessage()), "success");
                        }
                        if (NOTIFICATION_TYPE.MESSAGE_DELETED.getValue().equals(mqttMessageResponse.getType())) {
                            String messageKey = mqttMessageResponse.getMessage().toString().split(",")[0];
                            syncCallService.deleteMessage(messageKey);
                            BroadcastService.sendMessageDeleteBroadcast(context, BroadcastService.INTENT_ACTIONS.DELETE_MESSAGE.toString(), messageKey, null);
                        }
                        if (NOTIFICATION_TYPE.MESSAGE_SENT.getValue().equals(mqttMessageResponse.getType())) {
                            GcmMessageResponse messageResponse = (GcmMessageResponse) GsonUtils.getObjectFromJson(mqttMessage.toString(), GcmMessageResponse.class);
                            Message sentMessageSync = messageResponse.getMessage();
                            syncCallService.syncMessages(sentMessageSync.getKeyString());
                        }
                        if (NOTIFICATION_TYPE.USER_BLOCKED.getValue().equals(mqttMessageResponse.getType()) || NOTIFICATION_TYPE.USER_UN_BLOCKED.getValue().equals(mqttMessageResponse.getType())) {
                            syncCallService.syncBlockUsers();
                        }
                        if (NOTIFICATION_TYPE.USER_DETAIL_CHANGED.getValue().equals(mqttMessageResponse.getType()) || NOTIFICATION_TYPE.USER_DELETE_NOTIFICATION.getValue().equals(mqttMessageResponse.getType())) {
                            String userId = mqttMessageResponse.getMessage().toString();
                            syncCallService.syncUserDetail(userId);
                        }
                        if (NOTIFICATION_TYPE.MESSAGE_METADATA_UPDATE.getValue().equals(mqttMessageResponse.getType())) {
                            String keyString = null;
                            String deviceKey = null;
                            try {
                                GcmMessageResponse messageResponse = (GcmMessageResponse) GsonUtils.getObjectFromJson(mqttMessage.toString(), GcmMessageResponse.class);
                                keyString = messageResponse.getMessage().getKeyString();
                                deviceKey = messageResponse.getMessage().getDeviceKeyString();
                            } catch (Exception e) {
                                try {
                                    InstantMessageResponse response = (InstantMessageResponse) GsonUtils.getObjectFromJson(mqttMessage.toString(), InstantMessageResponse.class);
                                    keyString = response.getMessage();
                                    Message message = new MessageDatabaseService(context).getMessage(keyString);
                                    Utils.printLog(context, TAG, "Message from db : " + message);
                                    if (message != null) {
                                        deviceKey = message.getDeviceKeyString();
                                    }
                                } catch (Exception e1) {
                                    e1.printStackTrace();
                                }
                            }
                            if (deviceKey != null && deviceKey.equals(MobiComUserPreference.getInstance(context).getDeviceKeyString())) {
                                return;
                            }
                            syncCallService.syncMessageMetadataUpdate(keyString, false);
                        }
                        if (NOTIFICATION_TYPE.USER_MUTE_NOTIFICATION.getValue().equals(mqttMessageResponse.getType())) {
                            try {
                                InstantMessageResponse response = (InstantMessageResponse) GsonUtils.getObjectFromJson(mqttMessage.toString(), InstantMessageResponse.class);
                                if (response.getMessage() != null) {
                                    String muteFlag = String.valueOf(response.getMessage().charAt(response.getMessage().length() - 1));
                                    if ("1".equals(muteFlag)) {
                                        syncCallService.syncMutedUserList(false, null);
                                    } else if ("0".equals(muteFlag)) {
                                        String userId = response.getMessage().substring(0, response.getMessage().length() - 2);
                                        syncCallService.syncMutedUserList(false, userId);
                                    }
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                });
                thread.start();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : MqttMessage(org.eclipse.paho.client.mqttv3.MqttMessage) Message(com.applozic.mobicomkit.api.conversation.Message) MqttMessageResponse(com.applozic.mobicomkit.feed.MqttMessageResponse) GcmMessageResponse(com.applozic.mobicomkit.feed.GcmMessageResponse) Channel(com.applozic.mobicommons.people.channel.Channel) InstantMessageResponse(com.applozic.mobicomkit.feed.InstantMessageResponse) Date(java.util.Date) MqttException(org.eclipse.paho.client.mqttv3.MqttException) SyncCallService(com.applozic.mobicomkit.api.conversation.SyncCallService) MessageDatabaseService(com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)

Example 2 with SyncCallService

use of com.applozic.mobicomkit.api.conversation.SyncCallService in project Applozic-Android-SDK by AppLozic.

the class MobiComPushReceiver method processMessage.

public static void processMessage(Context context, Bundle bundle, Map<String, String> data) {
    try {
        String payloadForDelivered = null, userConnected = null, userDisconnected = null, payloadDeliveredAndRead = null, messageKey = null, messageSent = null, deleteConversationForContact = null, deleteConversationForChannel = null, deleteMessage = null, conversationReadResponse = null, userBlockedResponse = null, userUnBlockedResponse = null, conversationReadForContact = null, conversationReadForChannel = null, conversationReadForSingleMessage = null, userDetailChanged = null, userDeleteNotification = null, messageMetadataUpdate = null, mutedUserListResponse = null;
        SyncCallService syncCallService = SyncCallService.getInstance(context);
        if (bundle != null) {
            deleteConversationForContact = bundle.getString(notificationKeyList.get(5));
            deleteMessage = bundle.getString(notificationKeyList.get(4));
            payloadForDelivered = bundle.getString(notificationKeyList.get(3));
            userConnected = bundle.getString(notificationKeyList.get(10));
            userDisconnected = bundle.getString(notificationKeyList.get(11));
            payloadDeliveredAndRead = bundle.getString(notificationKeyList.get(7));
            messageSent = bundle.getString(notificationKeyList.get(1));
            messageKey = bundle.getString(notificationKeyList.get(0));
            conversationReadResponse = bundle.getString(notificationKeyList.get(9));
            userBlockedResponse = bundle.getString(notificationKeyList.get(15));
            userUnBlockedResponse = bundle.getString(notificationKeyList.get(16));
            conversationReadForContact = bundle.getString(notificationKeyList.get(8));
            conversationReadForChannel = bundle.getString(notificationKeyList.get(20));
            deleteConversationForChannel = bundle.getString(notificationKeyList.get(22));
            userDetailChanged = bundle.getString(notificationKeyList.get(29));
            userDeleteNotification = bundle.getString(notificationKeyList.get(31));
            messageMetadataUpdate = bundle.getString(notificationKeyList.get(30));
            mutedUserListResponse = bundle.getString(notificationKeyList.get(32));
        } else if (data != null) {
            deleteConversationForContact = data.get(notificationKeyList.get(5));
            deleteMessage = data.get(notificationKeyList.get(4));
            payloadForDelivered = data.get(notificationKeyList.get(3));
            userConnected = data.get(notificationKeyList.get(10));
            userDisconnected = data.get(notificationKeyList.get(11));
            payloadDeliveredAndRead = data.get(notificationKeyList.get(7));
            messageSent = data.get(notificationKeyList.get(1));
            messageKey = data.get(notificationKeyList.get(0));
            conversationReadResponse = data.get(notificationKeyList.get(9));
            userBlockedResponse = data.get(notificationKeyList.get(15));
            userUnBlockedResponse = data.get(notificationKeyList.get(16));
            conversationReadForContact = data.get(notificationKeyList.get(8));
            conversationReadForChannel = data.get(notificationKeyList.get(20));
            deleteConversationForChannel = data.get(notificationKeyList.get(22));
            userDetailChanged = data.get(notificationKeyList.get(29));
            userDeleteNotification = data.get(notificationKeyList.get(31));
            messageMetadataUpdate = data.get(notificationKeyList.get(30));
            mutedUserListResponse = data.get(notificationKeyList.get(32));
        }
        if (!TextUtils.isEmpty(payloadForDelivered)) {
            MqttMessageResponse messageResponseForDelivered = (MqttMessageResponse) GsonUtils.getObjectFromJson(payloadForDelivered, MqttMessageResponse.class);
            if (processPushNotificationId(messageResponseForDelivered.getId())) {
                return;
            }
            addPushNotificationId(messageResponseForDelivered.getId());
            String[] splitKeyString = (messageResponseForDelivered.getMessage()).toString().split(",");
            String keyString = splitKeyString[0];
            // String userId = splitKeyString[1];
            syncCallService.updateDeliveryStatus(keyString);
        }
        if (!TextUtils.isEmpty(payloadDeliveredAndRead)) {
            MqttMessageResponse messageResponseForDeliveredAndRead = (MqttMessageResponse) GsonUtils.getObjectFromJson(payloadDeliveredAndRead, MqttMessageResponse.class);
            if (processPushNotificationId(messageResponseForDeliveredAndRead.getId())) {
                return;
            }
            addPushNotificationId(messageResponseForDeliveredAndRead.getId());
            String[] splitKeyString = (messageResponseForDeliveredAndRead.getMessage()).toString().split(",");
            String keyString = splitKeyString[0];
            // String userId = splitKeyString[1];
            syncCallService.updateReadStatus(keyString);
        }
        if (!TextUtils.isEmpty(deleteConversationForContact)) {
            MqttMessageResponse deleteConversationResponse = (MqttMessageResponse) GsonUtils.getObjectFromJson(deleteConversationForContact, MqttMessageResponse.class);
            if (processPushNotificationId(deleteConversationResponse.getId())) {
                return;
            }
            addPushNotificationId(deleteConversationResponse.getId());
            MobiComConversationService conversationService = new MobiComConversationService(context);
            conversationService.deleteConversationFromDevice(deleteConversationResponse.getMessage().toString());
            BroadcastService.sendConversationDeleteBroadcast(context, BroadcastService.INTENT_ACTIONS.DELETE_CONVERSATION.toString(), deleteConversationResponse.getMessage().toString(), 0, "success");
        }
        if (!TextUtils.isEmpty(deleteConversationForChannel)) {
            InstantMessageResponse instantMessageResponse = (InstantMessageResponse) GsonUtils.getObjectFromJson(deleteConversationForChannel, InstantMessageResponse.class);
            if (processPushNotificationId(instantMessageResponse.getId())) {
                return;
            }
            addPushNotificationId(instantMessageResponse.getId());
            syncCallService.deleteChannelConversationThread(instantMessageResponse.getMessage());
            BroadcastService.sendConversationDeleteBroadcast(context, BroadcastService.INTENT_ACTIONS.DELETE_CONVERSATION.toString(), null, Integer.valueOf(instantMessageResponse.getMessage()), "success");
        }
        if (!TextUtils.isEmpty(userConnected)) {
            MqttMessageResponse userConnectedResponse = (MqttMessageResponse) GsonUtils.getObjectFromJson(userConnected, MqttMessageResponse.class);
            if (processPushNotificationId(userConnectedResponse.getId())) {
                return;
            }
            addPushNotificationId(userConnectedResponse.getId());
            syncCallService.updateConnectedStatus(userConnectedResponse.getMessage().toString(), new Date(), true);
        }
        if (!TextUtils.isEmpty(userDisconnected)) {
            MqttMessageResponse userDisconnectedResponse = (MqttMessageResponse) GsonUtils.getObjectFromJson(userDisconnected, MqttMessageResponse.class);
            if (processPushNotificationId(userDisconnectedResponse.getId())) {
                return;
            }
            addPushNotificationId(userDisconnectedResponse.getId());
            String[] parts = userDisconnectedResponse.getMessage().toString().split(",");
            String userId = parts[0];
            Date lastSeenAt = new Date();
            if (parts.length >= 2 && !parts[1].equals("null")) {
                lastSeenAt = new Date(Long.valueOf(parts[1]));
            }
            syncCallService.updateConnectedStatus(userId, lastSeenAt, false);
        }
        if (!TextUtils.isEmpty(deleteMessage)) {
            MqttMessageResponse deleteSingleMessageResponse = (MqttMessageResponse) GsonUtils.getObjectFromJson(deleteMessage, MqttMessageResponse.class);
            if (processPushNotificationId(deleteSingleMessageResponse.getId())) {
                return;
            }
            addPushNotificationId(deleteSingleMessageResponse.getId());
            String deleteMessageKeyAndUserId = deleteSingleMessageResponse.getMessage().toString();
            // String contactNumbers = deleteMessageKeyAndUserId.split(",").length > 1 ? deleteMessageKeyAndUserId.split(",")[1] : null;
            syncCallService.deleteMessage(deleteMessageKeyAndUserId.split(",")[0]);
        }
        if (!TextUtils.isEmpty(messageSent)) {
            GcmMessageResponse syncSentMessageResponse = (GcmMessageResponse) GsonUtils.getObjectFromJson(messageSent, GcmMessageResponse.class);
            if (processPushNotificationId(syncSentMessageResponse.getId())) {
                return;
            }
            addPushNotificationId(syncSentMessageResponse.getId());
            syncCallService.syncMessages(null);
        }
        GcmMessageResponse syncMessageResponse = null;
        if (!TextUtils.isEmpty(messageKey)) {
            syncMessageResponse = (GcmMessageResponse) GsonUtils.getObjectFromJson(messageKey, GcmMessageResponse.class);
            if (processPushNotificationId(syncMessageResponse.getId())) {
                return;
            }
            addPushNotificationId(syncMessageResponse.getId());
            Message messageObj = syncMessageResponse.getMessage();
            if (!TextUtils.isEmpty(messageObj.getKeyString())) {
                syncCallService.syncMessages(messageObj.getKeyString());
            } else {
                syncCallService.syncMessages(null);
            }
        }
        if (!TextUtils.isEmpty(conversationReadResponse)) {
            MqttMessageResponse updateDeliveryStatusForContactResponse = (MqttMessageResponse) GsonUtils.getObjectFromJson(conversationReadResponse, MqttMessageResponse.class);
            if (notificationKeyList.get(9).equals(updateDeliveryStatusForContactResponse.getType())) {
                if (processPushNotificationId(updateDeliveryStatusForContactResponse.getId())) {
                    return;
                }
                addPushNotificationId(updateDeliveryStatusForContactResponse.getId());
                syncCallService.updateDeliveryStatusForContact(updateDeliveryStatusForContactResponse.getMessage().toString(), true);
            }
        }
        if (!TextUtils.isEmpty(userBlockedResponse)) {
            MqttMessageResponse syncUserBlock = (MqttMessageResponse) GsonUtils.getObjectFromJson(userBlockedResponse, MqttMessageResponse.class);
            if (processPushNotificationId(syncUserBlock.getId())) {
                return;
            }
            addPushNotificationId(syncUserBlock.getId());
            SyncCallService.getInstance(context).syncBlockUsers();
        }
        if (!TextUtils.isEmpty(userUnBlockedResponse)) {
            MqttMessageResponse syncUserUnBlock = (MqttMessageResponse) GsonUtils.getObjectFromJson(userUnBlockedResponse, MqttMessageResponse.class);
            if (processPushNotificationId(syncUserUnBlock.getId())) {
                return;
            }
            addPushNotificationId(syncUserUnBlock.getId());
            SyncCallService.getInstance(context).syncBlockUsers();
        }
        if (!TextUtils.isEmpty(conversationReadForContact)) {
            MqttMessageResponse conversationReadForContactResponse = (MqttMessageResponse) GsonUtils.getObjectFromJson(conversationReadForContact, MqttMessageResponse.class);
            if (processPushNotificationId(conversationReadForContactResponse.getId())) {
                return;
            }
            addPushNotificationId(conversationReadForContactResponse.getId());
            syncCallService.updateConversationReadStatus(conversationReadForContactResponse.getMessage().toString(), false);
        }
        if (!TextUtils.isEmpty(conversationReadForChannel)) {
            InstantMessageResponse conversationReadForChannelResponse = (InstantMessageResponse) GsonUtils.getObjectFromJson(conversationReadForChannel, InstantMessageResponse.class);
            if (processPushNotificationId(conversationReadForChannelResponse.getId())) {
                return;
            }
            addPushNotificationId(conversationReadForChannelResponse.getId());
            syncCallService.updateConversationReadStatus(conversationReadForChannelResponse.getMessage(), true);
        }
        if (!TextUtils.isEmpty(userDetailChanged) || !TextUtils.isEmpty(userDeleteNotification)) {
            MqttMessageResponse response = null;
            if (!TextUtils.isEmpty(userDetailChanged)) {
                response = (MqttMessageResponse) GsonUtils.getObjectFromJson(userDetailChanged, MqttMessageResponse.class);
            } else if (!TextUtils.isEmpty(userDeleteNotification)) {
                response = (MqttMessageResponse) GsonUtils.getObjectFromJson(userDeleteNotification, MqttMessageResponse.class);
            }
            if (processPushNotificationId(response.getId())) {
                return;
            }
            addPushNotificationId(response.getId());
            String userId = response.getMessage().toString();
            syncCallService.syncUserDetail(userId);
        }
        if (!TextUtils.isEmpty(messageMetadataUpdate)) {
            String keyString = null;
            String id = null;
            String deviceKey = null;
            try {
                GcmMessageResponse messageResponse = (GcmMessageResponse) GsonUtils.getObjectFromJson(messageMetadataUpdate, GcmMessageResponse.class);
                keyString = messageResponse.getMessage().getKeyString();
                id = messageResponse.getId();
                deviceKey = messageResponse.getMessage().getDeviceKeyString();
            } catch (Exception e) {
                try {
                    InstantMessageResponse response = (InstantMessageResponse) GsonUtils.getObjectFromJson(messageMetadataUpdate, InstantMessageResponse.class);
                    keyString = response.getMessage();
                    id = response.getId();
                    Message message = new MessageDatabaseService(context).getMessage(keyString);
                    if (message != null) {
                        deviceKey = message.getDeviceKeyString();
                    }
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            if (processPushNotificationId(id)) {
                return;
            }
            addPushNotificationId(id);
            if (deviceKey != null && deviceKey.equals(MobiComUserPreference.getInstance(context).getDeviceKeyString())) {
                return;
            }
            syncCallService.syncMessageMetadataUpdate(keyString, true);
        }
        if (!TextUtils.isEmpty(mutedUserListResponse)) {
            try {
                InstantMessageResponse response = (InstantMessageResponse) GsonUtils.getObjectFromJson(mutedUserListResponse, InstantMessageResponse.class);
                if (processPushNotificationId(response.getId())) {
                    return;
                }
                addPushNotificationId(response.getId());
                if (response.getMessage() != null) {
                    String muteFlag = String.valueOf(response.getMessage().charAt(response.getMessage().length() - 1));
                    if ("1".equals(muteFlag)) {
                        syncCallService.syncMutedUserList(true, null);
                    } else if ("0".equals(muteFlag)) {
                        String userId = response.getMessage().substring(0, response.getMessage().length() - 2);
                        syncCallService.syncMutedUserList(true, userId);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) MqttMessageResponse(com.applozic.mobicomkit.feed.MqttMessageResponse) GcmMessageResponse(com.applozic.mobicomkit.feed.GcmMessageResponse) InstantMessageResponse(com.applozic.mobicomkit.feed.InstantMessageResponse) SyncCallService(com.applozic.mobicomkit.api.conversation.SyncCallService) MobiComConversationService(com.applozic.mobicomkit.api.conversation.MobiComConversationService) Date(java.util.Date) MessageDatabaseService(com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)

Aggregations

Message (com.applozic.mobicomkit.api.conversation.Message)2 SyncCallService (com.applozic.mobicomkit.api.conversation.SyncCallService)2 MessageDatabaseService (com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)2 GcmMessageResponse (com.applozic.mobicomkit.feed.GcmMessageResponse)2 InstantMessageResponse (com.applozic.mobicomkit.feed.InstantMessageResponse)2 MqttMessageResponse (com.applozic.mobicomkit.feed.MqttMessageResponse)2 Date (java.util.Date)2 MobiComConversationService (com.applozic.mobicomkit.api.conversation.MobiComConversationService)1 Channel (com.applozic.mobicommons.people.channel.Channel)1 MqttException (org.eclipse.paho.client.mqttv3.MqttException)1 MqttMessage (org.eclipse.paho.client.mqttv3.MqttMessage)1