Skip to content

Commit

Permalink
'#1923: Handle system actions 10 and 28 (number changed).
Browse files Browse the repository at this point in the history
wladimirleite committed Jan 3, 2024
1 parent d0c4595 commit f34d804
Showing 8 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -277,6 +277,7 @@ WhatsAppReport.Hours=hours
WhatsAppReport.GroupChangedAllMembersCanSend=changed this group's settings to allow all participants to send messages.
WhatsAppReport.GroupChangedOnlyAdminsCanSend=changed this group's settings to allow only admins to send messages.
WhatsAppReport.GroupOnlyAdminsCanSend=Only admins can send messages to this group.
WhatsAppReport.ChangedNumber=change to
VCardParser.FormattedName=Formatted Name
VCardParser.Name=Name
VCardParser.Nickname=Nickname
Original file line number Diff line number Diff line change
@@ -277,6 +277,7 @@ WhatsAppReport.Days=days[TBT]
WhatsAppReport.GroupChangedAllMembersCanSend=changed this group's settings to allow all participants to send messages.[TBT]
WhatsAppReport.GroupChangedOnlyAdminsCanSend=changed this group's settings to allow only admins to send messages.[TBT]
WhatsAppReport.GroupOnlyAdminsCanSend=Only admins can send messages to this group.[TBT]
WhatsAppReport.ChangedNumber=change to[TBT]
VCardParser.FormattedName=Name formatiert
VCardParser.Name=Name
VCardParser.Nickname=Nickname
Original file line number Diff line number Diff line change
@@ -277,6 +277,7 @@ WhatsAppReport.Days=days[TBT]
WhatsAppReport.GroupChangedAllMembersCanSend=changed this group's settings to allow all participants to send messages.[TBT]
WhatsAppReport.GroupChangedOnlyAdminsCanSend=changed this group's settings to allow only admins to send messages.[TBT]
WhatsAppReport.GroupOnlyAdminsCanSend=Only admins can send messages to this group.[TBT]
WhatsAppReport.ChangedNumber=change to[TBT]
VCardParser.FormattedName=Nombre con formato
VCardParser.Name=Nombre
VCardParser.Nickname=Sobrenombre
Original file line number Diff line number Diff line change
@@ -277,6 +277,7 @@ WhatsAppReport.Days=days[TBT]
WhatsAppReport.GroupChangedAllMembersCanSend=changed this group's settings to allow all participants to send messages.[TBT]
WhatsAppReport.GroupChangedOnlyAdminsCanSend=changed this group's settings to allow only admins to send messages.[TBT]
WhatsAppReport.GroupOnlyAdminsCanSend=Only admins can send messages to this group.[TBT]
WhatsAppReport.ChangedNumber=change to[TBT]
VCardParser.FormattedName=Nome formattato
VCardParser.Name=Nome
VCardParser.Nickname=Nickname
Original file line number Diff line number Diff line change
@@ -277,6 +277,7 @@ WhatsAppReport.Days=dias
WhatsAppReport.GroupChangedAllMembersCanSend=mudou as configurações deste grupo para permitir que todos os membros enviem mensagens.
WhatsAppReport.GroupChangedOnlyAdminsCanSend=mudou as configurações deste grupo para permitir que somente admins enviem mensagens.
WhatsAppReport.GroupOnlyAdminsCanSend=Somente admins podem enviar mensagens ao grupo.
WhatsAppReport.ChangedNumber=mudou para
VCardParser.FormattedName=Nome Formatado
VCardParser.Name=Nome
VCardParser.Nickname=Apelido
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import static iped.parsers.whatsapp.Message.MessageType.BUSINESS_CHAT;
import static iped.parsers.whatsapp.Message.MessageType.BUSINESS_META_SECURE_SERVICE;
import static iped.parsers.whatsapp.Message.MessageType.CALL_MESSAGE;
import static iped.parsers.whatsapp.Message.MessageType.CHANGED_NUMBER;
import static iped.parsers.whatsapp.Message.MessageType.CONTACT_MESSAGE;
import static iped.parsers.whatsapp.Message.MessageType.DELETED_BY_ADMIN;
import static iped.parsers.whatsapp.Message.MessageType.DELETED_BY_SENDER;
@@ -258,6 +259,17 @@ private void extractUsersGroupAction(Connection conn, Message m) throws SQLExcep
}
}

