Merge pull request #1245 from nextcloud/feature/noid/allow-to-add-emails-as-participant

✉️ &  Allow to add emails and circles as particpants
This commit is contained in:
Andy Scherzinger 2021-05-14 17:41:49 +02:00 committed by GitHub
commit 94416b3ad0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 220 additions and 85 deletions

View File

@ -259,7 +259,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token) val credentials = ApiUtils.getCredentials(currentUser.username, currentUser.token)
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom( val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion, currentUser.baseUrl, roomType, apiVersion, currentUser.baseUrl, roomType,
userId, null null, userId, null
) )
ncApi.createRoom( ncApi.createRoom(
credentials, credentials,

View File

@ -151,7 +151,10 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
holder.contactDisplayName.setText(NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest)); holder.contactDisplayName.setText(NextcloudTalkApplication.Companion.getSharedApplication().getString(R.string.nc_guest));
} }
if (participant.getActorType() == Participant.ActorType.GROUPS || "groups".equals(participant.getSource())) { if (participant.getActorType() == Participant.ActorType.GROUPS ||
"groups".equals(participant.getSource()) ||
participant.getActorType() == Participant.ActorType.CIRCLES ||
"circles".equals(participant.getSource())) {
holder.simpleDraweeView.setImageResource(R.drawable.ic_circular_group); holder.simpleDraweeView.setImageResource(R.drawable.ic_circular_group);
} else if (participant.getActorType() == Participant.ActorType.EMAILS) { } else if (participant.getActorType() == Participant.ActorType.EMAILS) {
holder.simpleDraweeView.setImageResource(R.drawable.ic_circular_mail); holder.simpleDraweeView.setImageResource(R.drawable.ic_circular_mail);

View File

@ -1625,6 +1625,7 @@ class ChatController(args: Bundle) :
apiVersion, apiVersion,
conversationUser?.baseUrl, conversationUser?.baseUrl,
"1", "1",
null,
message?.user?.id?.substring(6), message?.user?.id?.substring(6),
null null
) )
@ -1818,8 +1819,12 @@ class ChatController(args: Bundle) :
} }
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom( val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion, conversationUser?.baseUrl, "1", apiVersion,
userMentionClickEvent.userId, null conversationUser?.baseUrl,
"1",
null,
userMentionClickEvent.userId,
null
) )
ncApi?.createRoom( ncApi?.createRoom(

View File

@ -75,6 +75,7 @@ import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode; import org.greenrobot.eventbus.ThreadMode;
import org.parceler.Parcels; import org.parceler.Parcels;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -129,7 +130,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
@BindView(R.id.loading_content) @BindView(R.id.loading_content)
LinearLayout loadingContent; LinearLayout loadingContent;
@BindView(R.id.recycler_view) @BindView(R.id.recycler_view)
RecyclerView recyclerView; RecyclerView recyclerView;
@ -191,6 +191,8 @@ public class ContactsController extends BaseController implements SearchView.OnQ
private Set<String> selectedUserIds; private Set<String> selectedUserIds;
private Set<String> selectedGroupIds; private Set<String> selectedGroupIds;
private Set<String> selectedCircleIds;
private Set<String> selectedEmails;
private List<String> existingParticipants; private List<String> existingParticipants;
private boolean isAddingParticipantsView; private boolean isAddingParticipantsView;
private String conversationToken; private String conversationToken;
@ -217,8 +219,10 @@ public class ContactsController extends BaseController implements SearchView.OnQ
} }
} }
selectedGroupIds = new HashSet<>();
selectedUserIds = new HashSet<>(); selectedUserIds = new HashSet<>();
selectedGroupIds = new HashSet<>();
selectedEmails = new HashSet<>();
selectedCircleIds = new HashSet<>();
} }
@Override @Override
@ -279,13 +283,18 @@ public class ContactsController extends BaseController implements SearchView.OnQ
private void selectionDone() { private void selectionDone() {
if (!isAddingParticipantsView) { if (!isAddingParticipantsView) {
if (!isPublicCall && (selectedGroupIds.size() + selectedUserIds.size() == 1)) { if (!isPublicCall && (selectedCircleIds.size() + selectedGroupIds.size() + selectedUserIds.size() == 1)) {
String userId; String userId;
String sourceType = null;
String roomType = "1"; String roomType = "1";
if (selectedGroupIds.size() == 1) { if (selectedGroupIds.size() == 1) {
roomType = "2"; roomType = "2";
userId = selectedGroupIds.iterator().next(); userId = selectedGroupIds.iterator().next();
} else if (selectedCircleIds.size() == 1) {
roomType = "2";
sourceType = "circles";
userId = selectedCircleIds.iterator().next();
} else { } else {
userId = selectedUserIds.iterator().next(); userId = selectedUserIds.iterator().next();
} }
@ -294,6 +303,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion, RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion,
currentUser.getBaseUrl(), currentUser.getBaseUrl(),
roomType, roomType,
sourceType,
userId, userId,
null); null);
ncApi.createRoom(credentials, ncApi.createRoom(credentials,
@ -368,23 +378,31 @@ public class ContactsController extends BaseController implements SearchView.OnQ
ArrayList<String> userIdsArray = new ArrayList<>(selectedUserIds); ArrayList<String> userIdsArray = new ArrayList<>(selectedUserIds);
ArrayList<String> groupIdsArray = new ArrayList<>(selectedGroupIds); ArrayList<String> groupIdsArray = new ArrayList<>(selectedGroupIds);
ArrayList<String> emailsArray = new ArrayList<>(selectedEmails);
ArrayList<String> circleIdsArray = new ArrayList<>(selectedCircleIds);
bundle.putParcelable(BundleKeys.INSTANCE.getKEY_CONVERSATION_TYPE(), Parcels.wrap(roomType)); bundle.putParcelable(BundleKeys.INSTANCE.getKEY_CONVERSATION_TYPE(), Parcels.wrap(roomType));
bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_PARTICIPANTS(), userIdsArray); bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_PARTICIPANTS(), userIdsArray);
bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_GROUP(), groupIdsArray); bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_GROUP(), groupIdsArray);
bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_EMAIL(), emailsArray);
bundle.putStringArrayList(BundleKeys.INSTANCE.getKEY_INVITED_CIRCLE(), circleIdsArray);
bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 11); bundle.putInt(BundleKeys.INSTANCE.getKEY_OPERATION_CODE(), 11);
prepareAndShowBottomSheetWithBundle(bundle, true); prepareAndShowBottomSheetWithBundle(bundle, true);
} }
} else { } else {
String[] userIdsArray = selectedUserIds.toArray(new String[selectedUserIds.size()]); String[] userIdsArray = selectedUserIds.toArray(new String[selectedUserIds.size()]);
String[] groupIdsArray = selectedGroupIds.toArray(new String[selectedGroupIds.size()]); String[] groupIdsArray = selectedGroupIds.toArray(new String[selectedGroupIds.size()]);
String[] emailsArray = selectedEmails.toArray(new String[selectedEmails.size()]);
String[] circleIdsArray = selectedCircleIds.toArray(new String[selectedCircleIds.size()]);
Data.Builder data = new Data.Builder(); Data.Builder data = new Data.Builder();
data.putLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), currentUser.getId()); data.putLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), currentUser.getId());
data.putString(BundleKeys.INSTANCE.getKEY_TOKEN(), conversationToken); data.putString(BundleKeys.INSTANCE.getKEY_TOKEN(), conversationToken);
data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_USERS(), userIdsArray); data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_USERS(), userIdsArray);
data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_GROUPS(), groupIdsArray); data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_GROUPS(), groupIdsArray);
data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_EMAILS(), emailsArray);
data.putStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_CIRCLES(), circleIdsArray);
OneTimeWorkRequest addParticipantsToConversationWorker = OneTimeWorkRequest addParticipantsToConversationWorker =
new OneTimeWorkRequest.Builder(AddParticipantsToConversation.class).setInputData(data.build()).build(); new OneTimeWorkRequest.Builder(AddParticipantsToConversation.class).setInputData(data.build()).build();
@ -467,15 +485,26 @@ public class ContactsController extends BaseController implements SearchView.OnQ
modifiedQueryMap.put("itemId", conversationToken); modifiedQueryMap.put("itemId", conversationToken);
} }
List<String> shareTypesList = null; List<String> shareTypesList;
shareTypesList = new ArrayList<>(); shareTypesList = new ArrayList<>();
// users // users
shareTypesList.add("0"); shareTypesList.add("0");
if (!isAddingParticipantsView) {
// groups // groups
shareTypesList.add("1"); shareTypesList.add("1");
} else if (currentUser.hasSpreedFeatureCapability("invite-groups-and-mails")) {
// groups
shareTypesList.add("1");
// emails
shareTypesList.add("4");
}
if (currentUser.hasSpreedFeatureCapability("circles-support")) {
// circles
shareTypesList.add("7");
}
modifiedQueryMap.put("shareTypes[]", shareTypesList); modifiedQueryMap.put("shareTypes[]", shareTypesList);
ncApi.getContactsWithSearchParam( ncApi.getContactsWithSearchParam(
credentials, credentials,
@ -498,43 +527,49 @@ public class ContactsController extends BaseController implements SearchView.OnQ
EnumActorTypeConverter actorTypeConverter = new EnumActorTypeConverter(); EnumActorTypeConverter actorTypeConverter = new EnumActorTypeConverter();
try { try {
AutocompleteOverall autocompleteOverall = LoganSquare.parse(responseBody.string(), AutocompleteOverall.class); AutocompleteOverall autocompleteOverall = LoganSquare.parse(
autocompleteUsersHashSet.addAll(autocompleteOverall.getOcs().getData()); responseBody.string(),
AutocompleteOverall.class);
autocompleteUsersHashSet.addAll(autocompleteOverall.getOcs().getData());
for (AutocompleteUser autocompleteUser : autocompleteUsersHashSet) { for (AutocompleteUser autocompleteUser : autocompleteUsersHashSet) {
if (!autocompleteUser.getId().equals(currentUser.getUserId()) && !existingParticipants.contains(autocompleteUser.getId())) { if (!autocompleteUser.getId().equals(currentUser.getUserId())
participant = new Participant(); && !existingParticipants.contains(autocompleteUser.getId())) {
participant.setActorId(autocompleteUser.getId()); participant = new Participant();
participant.setActorType(actorTypeConverter.getFromString(autocompleteUser.getSource())); participant.setActorId(autocompleteUser.getId());
participant.setDisplayName(autocompleteUser.getLabel()); participant.setActorType(actorTypeConverter.getFromString(autocompleteUser.getSource()));
participant.setSource(autocompleteUser.getSource()); participant.setDisplayName(autocompleteUser.getLabel());
participant.setSource(autocompleteUser.getSource());
String headerTitle; String headerTitle;
if (participant.getActorType() != Participant.ActorType.GROUPS) {
headerTitle = participant.getDisplayName().substring(0, 1).toUpperCase();
} else {
headerTitle = getResources().getString(R.string.nc_groups);
}
GenericTextHeaderItem genericTextHeaderItem;
if (!userHeaderItems.containsKey(headerTitle)) {
genericTextHeaderItem = new GenericTextHeaderItem(headerTitle);
userHeaderItems.put(headerTitle, genericTextHeaderItem);
}
UserItem newContactItem = new UserItem(participant, currentUser,
userHeaderItems.get(headerTitle));
if (!contactItems.contains(newContactItem)) {
newUserItemList.add(newContactItem);
}
if (participant.getActorType() == Participant.ActorType.GROUPS) {
headerTitle = getResources().getString(R.string.nc_groups);
} else if (participant.getActorType() == Participant.ActorType.CIRCLES) {
headerTitle = getResources().getString(R.string.nc_circles);
} else {
headerTitle = participant.getDisplayName().substring(0, 1).toUpperCase();
} }
GenericTextHeaderItem genericTextHeaderItem;
if (!userHeaderItems.containsKey(headerTitle)) {
genericTextHeaderItem = new GenericTextHeaderItem(headerTitle);
userHeaderItems.put(headerTitle, genericTextHeaderItem);
}
UserItem newContactItem = new UserItem(
participant,
currentUser,
userHeaderItems.get(headerTitle)
);
if (!contactItems.contains(newContactItem)) {
newUserItemList.add(newContactItem);
}
}
} }
} catch (Exception exception) { } catch (IOException ioe) {
Log.e(TAG, "Parsing response body failed while getting contacts"); Log.e(TAG, "Parsing response body failed while getting contacts", ioe);
} }
userHeaderItems = new HashMap<>(); userHeaderItems = new HashMap<>();
@ -544,7 +579,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
String firstName; String firstName;
String secondName; String secondName;
if (o1 instanceof UserItem) { if (o1 instanceof UserItem) {
firstName = ((UserItem) o1).getModel().getDisplayName(); firstName = ((UserItem) o1).getModel().getDisplayName();
} else { } else {
@ -558,13 +592,35 @@ public class ContactsController extends BaseController implements SearchView.OnQ
} }
if (o1 instanceof UserItem && o2 instanceof UserItem) { if (o1 instanceof UserItem && o2 instanceof UserItem) {
if ("groups".equals(((UserItem) o1).getModel().getSource()) && "groups".equals(((UserItem) o2).getModel().getSource())) { String firstSource = ((UserItem) o1).getModel().getSource();
String secondSource = ((UserItem) o2).getModel().getSource();
if (firstSource.equals(secondSource)) {
return firstName.compareToIgnoreCase(secondName); return firstName.compareToIgnoreCase(secondName);
} else if ("groups".equals(((UserItem) o1).getModel().getSource())) { }
// First users
if ("users".equals(firstSource)) {
return -1; return -1;
} else if ("groups".equals(((UserItem) o2).getModel().getSource())) { } else if ("users".equals(secondSource)) {
return 1; return 1;
} }
// Then groups
if ("groups".equals(firstSource)) {
return -1;
} else if ("groups".equals(secondSource)) {
return 1;
}
// Then circles
if ("circles".equals(firstSource)) {
return -1;
} else if ("circles".equals(secondSource)) {
return 1;
}
// Otherwise fall back to name sorting
return firstName.compareToIgnoreCase(secondName);
} }
return firstName.compareToIgnoreCase(secondName); return firstName.compareToIgnoreCase(secondName);
@ -574,7 +630,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
String firstName; String firstName;
String secondName; String secondName;
if (o1 instanceof UserItem) { if (o1 instanceof UserItem) {
firstName = ((UserItem) o1).getModel().getDisplayName(); firstName = ((UserItem) o1).getModel().getDisplayName();
} else { } else {
@ -600,7 +655,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
return firstName.compareToIgnoreCase(secondName); return firstName.compareToIgnoreCase(secondName);
}); });
if (newUserItemList.size() > 0) { if (newUserItemList.size() > 0) {
adapter.updateDataSet(newUserItemList); adapter.updateDataSet(newUserItemList);
} else { } else {
@ -611,7 +665,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
} }
} }
} }
@Override @Override
@ -620,7 +673,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
} }
dispose(contactsQueryDisposable); dispose(contactsQueryDisposable);
} }
@Override @Override
@ -747,7 +799,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
private void checkAndHandleDoneMenuItem() { private void checkAndHandleDoneMenuItem() {
if (adapter != null && doneMenuItem != null) { if (adapter != null && doneMenuItem != null) {
if ((selectedGroupIds.size() + selectedUserIds.size() > 0) || isPublicCall) { if ((selectedCircleIds.size() + selectedEmails.size() + selectedGroupIds.size() + selectedUserIds.size() > 0) || isPublicCall) {
doneMenuItem.setVisible(true); doneMenuItem.setVisible(true);
} else { } else {
doneMenuItem.setVisible(false); doneMenuItem.setVisible(false);
@ -759,10 +811,12 @@ public class ContactsController extends BaseController implements SearchView.OnQ
@Override @Override
protected String getTitle() { protected String getTitle() {
if (!isNewConversationView && !isAddingParticipantsView) { if (isAddingParticipantsView) {
return getResources().getString(R.string.nc_app_name); return getResources().getString(R.string.nc_add_participants);
} else if (isNewConversationView) {
return getResources().getString(R.string.nc_select_participants);
} else { } else {
return getResources().getString(R.string.nc_select_contacts); return getResources().getString(R.string.nc_app_name);
} }
} }
@ -848,6 +902,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion, RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion,
currentUser.getBaseUrl(), currentUser.getBaseUrl(),
roomType, roomType,
null,
userItem.getModel().getActorId(), userItem.getModel().getActorId(),
null); null);
@ -899,6 +954,18 @@ public class ContactsController extends BaseController implements SearchView.OnQ
} else { } else {
selectedGroupIds.remove(participant.getActorId()); selectedGroupIds.remove(participant.getActorId());
} }
} else if ("emails".equals(participant.getSource())) {
if (participant.isSelected()) {
selectedEmails.add(participant.getActorId());
} else {
selectedEmails.remove(participant.getActorId());
}
} else if ("circles".equals(participant.getSource())) {
if (participant.isSelected()) {
selectedCircleIds.add(participant.getActorId());
} else {
selectedCircleIds.remove(participant.getActorId());
}
} else { } else {
if (participant.isSelected()) { if (participant.isSelected()) {
selectedUserIds.add(participant.getActorId()); selectedUserIds.add(participant.getActorId());

View File

@ -403,10 +403,10 @@ public class OperationsMenuController extends BaseController {
if (conversationType.equals(Conversation.ConversationType.ROOM_PUBLIC_CALL)) { if (conversationType.equals(Conversation.ConversationType.ROOM_PUBLIC_CALL)) {
retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion, currentUser.getBaseUrl(), retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion, currentUser.getBaseUrl(),
"3", invite, conversationName); "3", null, invite, conversationName);
} else { } else {
retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion, currentUser.getBaseUrl(), retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion, currentUser.getBaseUrl(),
"2", invite, conversationName); "2", null, invite, conversationName);
} }
ncApi.createRoom(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap()) ncApi.createRoom(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
@ -582,10 +582,13 @@ public class OperationsMenuController extends BaseController {
if ((localInvitedGroups.size() > 0 && currentUser.hasSpreedFeatureCapability("invite-groups-and-mails"))) { if ((localInvitedGroups.size() > 0 && currentUser.hasSpreedFeatureCapability("invite-groups-and-mails"))) {
for (int i = 0; i < localInvitedGroups.size(); i++) { for (int i = 0; i < localInvitedGroups.size(); i++) {
final String groupId = localInvitedGroups.get(i); final String groupId = localInvitedGroups.get(i);
retrofitBucket = ApiUtils.getRetrofitBucketForAddGroupParticipant(apiVersion, retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipantWithSource(
currentUser.getBaseUrl(), apiVersion,
conversation.getToken(), currentUser.getBaseUrl(),
groupId); conversation.getToken(),
"groups",
groupId
);
ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap()) ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())

View File

@ -64,6 +64,8 @@ public class AddParticipantsToConversation extends Worker {
Data data = getInputData(); Data data = getInputData();
String[] selectedUserIds = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_USERS()); String[] selectedUserIds = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_USERS());
String[] selectedGroupIds = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_GROUPS()); String[] selectedGroupIds = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_GROUPS());
String[] selectedCircleIds = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_CIRCLES());
String[] selectedEmails = data.getStringArray(BundleKeys.INSTANCE.getKEY_SELECTED_EMAILS());
UserEntity user = userUtils.getUserWithInternalId(data.getLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), -1)); UserEntity user = userUtils.getUserWithInternalId(data.getLong(BundleKeys.INSTANCE.getKEY_INTERNAL_USER_ID(), -1));
int apiVersion = ApiUtils.getConversationApiVersion(user, new int[] {ApiUtils.APIv4, 1}); int apiVersion = ApiUtils.getConversationApiVersion(user, new int[] {ApiUtils.APIv4, 1});
@ -72,23 +74,64 @@ public class AddParticipantsToConversation extends Worker {
String credentials = ApiUtils.getCredentials(user.getUsername(), user.getToken()); String credentials = ApiUtils.getCredentials(user.getUsername(), user.getToken());
RetrofitBucket retrofitBucket; RetrofitBucket retrofitBucket;
for (String userId : selectedUserIds) { if (selectedUserIds != null) {
retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipant(apiVersion, user.getBaseUrl(), for (String userId : selectedUserIds) {
conversationToken, retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipant(apiVersion, user.getBaseUrl(),
userId); conversationToken,
userId);
ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap()) ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.blockingSubscribe(); .blockingSubscribe();
}
} }
for (String groupId : selectedGroupIds) { if (selectedGroupIds != null) {
retrofitBucket = ApiUtils.getRetrofitBucketForAddGroupParticipant(apiVersion, user.getBaseUrl(), conversationToken, for (String groupId : selectedGroupIds) {
groupId); retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipantWithSource(
apiVersion,
user.getBaseUrl(),
conversationToken,
"groups",
groupId
);
ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap()) ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.blockingSubscribe(); .blockingSubscribe();
}
}
if (selectedCircleIds != null) {
for (String circleId : selectedCircleIds) {
retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipantWithSource(
apiVersion,
user.getBaseUrl(),
conversationToken,
"circles",
circleId
);
ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
.subscribeOn(Schedulers.io())
.blockingSubscribe();
}
}
if (selectedEmails != null) {
for (String email : selectedEmails) {
retrofitBucket = ApiUtils.getRetrofitBucketForAddParticipantWithSource(
apiVersion,
user.getBaseUrl(),
conversationToken,
"emails",
email
);
ncApi.addParticipant(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
.subscribeOn(Schedulers.io())
.blockingSubscribe();
}
} }
eventBus.post(new EventStatus(user.getId(), EventStatus.EventType.PARTICIPANTS_UPDATE, true)); eventBus.post(new EventStatus(user.getId(), EventStatus.EventType.PARTICIPANTS_UPDATE, true));

