Skip to content

Commit

Permalink
'#2011: change WhatsApp group messages to use the group as TO field
Browse files Browse the repository at this point in the history
  • Loading branch information
lfcnassif committed Jul 26, 2024
1 parent 56ac676 commit 567239c
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -889,13 +889,14 @@ private String formatContact(WAContact contact, Map<String, String> cache) {
return result;
}

private void fillGroupRecipients(Metadata meta, Chat c, String from, Map<String, String> cache) {
for (WAContact member : c.getGroupMembers()) {
String gmb = formatContact(member, cache);
if (!gmb.equals(from)) {
meta.add(org.apache.tika.metadata.Message.MESSAGE_TO, gmb);
}
}
private void fillGroupRecipients(Metadata meta, Chat c) {
String to = c.isChannelChat() ? "Channel " : "Group ";
if (c.getSubject() != null) {
to += c.getSubject().strip();
}
to += " (id:" + c.getId() + ")";
meta.add(org.apache.tika.metadata.Message.MESSAGE_TO, to);
meta.set(ExtraProperties.IS_GROUP_MESSAGE, "true");
}

private void extractMessages(String chatName, Chat c, List<Message> messages, WAAccount account,
Expand Down Expand Up @@ -926,15 +927,15 @@ private void extractMessages(String chatName, Chat c, List<Message> messages, WA
}
if (m.isFromMe()) {
meta.set(org.apache.tika.metadata.Message.MESSAGE_FROM, local);
if (c.isGroupChat()) {
fillGroupRecipients(meta, c, local, cache);
if (c.isGroupOrChannelChat()) {
fillGroupRecipients(meta, c);
} else {
meta.add(org.apache.tika.metadata.Message.MESSAGE_TO, remote);
}
} else {
meta.set(org.apache.tika.metadata.Message.MESSAGE_FROM, remote);
if (c.isGroupChat()) {
fillGroupRecipients(meta, c, remote, cache);
if (c.isGroupOrChannelChat()) {
fillGroupRecipients(meta, c);
} else {
meta.add(org.apache.tika.metadata.Message.MESSAGE_TO, local);
}
Expand Down

0 comments on commit 567239c

Please sign in to comment.