private void extractChangedNumber(Connection conn, Message m) throws SQLException {
try (PreparedStatement stmt = conn.prepareStatement(SELECT_SYSTEM_NUMBER_CHANGE)) {
stmt.setLong(1, m.getId());
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
m.addUserGroupAction(rs.getString("oldUser"));
m.addUserGroupAction(rs.getString("newUser"));
}
}
}

private void extractEphemeralDuration(Connection conn, Message m) throws SQLException {
try (PreparedStatement stmt = conn.prepareStatement(SELECT_EPHEMERAL_SETTING)) {
stmt.setLong(1, m.getId());
@@ -275,6 +287,7 @@ private void extractMessages(Connection conn, Map<Long, Chat> idToChat) throws S
boolean hasPollOptionTable = SQLite3DBParser.containsTable("message_poll_option", conn);
boolean hasEphemeralSettingTable = SQLite3DBParser.containsTable("message_ephemeral_setting", conn);
boolean hasSystemChat = SQLite3DBParser.containsTable("message_system_chat_participant", conn);
boolean hasSystemNumberChangeTable = SQLite3DBParser.containsTable("message_system_number_change", conn);

try (PreparedStatement stmt = conn.prepareStatement(getSelectMessagesQuery(conn))) {
ResultSet rs = stmt.executeQuery();
@@ -391,6 +404,10 @@ private void extractMessages(Connection conn, Map<Long, Chat> idToChat) throws S
m.setRemoteResource(m.getUsersGroupAction().get(0));
}

if (hasSystemNumberChangeTable && m.getMessageType() == CHANGED_NUMBER) {
extractChangedNumber(conn, m);
}

c.add(m);
}
}
@@ -511,6 +528,10 @@ protected Message.MessageType decodeMessageType(int messageType, int status, Int
case 14:
result = USER_REMOVED_FROM_GROUP;
break;
case 10:
case 28:
result = CHANGED_NUMBER;
break;
case 11:
result = GROUP_CREATED;
break;
@@ -691,6 +712,8 @@ protected Message.MessageType decodeMessageType(int messageType, int status, Int
private static final String SELECT_TEMPLATE = "SELECT content_text_data as content FROM message_template where message_row_id=?";

private static final String SELECT_USERS_GROUP_ACTION = "select raw_string from message_system_chat_participant inner join jid on user_jid_row_id = jid._id where message_row_id=? order by _id";

private static final String SELECT_SYSTEM_NUMBER_CHANGE = "select old.raw_string as oldUser, new.raw_string as newUser from message_system_number_change left join jid old on old_jid_row_id = old._id left join jid new on new_jid_row_id = new._id where message_row_id=?";

private static final String SELECT_POLL_OPTION = "SELECT option_name as name, vote_total as total FROM message_poll_option where message_row_id=? order by _id";

Original file line number Diff line number Diff line change
@@ -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, TEMPLATE_QUOTE, POLL_MESSAGE, EPHEMERAL_DURATION_CHANGED, EPHEMERAL_ENABLED, EPHEMERAL_SAVE, GROUP_CHANGED_ONLY_ADMINS_CAN_SEND, GROUP_CHANGED_ALL_MEMBERS_CAN_SEND, GROUP_ONLY_ADMINS_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_CHANGED_ONLY_ADMINS_CAN_SEND, GROUP_CHANGED_ALL_MEMBERS_CAN_SEND, GROUP_ONLY_ADMINS_CAN_SEND, CHANGED_NUMBER, UNKNOWN_MESSAGE
}

public static enum MessageStatus {
Original file line number Diff line number Diff line change
@@ -531,6 +531,15 @@ private synchronized void printMessage(PrintWriter out, Message message, boolean
out.println("<div class=\"systemmessage\">");
out.println(Messages.getString("WhatsAppReport.GroupOnlyAdminsCanSend") + "<br>");
break;
case CHANGED_NUMBER:
out.println("<div class=\"systemmessage\">");
users = message.getUsersGroupAction();
if (users.size() >= 2) {
out.println(getBestContactName(false, users.get(0), contactsDirectory, account) + " "
+ Messages.getString("WhatsAppReport.ChangedNumber") + " "
+ getBestContactName(false, users.get(1), contactsDirectory, account) + ".<br>");
}
break;

default:
IItemReader mediaItem = null;

0 comments on commit f34d804

Please sign in to comment.