View File

@ -24,6 +24,7 @@ package com.nextcloud.talk.models.json.converters
import com.bluelinelabs.logansquare.typeconverters.StringBasedTypeConverter import com.bluelinelabs.logansquare.typeconverters.StringBasedTypeConverter
import com.nextcloud.talk.models.json.participants.Participant import com.nextcloud.talk.models.json.participants.Participant
import com.nextcloud.talk.models.json.participants.Participant.ActorType.CIRCLES
import com.nextcloud.talk.models.json.participants.Participant.ActorType.DUMMY import com.nextcloud.talk.models.json.participants.Participant.ActorType.DUMMY
import com.nextcloud.talk.models.json.participants.Participant.ActorType.EMAILS import com.nextcloud.talk.models.json.participants.Participant.ActorType.EMAILS
import com.nextcloud.talk.models.json.participants.Participant.ActorType.GROUPS import com.nextcloud.talk.models.json.participants.Participant.ActorType.GROUPS
@ -37,6 +38,7 @@ class EnumActorTypeConverter : StringBasedTypeConverter<Participant.ActorType>()
"groups" -> GROUPS "groups" -> GROUPS
"guests" -> GUESTS "guests" -> GUESTS
"users" -> USERS "users" -> USERS
"circles" -> CIRCLES
else -> DUMMY else -> DUMMY
} }
} }
@ -52,6 +54,7 @@ class EnumActorTypeConverter : StringBasedTypeConverter<Participant.ActorType>()
GROUPS -> "groups" GROUPS -> "groups"
GUESTS -> "guests" GUESTS -> "guests"
USERS -> "users" USERS -> "users"
CIRCLES -> "circles"
else -> "" else -> ""
} }
} }

