Explorar o código

Always pass the session id in "NICK_CHANGE" PeerConnectionEvents

Before the NICK_CHANGE event include either the session id or the user
id, depending on whether the participant was a guest or a user. However,
as the session id is also known for users the event can be unified to
always include the session id only.

This also fixes an exception when handling the "NICK_CHANGE" event, as
the session id was got from the user id given in the event, but if the
event already included the session id the look up failed and the session
id was replaced with an empty value. This in turn caused an exception
when trying to use the view for the now invalid session id. Now the
session id provided in the event is always directly used.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Daniel Calviño Sánchez %!s(int64=4) %!d(string=hai) anos
pai
achega
6b2720653a

+ 3 - 8
app/src/main/java/com/nextcloud/talk/controllers/CallController.java

@@ -2031,16 +2031,11 @@ public class CallController extends BaseController {
         }
         }
     }
     }
 
 
-    private void gotNick(String sessionOrUserId, String nick, boolean isFromAnEvent, String type) {
-        if (isFromAnEvent && hasExternalSignalingServer) {
-            // get session based on userId
-            sessionOrUserId = webSocketClient.getSessionForUserId(sessionOrUserId);
-        }
-
-        sessionOrUserId += "+" + type;
+    private void gotNick(String sessionId, String nick, boolean isFromAnEvent, String type) {
+        sessionId += "+" + type;
 
 
         if (relativeLayout != null) {
         if (relativeLayout != null) {
-            RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionOrUserId);
+            RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
             TextView textView = relativeLayout.findViewById(R.id.peer_nick_text_view);
             TextView textView = relativeLayout.findViewById(R.id.peer_nick_text_view);
             if (!textView.getText().equals(nick)) {
             if (!textView.getText().equals(nick)) {
                 textView.setText(nick);
                 textView.setText(nick);

+ 1 - 1
app/src/main/java/com/nextcloud/talk/webrtc/MagicPeerConnectionWrapper.java

@@ -279,7 +279,7 @@ public class MagicPeerConnectionWrapper {
                         if (dataChannelMessage.getPayload() != null) {
                         if (dataChannelMessage.getPayload() != null) {
                             HashMap<String, String> payloadHashMap = (HashMap<String, String>) dataChannelMessage.getPayload();
                             HashMap<String, String> payloadHashMap = (HashMap<String, String>) dataChannelMessage.getPayload();
                             EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
                             EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
-                                    .NICK_CHANGE, payloadHashMap.get("userid"), payloadHashMap.get("name"), null, videoStreamType));
+                                    .NICK_CHANGE, sessionId, payloadHashMap.get("name"), null, videoStreamType));
                         }
                         }
                     }
                     }