Skip to content

Commit

Permalink
'#1923: Use proper ProtoBuf decoding for iOS ephemeral duration.
Browse files Browse the repository at this point in the history
  • Loading branch information
wladimirleite committed Feb 1, 2024
1 parent cf12229 commit c17e90f
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -640,21 +640,18 @@ private MessageTemplate decodeTemplate(byte[] metadata) {
}

private int decodeEphemeralDuration(byte[] metadata) {
int days = 7; // default value
int v1 = getPositiveValueFromMetadata(metadata, 2);
if (v1 == 0) {
days = 0;
} else if (v1 == 0x80) {
int v2 = getPositiveValueFromMetadata(metadata, 3);
int v3 = getPositiveValueFromMetadata(metadata, 4);
if (v2 == 0xA3 && v3 == 0x05) {
days = 1;
} else if (v2 == 0xF5 && v3 == 0x24) {
days = 7;
int seconds = 0;
Part p1 = new ProtoBufDecoder(metadata).decode(36);
if (p1 != null) {
String s = p1.getString();
if (s != null && !s.isBlank()) {
try {
seconds = Integer.parseInt(s);
} catch (NumberFormatException e) {
}
}
// Codes for other values (like 30 or 90 days)?
}
return days * 86400;
return seconds;
}

private Message createMessageFromUndeletedRecord(SqliteRow row, Chat chat, Map<Long, SqliteRow> mediaItems,
Expand Down

0 comments on commit c17e90f

Please sign in to comment.