Skip to content

Commit

Permalink
Merge pull request #399 from Kommunicate-io/team_concept
Browse files Browse the repository at this point in the history
[CM-1486] - Changes for team concept
  • Loading branch information
amntoppoKM authored Jun 30, 2023
2 parents b0ac937 + 5641ad7 commit 9a2d091
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 2 deletions.
15 changes: 15 additions & 0 deletions kommunicate/src/main/java/com/applozic/mobicomkit/Applozic.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
import com.applozic.mobicommons.people.contact.Contact;
import com.applozic.mobicommons.task.AlTask;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.kommunicate.KmSettings;

Expand Down Expand Up @@ -202,6 +204,19 @@ public static void unSubscribeToSupportGroup(Context context, boolean useEncrypt
ApplozicMqttIntentService.enqueueWork(context, subscribeIntent);
}

public static void subscribeToTeamTopic(Context context, boolean useEncrypted, ArrayList<String> teams) {
Intent subscribeIntent = new Intent(context, ApplozicMqttIntentService.class);
subscribeIntent.putExtra(ApplozicMqttIntentService.CONNECT_TO_TEAM_TOPIC, true);
subscribeIntent.putExtra(ApplozicMqttIntentService.USE_ENCRYPTED_TOPIC, useEncrypted);
subscribeIntent.putStringArrayListExtra(ApplozicMqttIntentService.TEAM_TOPIC_LIST, teams);
ApplozicMqttIntentService.enqueueWork(context, subscribeIntent);
}
public static void unSubscribeToTeamTopic(Context context, boolean useEncrypted) {
Intent subscribeIntent = new Intent(context, ApplozicMqttIntentService.class);
subscribeIntent.putExtra(ApplozicMqttIntentService.DISCONNECT_FROM_TEAM_TOPIC, true);
subscribeIntent.putExtra(ApplozicMqttIntentService.USE_ENCRYPTED_TOPIC, useEncrypted);
ApplozicMqttIntentService.enqueueWork(context, subscribeIntent);
}
public static void subscribeToTyping(Context context, Channel channel, Contact contact) {
Intent intent = new Intent(context, ApplozicMqttIntentService.class);
if (channel != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;

import java.util.Date;
import java.util.List;

/**
* Created by sunil on 26/11/15.
Expand All @@ -46,6 +47,8 @@ public class ApplozicMqttService extends MobiComKitClientService implements Mqtt
private static final String OPEN_GROUP = "group-";
private static final String MQTT_ENCRYPTION_TOPIC = "encr-";
private static final String SUPPORT_GROUP_TOPIC = "support-channel";
private static final String TEAM_TOPIC = "teamid";

private static ApplozicMqttService applozicMqttService;
private AlMqttClient client;
private MemoryPersistence memoryPersistence;
Expand Down Expand Up @@ -308,6 +311,47 @@ public void run() {
thread.start();
}

public synchronized void subscribeToTeamTopic(boolean useEncrypted, List<String> teams) {
try {
String userKeyString = MobiComUserPreference.getInstance(context).getSuUserKeyString();
if (TextUtils.isEmpty(userKeyString)) {
return;
}
final MqttClient client = connect();
if (client != null && client.isConnected()) {
for(String team: teams) {
String topic = (useEncrypted ? MQTT_ENCRYPTION_TOPIC : "") + TEAM_TOPIC + "-" + team;
Utils.printLog(context, TAG, "Subscribing to team topic : " + topic);
client.subscribe(topic, 0);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

public synchronized void unSubscribeToTeamTopic(final boolean useEncrypted, final List<String> teams) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
if (client == null || !client.isConnected()) {
return;
}
for(String team: teams) {
String topic = (useEncrypted ? MQTT_ENCRYPTION_TOPIC : "") + TEAM_TOPIC + "-" + team;
Utils.printLog(context, TAG, "Unsubscribing to team topic : " + topic);
client.unsubscribe(topic);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
thread.setPriority(Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
}

public void disconnectPublish(String userKeyString, String deviceKeyString, String status, boolean useEncrypted) {
try {
connectPublish(userKeyString, deviceKeyString, status);
Expand Down Expand Up @@ -580,6 +624,20 @@ public void run() {
String[] parts = mqttMessageResponse.getMessage().toString().split(",");
syncCallService.updateAwayStatus(parts[0], Integer.valueOf(parts[1]));
}
if(NOTIFICATION_TYPE.GROUP_UPDATE.getValue().equals(mqttMessageResponse.getType())) {
try {
GcmMessageResponse messageResponse = (GcmMessageResponse) GsonUtils.getObjectFromJson(messageDataString, GcmMessageResponse.class);
Message message = messageResponse.getMessage();
if(messageResponse.getMessage() != null && message.getMetadata() != null
&& message.getMetadata().containsKey("KM_REMOVE_GROUP")
&& "true".equals(message.getMetadata().get("KM_REMOVE_GROUP"))) {
ChannelService.getInstance(context).deleteChannelFromDb(messageResponse.getMessage().getGroupId());
}
} catch (Exception e) {
e.printStackTrace();
}

}
}

} catch (Exception e) {
Expand Down Expand Up @@ -773,7 +831,10 @@ public static enum NOTIFICATION_TYPE {
USER_DELETE_NOTIFICATION("APPLOZIC_34"),
USER_MUTE_NOTIFICATION("APPLOZIC_37"),
MUTE_NOTIFICATIONS("APPLOZIC_38"),
GROUP_MUTE_NOTIFICATION("APPLOZIC_39");
GROUP_MUTE_NOTIFICATION("APPLOZIC_39"),
WAITING_QUEUE_UPDATE("APPLOZIC_40"),
AGENT_SCORECARD_UPDATE("APPLOZIC_41"),
GROUP_UPDATE("APPLOZIC_42");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.applozic.mobicommons.people.channel.Channel;
import com.applozic.mobicommons.people.contact.Contact;

import java.util.List;

/**
* Created by sunil on 30/12/15.
*/
Expand All @@ -36,6 +38,11 @@ public class ApplozicMqttIntentService extends AlJobIntentService {
public static final String STOP_TYPING = "STOP_TYPING";
public static final String CONNECT_TO_SUPPORT_GROUP_TOPIC = "connectToSupportGroupTopic";
public static final String DISCONNECT_FROM_SUPPORT_GROUP_TOPIC = "disconnectFromSupportGroupTopic";
public static final String CONNECT_TO_TEAM_TOPIC = "connectToTeamTopic";
public static final String DISCONNECT_FROM_TEAM_TOPIC = "disconnectFromTeamTopic";
public static final String TEAM_TOPIC_LIST = "teamTopicList";


public static final String USE_ENCRYPTED_TOPIC = "useEncryptedTopic";

/**
Expand Down Expand Up @@ -93,6 +100,18 @@ protected void onHandleWork(@NonNull Intent intent) {
return;
}

boolean subscribeToTeamTopic = intent.getBooleanExtra(CONNECT_TO_TEAM_TOPIC, false);
List<String> teamList = intent.getStringArrayListExtra(TEAM_TOPIC_LIST);
if (subscribeToTeamTopic) {
ApplozicMqttService.getInstance(getApplicationContext()).subscribeToTeamTopic(useEncryptedTopic, teamList);
return;
}
boolean unSubscribeToTeamTopic = intent.getBooleanExtra(DISCONNECT_FROM_TEAM_TOPIC, false);
if (unSubscribeToTeamTopic) {
ApplozicMqttService.getInstance(getApplicationContext()).unSubscribeToSupportGroup(useEncryptedTopic);
return;
}

String userKeyString = intent.getStringExtra(USER_KEY_STRING);
String deviceKeyString = intent.getStringExtra(DEVICE_KEY_STRING);
if (!TextUtils.isEmpty(userKeyString) && !TextUtils.isEmpty(deviceKeyString)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,15 @@ public String deleteChannel(Integer channelKey, boolean updateClientGroupId, boo
}
}

public void deleteChannelFromDb(Integer channelKey) {
if(channelKey != null && channelKey != 0) {
channelDatabaseService.deleteChannel(channelKey);
channelDatabaseService.deleteChannelUserMappers(channelKey);
BroadcastService.sendConversationDeleteBroadcast(context, BroadcastService.INTENT_ACTIONS.DELETE_CONVERSATION.toString(), null, channelKey, "success");

}
}

private void processChildGroupKeys(Set<Integer> childGroupKeys) {
for (Integer channelKey : childGroupKeys) {
Channel channel = channelDatabaseService.getChannelByChannelKey(channelKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ public static class KMRolesAndPermissions extends JsonMarker {
private boolean isTeamAssignmentAllowed = false;
private boolean hideAssignToDropdown;
private boolean restictOperatorToReadOnly;
private boolean restrictSpamBtn;


public boolean isRestrictSpamBtn() {
return restrictSpamBtn;
}

public void setRestrictSpamBtn(boolean restrictSpamBtn) {
this.restrictSpamBtn = restrictSpamBtn;
}


public boolean isHideAssignToDropdown() {
return hideAssignToDropdown;
Expand Down Expand Up @@ -345,4 +356,4 @@ public String getUrl() {
return url;
}
}
}
}

0 comments on commit 9a2d091

Please sign in to comment.