Fix some more getUserId() calls

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-05-10 11:34:19 +02:00
parent dde79b5671
commit 79be753493
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
5 changed files with 30 additions and 49 deletions

View File

@ -70,7 +70,8 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
public boolean equals(Object o) {
if (o instanceof UserItem) {
UserItem inItem = (UserItem) o;
return participant.getUserId().equals(inItem.getModel().getUserId());
return participant.getActorType().equals(inItem.getModel().getActorType()) &&
participant.getActorId().equals(inItem.getModel().getActorId());
}
return false;
}
@ -178,7 +179,7 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
.setOldController(holder.simpleDraweeView.getController())
.setAutoPlayAnimations(true)
.setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
participant.getUserId(), R.dimen.avatar_size), null))
participant.getActorId(), R.dimen.avatar_size), null))
.build();
holder.simpleDraweeView.setController(draweeController);
}
@ -279,7 +280,7 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
public boolean filter(String constraint) {
return participant.getDisplayName() != null &&
(Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL).matcher(participant.getDisplayName().trim()).find() ||
Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL).matcher(participant.getUserId().trim()).find());
Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL).matcher(participant.getActorId().trim()).find());
}
@Override

View File

@ -230,7 +230,8 @@ public class CallNotificationController extends BaseController {
if (hasParticipantsInCall) {
for (Participant participant : participantList) {
if (participant.getUserId().equals(userBeingCalled.getUserId())) {
if (participant.getActorType() == Participant.ActorType.USERS &&
participant.getActorId().equals(userBeingCalled.getUserId())) {
inCallOnDifferentDevice = true;
break;
}

View File

@ -862,7 +862,7 @@ public class ContactsController extends BaseController implements SearchView.OnQ
RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(apiVersion,
currentUser.getBaseUrl(),
roomType,
userItem.getModel().getUserId(),
userItem.getModel().getActorId(),
null);
ncApi.createRoom(credentials,
@ -914,15 +914,15 @@ public class ContactsController extends BaseController implements SearchView.OnQ
if ("groups".equals(participant.getSource())) {
if (participant.isSelected()) {
selectedGroupIds.add(participant.getUserId());
selectedGroupIds.add(participant.getActorId());
} else {
selectedGroupIds.remove(participant.getUserId());
selectedGroupIds.remove(participant.getActorId());
}
} else {
if (participant.isSelected()) {
selectedUserIds.add(participant.getUserId());
selectedUserIds.add(participant.getActorId());
} else {
selectedUserIds.remove(participant.getUserId());
selectedUserIds.remove(participant.getActorId());
}
}
@ -935,10 +935,11 @@ public class ContactsController extends BaseController implements SearchView.OnQ
Participant internalParticipant;
for (int i = 0; i < currentItems.size(); i++) {
internalParticipant = currentItems.get(i).getModel();
if (internalParticipant.getUserId().equals(participant.getUserId()) &&
"groups".equals(internalParticipant.getSource()) && internalParticipant.isSelected()) {
if (internalParticipant.getActorId().equals(participant.getActorId()) &&
internalParticipant.getActorType() == Participant.ActorType.GROUPS &&
internalParticipant.isSelected()) {
internalParticipant.setSelected(false);
selectedGroupIds.remove(internalParticipant.getUserId());
selectedGroupIds.remove(internalParticipant.getActorId());
}
}
@ -978,9 +979,10 @@ public class ContactsController extends BaseController implements SearchView.OnQ
for (int i = 0; i < currentItems.size(); i++) {
if (currentItems.get(i) instanceof UserItem) {
internalParticipant = ((UserItem) currentItems.get(i)).getModel();
if ("groups".equals(internalParticipant.getSource()) && internalParticipant.isSelected()) {
if (internalParticipant.getActorType() == Participant.ActorType.GROUPS &&
internalParticipant.isSelected()) {
internalParticipant.setSelected(false);
selectedGroupIds.remove(internalParticipant.getUserId());
selectedGroupIds.remove(internalParticipant.getActorId());
}
}
}

View File

@ -125,23 +125,10 @@ public class Participant {
return attendeePin;
}
@Deprecated
public String getUserId() {
if (this.actorType != null && this.actorType == ActorType.USERS) {
return this.actorId;
}
return this.userId;
}
public ParticipantType getType() {
return this.type;
}
@Deprecated
public String getName() {
return this.name;
}
public String getDisplayName() {
return this.displayName;
}
@ -159,11 +146,6 @@ public class Participant {
return sessionIds;
}
@Deprecated
public long getRoomId() {
return this.roomId;
}
public Object getInCall() {
return this.inCall;
}
@ -176,11 +158,6 @@ public class Participant {
return this.selected;
}
@Deprecated
public void setUserId(String userId) {
this.userId = userId;
}
public void setAttendeeId(Long attendeeId) {
this.attendeeId = attendeeId;
}
@ -201,11 +178,6 @@ public class Participant {
this.type = type;
}
@Deprecated
public void setName(String name) {
this.name = name;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
@ -219,11 +191,6 @@ public class Participant {
this.sessionId = sessionId;
}
@Deprecated
public void setRoomId(long roomId) {
this.roomId = roomId;
}
public void setInCall(Object inCall) {
this.inCall = inCall;
}

View File

@ -64,6 +64,9 @@ import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import okio.ByteString;
import static com.nextcloud.talk.models.json.participants.Participant.ActorType.GUESTS;
import static com.nextcloud.talk.models.json.participants.Participant.ActorType.USERS;
@AutoInjector(NextcloudTalkApplication.class)
public class MagicWebSocketInstance extends WebSocketListener {
private static final String TAG = "MagicWebSocketInstance";
@ -246,7 +249,14 @@ public class MagicWebSocketInstance extends WebSocketListener {
internalHashMap = joinEventMap.get(i);
HashMap<String, Object> userMap = (HashMap<String, Object>) internalHashMap.get("user");
participant = new Participant();
participant.setUserId((String) internalHashMap.get("userid"));
String userId = (String) internalHashMap.get("userid");
if (userId != null) {
participant.setActorType(USERS);
participant.setActorId(userId);
} else {
participant.setActorType(GUESTS);
// FIXME seems to be not given by the HPB: participant.setActorId();
}
if (userMap != null) {
// There is no "user" attribute for guest participants.
participant.setDisplayName((String) userMap.get("displayname"));
@ -412,7 +422,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
public String getUserIdForSession(String session) {
Participant participant = usersHashMap.get(session);
if (participant != null) {
if (participant.getActorType() == Participant.ActorType.USERS) {
if (participant.getActorType() == USERS) {
return participant.getActorId();
}
}