summary refs log tree commit diff
path: root/webclient
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-09-25 11:45:01 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-09-25 11:45:01 +0200
commitef99a5d972413014b5ab332cc89a25591990b9b1 (patch)
treefc534ccb31891fe807baaad127c522075f1be8b2 /webclient
parentDon't set the room name to be the room alias on room creation if the client d... (diff)
downloadsynapse-ef99a5d972413014b5ab332cc89a25591990b9b1.tar.xz
getUserDisplayName: Disambiguate users who have the same displayname in the room.
Displayname are then disambiguate where it is necessary
Diffstat (limited to '')
-rw-r--r--webclient/components/matrix/event-handler-service.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js
index ea52db4f4a..e990d42d05 100644
--- a/webclient/components/matrix/event-handler-service.js
+++ b/webclient/components/matrix/event-handler-service.js
@@ -373,6 +373,21 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) {
         var member = getMember(room_id, user_id);
         if (member && member.content.displayname) { // Do not consider null displayname
             displayName = member.content.displayname;
+
+            // Disambiguate users who have the same displayname in the room
+            if (user_id !== matrixService.config().user_id) {
+                var room = $rootScope.events.rooms[room_id];
+
+                for (var member_id in room.members) {
+                    if (room.members.hasOwnProperty(member_id) && member_id !== user_id) {
+                        var member2 = room.members[member_id];
+                        if (member2.content.displayname && member2.content.displayname === displayName) {
+                            displayName = displayName + " (" + user_id + ")";
+                            break;
+                        }
+                    }
+                }
+            }
         }
 
         // The user may not have joined the room yet. So try to resolve display name from presence data