View File

@ -326,6 +326,7 @@ public class Participant {
GROUPS, GROUPS,
GUESTS, GUESTS,
USERS, USERS,
CIRCLES,
} }
public enum ParticipantType { public enum ParticipantType {

View File

@ -255,6 +255,7 @@ public class ApiUtils {
} }
public static RetrofitBucket getRetrofitBucketForCreateRoom(int version, String baseUrl, String roomType, public static RetrofitBucket getRetrofitBucketForCreateRoom(int version, String baseUrl, String roomType,
@Nullable String source,
@Nullable String invite, @Nullable String invite,
@Nullable String conversationName) { @Nullable String conversationName) {
RetrofitBucket retrofitBucket = new RetrofitBucket(); RetrofitBucket retrofitBucket = new RetrofitBucket();
@ -265,6 +266,9 @@ public class ApiUtils {
if (invite != null) { if (invite != null) {
queryMap.put("invite", invite); queryMap.put("invite", invite);
} }
if (source != null) {
queryMap.put("source", source);
}
if (conversationName != null) { if (conversationName != null) {
queryMap.put("roomName", conversationName); queryMap.put("roomName", conversationName);
@ -289,15 +293,15 @@ public class ApiUtils {
} }
public static RetrofitBucket getRetrofitBucketForAddGroupParticipant(int version, String baseUrl, String token, String group) { public static RetrofitBucket getRetrofitBucketForAddParticipantWithSource(
RetrofitBucket retrofitBucket = getRetrofitBucketForAddParticipant(version, baseUrl, token, group); int version,
retrofitBucket.getQueryMap().put("source", "groups"); String baseUrl,
return retrofitBucket; String token,
} String source,
String id
public static RetrofitBucket getRetrofitBucketForAddMailParticipant(int version, String baseUrl, String token, String mail) { ) {
RetrofitBucket retrofitBucket = getRetrofitBucketForAddParticipant(version, baseUrl, token, mail); RetrofitBucket retrofitBucket = getRetrofitBucketForAddParticipant(version, baseUrl, token, id);
retrofitBucket.getQueryMap().put("source", "emails"); retrofitBucket.getQueryMap().put("source", source);
return retrofitBucket; return retrofitBucket;
} }

View File

@ -23,6 +23,8 @@ package com.nextcloud.talk.utils.bundle
object BundleKeys { object BundleKeys {
val KEY_SELECTED_USERS = "KEY_SELECTED_USERS" val KEY_SELECTED_USERS = "KEY_SELECTED_USERS"
val KEY_SELECTED_GROUPS = "KEY_SELECTED_GROUPS" val KEY_SELECTED_GROUPS = "KEY_SELECTED_GROUPS"
val KEY_SELECTED_CIRCLES = "KEY_SELECTED_CIRCLES"
val KEY_SELECTED_EMAILS = "KEY_SELECTED_EMAILS"
val KEY_USERNAME = "KEY_USERNAME" val KEY_USERNAME = "KEY_USERNAME"
val KEY_TOKEN = "KEY_TOKEN" val KEY_TOKEN = "KEY_TOKEN"
val KEY_BASE_URL = "KEY_BASE_URL" val KEY_BASE_URL = "KEY_BASE_URL"
@ -48,7 +50,9 @@ object BundleKeys {
val KEY_INTERNAL_USER_ID = "KEY_INTERNAL_USER_ID" val KEY_INTERNAL_USER_ID = "KEY_INTERNAL_USER_ID"
val KEY_CONVERSATION_TYPE = "KEY_CONVERSATION_TYPE" val KEY_CONVERSATION_TYPE = "KEY_CONVERSATION_TYPE"
val KEY_INVITED_PARTICIPANTS = "KEY_INVITED_PARTICIPANTS" val KEY_INVITED_PARTICIPANTS = "KEY_INVITED_PARTICIPANTS"
val KEY_INVITED_CIRCLE = "KEY_INVITED_CIRCLE"
val KEY_INVITED_GROUP = "KEY_INVITED_GROUP" val KEY_INVITED_GROUP = "KEY_INVITED_GROUP"
val KEY_INVITED_EMAIL = "KEY_INVITED_EMAIL"
val KEY_CONVERSATION_NAME = "KEY_CONVERSATION_NAME" val KEY_CONVERSATION_NAME = "KEY_CONVERSATION_NAME"
val KEY_CALL_VOICE_ONLY = "KEY_CALL_VOICE_ONLY" val KEY_CALL_VOICE_ONLY = "KEY_CALL_VOICE_ONLY"
val KEY_ACTIVE_CONVERSATION = "KEY_ACTIVE_CONVERSATION" val KEY_ACTIVE_CONVERSATION = "KEY_ACTIVE_CONVERSATION"

View File

@ -190,7 +190,8 @@
<string name="nc_remove_from_favorites">Remove from favorites</string> <string name="nc_remove_from_favorites">Remove from favorites</string>
<!-- Contacts --> <!-- Contacts -->
<string name="nc_select_contacts">Select contacts</string> <string name="nc_select_participants">Select participants</string>
<string name="nc_add_participants">Add participants</string>
<string name="nc_contacts_done">Done</string> <string name="nc_contacts_done">Done</string>
<!-- Permissions --> <!-- Permissions -->
@ -312,6 +313,7 @@
<string name="nc_email">Email</string> <string name="nc_email">Email</string>
<string name="nc_group">Group</string> <string name="nc_group">Group</string>
<string name="nc_groups">Groups</string> <string name="nc_groups">Groups</string>
<string name="nc_circles">Circles</string>
<string name="nc_participants">Participants</string> <string name="nc_participants">Participants</string>
<string name="nc_participants_add">Add participants</string> <string name="nc_participants_add">Add participants</string>