From 5fd416972031ff29235ba1469ce1ea3a2a43ad78 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 23 Jun 2017 14:51:08 +0200 Subject: [PATCH] don't use version part of identity name in presence selection. fixes #2519 --- .../conversations/entities/Presences.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Presences.java b/src/main/java/eu/siacs/conversations/entities/Presences.java index 88d04dffa..57a8e5fe1 100644 --- a/src/main/java/eu/siacs/conversations/entities/Presences.java +++ b/src/main/java/eu/siacs/conversations/entities/Presences.java @@ -120,11 +120,31 @@ public class Presences { typeMap.put(resource,type); } if (name != null) { - nameMap.put(resource, name); + nameMap.put(resource, nameWithoutVersion(name)); } } } } return new Pair<>(typeMap,nameMap); } + + private static String nameWithoutVersion(String name) { + String[] parts = name.split(" "); + if (parts.length <= 1) { + return name; + } else { + if (Character.isDigit(parts[parts.length -1].charAt(0))) { + StringBuilder output = new StringBuilder(); + for(int i = 0; i < parts.length -1; ++i) { + if (output.length() != 0) { + output.append(' '); + } + output.append(parts[i]); + } + return output.toString(); + } else { + return name; + } + } + } }