Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into #1866_ColoredBookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
wladimirleite committed Oct 7, 2023
2 parents 1479607 + 73dc869 commit 8c118cb
Showing 1 changed file with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,33 +449,37 @@ private Message createMessageFromUndeletedRecord(SqliteRow row, Chat chat, Map<L
m.setUrl(mediaItem.getTextValue("ZMEDIAURL")); //$NON-NLS-1$
m.setLatitude(mediaItem.getFloatValue("ZLATITUDE")); //$NON-NLS-1$
m.setLongitude(mediaItem.getFloatValue("ZLONGITUDE")); //$NON-NLS-1$

// This block must be before "if (MEDIA_MESSAGES.contains(m.getMessageType()))",
// otherwise Media Hash won't be set. See issue #1921.
if (messageType == 0 && m.getData() == null) {
if (m.getMediaMime() != null) {
var mediaMime = m.getMediaMime();
if (mediaMime != null) {
if (mediaMime.startsWith("image")) {
m.setMessageType(IMAGE_MESSAGE);
} else if (mediaMime.startsWith("video")) {
m.setMessageType(VIDEO_MESSAGE);
} else if (mediaMime.startsWith("application")) {
m.setMessageType(APP_MESSAGE);
} else if (mediaMime.startsWith("audio")) {
m.setMessageType(AUDIO_MESSAGE);
} else if (m.getMediaCaption() != null) {
m.setMessageType(UNKNOWN_MEDIA_MESSAGE);
}
}
} else if (m.getMediaCaption() != null) {
m.setMessageType(UNKNOWN_MEDIA_MESSAGE);
}
}

if (MEDIA_MESSAGES.contains(m.getMessageType())) {
try {
m.setMediaHash(mediaItem.getTextValue("ZVCARDNAME"), true); //$NON-NLS-1$
} catch (IllegalArgumentException e) {
} // ignore
}
}
if (messageType == 0 && m.getData() == null) {
if (m.getMediaMime() != null) {
var mediaMime = m.getMediaMime();
if (mediaMime != null) {
if (mediaMime.startsWith("image")) {
m.setMessageType(IMAGE_MESSAGE);
} else if (mediaMime.startsWith("video")) {
m.setMessageType(VIDEO_MESSAGE);
} else if (mediaMime.startsWith("application")) {
m.setMessageType(APP_MESSAGE);
} else if (mediaMime.startsWith("audio")) {
m.setMessageType(AUDIO_MESSAGE);
} else if (m.getMediaCaption() != null ){
m.setMessageType(UNKNOWN_MEDIA_MESSAGE);
}
}
} else if (m.getMediaCaption() != null) {
m.setMessageType(UNKNOWN_MEDIA_MESSAGE);
}
}
m.setDeleted(row.isDeletedRow());
return m;
}
Expand Down

0 comments on commit 8c118cb

Please sign in to comment.