mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-15 08:45:04 +01:00
Add support for inviting groups to a conversation
This commit is contained in:
parent
c92c3db803
commit
569c536d2b
app/src/main/java/com/nextcloud/talk
@ -946,7 +946,8 @@ public class ContactsController extends BaseController implements SearchView.OnQ
|
|||||||
((UserItem) adapter.getItem(position)).flipItemSelection();
|
((UserItem) adapter.getItem(position)).flipItemSelection();
|
||||||
adapter.toggleSelection(position);
|
adapter.toggleSelection(position);
|
||||||
|
|
||||||
if (currentUser.hasSpreedCapabilityWithName("last-room-activity") &&
|
if (currentUser.hasSpreedCapabilityWithName("last-room-activity")
|
||||||
|
&& !currentUser.hasSpreedCapabilityWithName("invite-groups-and-mails") &&
|
||||||
"groups".equals(((UserItem) adapter.getItem(position)).getModel().getSource()) &&
|
"groups".equals(((UserItem) adapter.getItem(position)).getModel().getSource()) &&
|
||||||
adapter.getSelectedItemCount() > 1) {
|
adapter.getSelectedItemCount() > 1) {
|
||||||
List<Integer> selectedPositions = adapter.getSelectedPositions();
|
List<Integer> selectedPositions = adapter.getSelectedPositions();
|
||||||
|
@ -119,7 +119,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
|
|
||||||
private Conversation.RoomType conversationType;
|
private Conversation.RoomType conversationType;
|
||||||
private ArrayList<String> invitedUsers = new ArrayList<>();
|
private ArrayList<String> invitedUsers = new ArrayList<>();
|
||||||
private ArrayList<String> invitedGroup = new ArrayList<>();
|
private ArrayList<String> invitedGroups = new ArrayList<>();
|
||||||
|
|
||||||
private List<String> spreedCapabilities;
|
private List<String> spreedCapabilities;
|
||||||
private String credentials;
|
private String credentials;
|
||||||
@ -139,7 +139,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.containsKey(BundleKeys.KEY_INVITED_GROUP)) {
|
if (args.containsKey(BundleKeys.KEY_INVITED_GROUP)) {
|
||||||
this.invitedGroup = args.getStringArrayList(BundleKeys.KEY_INVITED_GROUP);
|
this.invitedGroups = args.getStringArrayList(BundleKeys.KEY_INVITED_GROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.containsKey(BundleKeys.KEY_CONVERSATION_TYPE)) {
|
if (args.containsKey(BundleKeys.KEY_CONVERSATION_TYPE)) {
|
||||||
@ -275,8 +275,8 @@ public class OperationsMenuController extends BaseController {
|
|||||||
boolean isGroupCallWorkaround = false;
|
boolean isGroupCallWorkaround = false;
|
||||||
String invite = null;
|
String invite = null;
|
||||||
|
|
||||||
if (invitedGroup.size() > 0) {
|
if (invitedGroups.size() > 0) {
|
||||||
invite = invitedGroup.get(0);
|
invite = invitedGroups.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conversationType.equals(Conversation.RoomType.ROOM_PUBLIC_CALL) ||
|
if (conversationType.equals(Conversation.RoomType.ROOM_PUBLIC_CALL) ||
|
||||||
@ -513,8 +513,50 @@ public class OperationsMenuController extends BaseController {
|
|||||||
private void inviteUsersToAConversation() {
|
private void inviteUsersToAConversation() {
|
||||||
RetrofitBucket retrofitBucket;
|
RetrofitBucket retrofitBucket;
|
||||||
final ArrayList<String> localInvitedUsers = invitedUsers;
|
final ArrayList<String> localInvitedUsers = invitedUsers;
|
||||||
if (localInvitedUsers.size() > 0) {
|
final ArrayList<String> localInvitedGroups = invitedGroups;
|
||||||
for (int i = 0; i < invitedUsers.size(); i++) {
|
localInvitedGroups.remove(0);
|
||||||
|
if (localInvitedUsers.size() > 0 || (localInvitedGroups.size() > 0 && currentUser.hasSpreedCapabilityWithName("invite-groups-and-mails"))) {
|
||||||
|
if ((localInvitedGroups.size() > 0 && currentUser.hasSpreedCapabilityWithName("invite-groups-and-mails"))) {
|
||||||
|
for (int i = 0; i < localInvitedGroups.size(); i++) {
|
||||||
|
final String groupId = localInvitedGroups.get(i);
|
||||||
|
retrofitBucket = ApiUtils.getRetrofitBucketForAddGroupParticipant(currentUser.getBaseUrl(), conversation.getToken(),
|
||||||
|
groupId);
|
||||||
|
|
||||||
|
ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
|
||||||
|
.subscribeOn(Schedulers.newThread())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.retry(1)
|
||||||
|
.subscribe(new Observer<AddParticipantOverall>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(AddParticipantOverall addParticipantOverall) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
synchronized (localInvitedGroups) {
|
||||||
|
localInvitedGroups.remove(localInvitedGroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localInvitedGroups.size() == 0 && localInvitedUsers.size() == 0) {
|
||||||
|
initiateConversation(true, null);
|
||||||
|
}
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < localInvitedGroups.size(); i++) {
|
||||||
final String userId = invitedUsers.get(i);
|
final String userId = invitedUsers.get(i);
|
||||||
retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipant(currentUser.getBaseUrl(), conversation.getToken(),
|
retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipant(currentUser.getBaseUrl(), conversation.getToken(),
|
||||||
userId);
|
userId);
|
||||||
@ -551,6 +593,7 @@ public class OperationsMenuController extends BaseController {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!currentUser.hasSpreedCapabilityWithName("chat-v2")) {
|
if (!currentUser.hasSpreedCapabilityWithName("chat-v2")) {
|
||||||
showResultImage(true, false);
|
showResultImage(true, false);
|
||||||
|
@ -132,6 +132,18 @@ public class ApiUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RetrofitBucket getRetrofitBucketForAddGroupParticipant(String baseUrl, String token, String group) {
|
||||||
|
RetrofitBucket retrofitBucket = getRetrofitBucketForAddParticipant(baseUrl, token, group);
|
||||||
|
retrofitBucket.getQueryMap().put("source", "groups");
|
||||||
|
return retrofitBucket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RetrofitBucket getRetrofitBucketForAddMailParticipant(String baseUrl, String token, String mail) {
|
||||||
|
RetrofitBucket retrofitBucket = getRetrofitBucketForAddParticipant(baseUrl, token, mail);
|
||||||
|
retrofitBucket.getQueryMap().put("source", "emails");
|
||||||
|
return retrofitBucket;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getUrlForRemoveSelfFromRoom(String baseUrl, String token) {
|
public static String getUrlForRemoveSelfFromRoom(String baseUrl, String token) {
|
||||||
return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token + "/participants/self";
|
return baseUrl + ocsApiVersion + spreedApiVersion + "/room/" + token + "/participants/self";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user