From 4b370dbb8cedf52287c0565eb283dd682d5740af Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Wed, 3 Jan 2024 12:21:16 -0300 Subject: [PATCH] '#2036: Use WA display name, as the contact's name, if available. --- .../src/main/java/iped/parsers/whatsapp/Chat.java | 8 ++++++-- .../main/java/iped/parsers/whatsapp/ReportGenerator.java | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/Chat.java b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/Chat.java index 790c6df3d3..541560e623 100644 --- a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/Chat.java +++ b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/Chat.java @@ -97,9 +97,13 @@ public String getTitle() { } } else { title = "WhatsApp Chat"; //$NON-NLS-1$ - if (remote != null && remote.getName() != null - && (getPrintId() == null || !remote.getName().strip().equals(getPrintId().strip()))) + if (remote != null && remote.getDisplayName() != null && !remote.getDisplayName().isBlank() + && (getPrintId() == null || !remote.getDisplayName().strip().equals(getPrintId().strip()))) { + title += " - " + remote.getDisplayName().strip(); + } else if (remote != null && remote.getName() != null + && (getPrintId() == null || !remote.getName().strip().equals(getPrintId().strip()))) { title += " - " + remote.getName().strip(); //$NON-NLS-1$ + } } if (getPrintId() != null && !getPrintId().isBlank()) { title += " - " + getPrintId().strip(); diff --git a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/ReportGenerator.java b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/ReportGenerator.java index 7b225f04af..9e2abeee40 100644 --- a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/ReportGenerator.java +++ b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/ReportGenerator.java @@ -1069,7 +1069,10 @@ private String getBestContactName(boolean isFromMe, String remoteResource, WACon if (number != null) { WAContact contact = contactsDirectory.getContact(number); if (contact != null) { - name = contact.getName(); + name = contact.getDisplayName(); + if (name == null || name.isBlank()) { + name = contact.getName(); + } } if (number.endsWith(waSuffix)) { number = number.substring(0, number.length() - waSuffix.length());