diff --git a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/ExtractorAndroidNew.java b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/ExtractorAndroidNew.java index eaf0eb682d..617a5a8923 100644 --- a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/ExtractorAndroidNew.java +++ b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/ExtractorAndroidNew.java @@ -34,6 +34,7 @@ import static iped.parsers.whatsapp.Message.MessageType.STICKER_MESSAGE; import static iped.parsers.whatsapp.Message.MessageType.SUBJECT_CHANGED; import static iped.parsers.whatsapp.Message.MessageType.TEMPLATE_MESSAGE; +import static iped.parsers.whatsapp.Message.MessageType.TEMPLATE_QUOTE; import static iped.parsers.whatsapp.Message.MessageType.TEXT_MESSAGE; import static iped.parsers.whatsapp.Message.MessageType.UNAVAILABLE_VIDEO_CALL; import static iped.parsers.whatsapp.Message.MessageType.UNAVAILABLE_VOICE_CALL; @@ -639,6 +640,9 @@ protected Message.MessageType decodeMessageType(int messageType, int status, Int case 28: result = TEMPLATE_MESSAGE; break; + case 32: + result = TEMPLATE_QUOTE; + break; case 36: result = EPHEMERAL_DURATION_CHANGED; break; diff --git a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/Message.java b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/Message.java index 59f3ac6891..326613f5b1 100644 --- a/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/Message.java +++ b/iped-parsers/iped-parsers-impl/src/main/java/iped/parsers/whatsapp/Message.java @@ -561,7 +561,7 @@ public void setSortId(long sortId) { } public static enum MessageType { - TEXT_MESSAGE, IMAGE_MESSAGE, AUDIO_MESSAGE, VIDEO_MESSAGE, UNKNOWN_MEDIA_MESSAGE, CONTACT_MESSAGE, LOCATION_MESSAGE, SHARE_LOCATION_MESSAGE, VOICE_CALL, VIDEO_CALL, APP_MESSAGE, GIF_MESSAGE, BLOCKED_CONTACT, UNBLOCKED_CONTACT, BUSINESS_CHAT, BUSINESS_TO_STANDARD, MESSAGES_ENCRYPTED, MESSAGES_NOW_ENCRYPTED, ENCRYPTION_KEY_CHANGED, MISSED_VOICE_CALL, MISSED_VIDEO_CALL, DELETED_MESSAGE, DELETED_BY_ADMIN, DELETED_BY_SENDER, GROUP_CREATED, USER_JOINED_GROUP, USER_JOINED_GROUP_FROM_LINK, USERS_JOINED_GROUP, USER_LEFT_GROUP, USER_REMOVED_FROM_GROUP, URL_MESSAGE, GROUP_ICON_CHANGED, GROUP_ICON_DELETED, GROUP_DESCRIPTION_CHANGED, SUBJECT_CHANGED, YOU_ADMIN, WAITING_MESSAGE, STICKER_MESSAGE, REFUSED_VIDEO_CALL, REFUSED_VOICE_CALL, UNAVAILABLE_VIDEO_CALL, UNAVAILABLE_VOICE_CALL, UNKNOWN_VOICE_CALL, UNKNOWN_VIDEO_CALL, VIEW_ONCE_IMAGE_MESSAGE, VIEW_ONCE_VIDEO_MESSAGE, CALL_MESSAGE, BUSINESS_META_SECURE_SERVICE, GROUP_INVITE, TEMPLATE_MESSAGE, POLL_MESSAGE, EPHEMERAL_DURATION_CHANGED, EPHEMERAL_ENABLED, EPHEMERAL_SAVE, GROUP_ONLY_ADMINS_CAN_SEND, GROUP_ALL_MEMBERS_CAN_SEND, UNKNOWN_MESSAGE + TEXT_MESSAGE, IMAGE_MESSAGE, AUDIO_MESSAGE, VIDEO_MESSAGE, UNKNOWN_MEDIA_MESSAGE, CONTACT_MESSAGE, LOCATION_MESSAGE, SHARE_LOCATION_MESSAGE, VOICE_CALL, VIDEO_CALL, APP_MESSAGE, GIF_MESSAGE, BLOCKED_CONTACT, UNBLOCKED_CONTACT, BUSINESS_CHAT, BUSINESS_TO_STANDARD, MESSAGES_ENCRYPTED, MESSAGES_NOW_ENCRYPTED, ENCRYPTION_KEY_CHANGED, MISSED_VOICE_CALL, MISSED_VIDEO_CALL, DELETED_MESSAGE, DELETED_BY_ADMIN, DELETED_BY_SENDER, GROUP_CREATED, USER_JOINED_GROUP, USER_JOINED_GROUP_FROM_LINK, USERS_JOINED_GROUP, USER_LEFT_GROUP, USER_REMOVED_FROM_GROUP, URL_MESSAGE, GROUP_ICON_CHANGED, GROUP_ICON_DELETED, GROUP_DESCRIPTION_CHANGED, SUBJECT_CHANGED, YOU_ADMIN, WAITING_MESSAGE, STICKER_MESSAGE, REFUSED_VIDEO_CALL, REFUSED_VOICE_CALL, UNAVAILABLE_VIDEO_CALL, UNAVAILABLE_VOICE_CALL, UNKNOWN_VOICE_CALL, UNKNOWN_VIDEO_CALL, VIEW_ONCE_IMAGE_MESSAGE, VIEW_ONCE_VIDEO_MESSAGE, CALL_MESSAGE, BUSINESS_META_SECURE_SERVICE, GROUP_INVITE, TEMPLATE_MESSAGE, TEMPLATE_QUOTE, POLL_MESSAGE, EPHEMERAL_DURATION_CHANGED, EPHEMERAL_ENABLED, EPHEMERAL_SAVE, GROUP_ONLY_ADMINS_CAN_SEND, GROUP_ALL_MEMBERS_CAN_SEND, UNKNOWN_MESSAGE } public static enum MessageStatus { 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 55b5a6ab99..0d29b5f8ed 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 @@ -619,6 +619,12 @@ private synchronized void printMessage(PrintWriter out, Message message, boolean out.println("
"); } break; + case TEMPLATE_MESSAGE: + out.print("
" + quoteUser + + "
" + formatTemplate(messageQuote) + + "
"); + break; default: out.print("
"+quoteUser+ "
"+ format(dataQuote) + "
"); @@ -639,10 +645,11 @@ private synchronized void printMessage(PrintWriter out, Message message, boolean switch (message.getMessageType()) { case TEXT_MESSAGE: + case TEMPLATE_QUOTE: if (message.getData() != null && !message.getData().isBlank()) { out.print(format(message.getData()) + "
"); //$NON-NLS-1$ } - // Some (rare) text messages have thumbs + // Some textual messages may have thumbs printThumb(out, message); break; case UNKNOWN_MEDIA_MESSAGE: @@ -694,26 +701,7 @@ private synchronized void printMessage(PrintWriter out, Message message, boolean break; case TEMPLATE_MESSAGE: printThumb(out, message); - if (message.getData() != null && !message.getData().isBlank()) { - out.println(format(message.getData()) + "
"); - } - MessageTemplate t = message.getMessageTemplate(); - if (t != null) { - String content = t.getContent(); - if (content != null && !content.isBlank()) { - out.println(format(content) + "
"); - } - for (MessageTemplate.Button button : t.getButtons()) { - String text = button.getText(); - if (text != null && !text.isBlank()) { - out.println("[" + format(text) + "]
"); - } - String extra = button.getExtra(); - if (extra != null && !extra.isBlank() && !extra.equals(text)) { - out.println(format(extra) + "
"); - } - } - } + out.println(formatTemplate(message)); break; case POLL_MESSAGE: printThumb(out, message); @@ -1020,6 +1008,31 @@ private void printThumb(PrintWriter out, Message message) { } } + private String formatTemplate(Message message) { + StringBuilder sb = new StringBuilder(); + if (message.getData() != null && !message.getData().isBlank()) { + sb.append(format(message.getData())).append("
"); + } + MessageTemplate t = message.getMessageTemplate(); + if (t != null) { + String content = t.getContent(); + if (content != null && !content.isBlank()) { + sb.append(format(content)).append("
"); + } + for (MessageTemplate.Button button : t.getButtons()) { + String text = button.getText(); + if (text != null && !text.isBlank()) { + sb.append("[").append(format(text)).append("]
"); + } + String extra = button.getExtra(); + if (extra != null && !extra.isBlank() && !extra.equals(text)) { + sb.append(format(extra)).append("
"); + } + } + } + return sb.toString(); + } + private String getBestContactName(Message message, WAContactsDirectory contactsDirectory, WAAccount account) { return getBestContactName(message.isFromMe(), message.getRemoteResource(), contactsDirectory, account); }