|
|
|
@ -816,7 +816,8 @@ public class MmsDatabase extends MessagingDatabase {
|
|
|
|
|
|
|
|
|
|
private Optional<InsertResult> insertMessageInbox(IncomingMediaMessage retrieved,
|
|
|
|
|
String contentLocation,
|
|
|
|
|
long threadId, long mailbox)
|
|
|
|
|
long threadId, long mailbox,
|
|
|
|
|
long serverTimestamp)
|
|
|
|
|
throws MmsException
|
|
|
|
|
{
|
|
|
|
|
if (threadId == -1 || retrieved.isGroupMessage()) {
|
|
|
|
@ -839,7 +840,13 @@ public class MmsDatabase extends MessagingDatabase {
|
|
|
|
|
contentValues.put(THREAD_ID, threadId);
|
|
|
|
|
contentValues.put(CONTENT_LOCATION, contentLocation);
|
|
|
|
|
contentValues.put(STATUS, Status.DOWNLOAD_INITIALIZED);
|
|
|
|
|
contentValues.put(DATE_RECEIVED, retrieved.getSentTimeMillis()); // Loki - This is important due to how we handle GIFs
|
|
|
|
|
// If the messages are from open groups, there will be a serverTimestamp,
|
|
|
|
|
// we use current time like a sortId of iOS as the receive time.
|
|
|
|
|
// Since the messages has been sorted by server timestamp before they are processed,
|
|
|
|
|
// the order here by actual receiving time should be correct.
|
|
|
|
|
long receiveTimestamp = serverTimestamp;
|
|
|
|
|
if (serverTimestamp == 0) { receiveTimestamp = retrieved.getSentTimeMillis(); }
|
|
|
|
|
contentValues.put(DATE_RECEIVED, receiveTimestamp); // Loki - This is important due to how we handle GIFs
|
|
|
|
|
contentValues.put(PART_COUNT, retrieved.getAttachments().size());
|
|
|
|
|
contentValues.put(SUBSCRIPTION_ID, retrieved.getSubscriptionId());
|
|
|
|
|
contentValues.put(EXPIRES_IN, retrieved.getExpiresIn());
|
|
|
|
@ -893,11 +900,11 @@ public class MmsDatabase extends MessagingDatabase {
|
|
|
|
|
type |= Types.EXPIRATION_TIMER_UPDATE_BIT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return insertMessageInbox(retrieved, contentLocation, threadId, type);
|
|
|
|
|
return insertMessageInbox(retrieved, contentLocation, threadId, type, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Optional<InsertResult> insertSecureDecryptedMessageInbox(IncomingMediaMessage retrieved, long threadId)
|
|
|
|
|
throws MmsException
|
|
|
|
|
public Optional<InsertResult> insertSecureDecryptedMessageInbox(IncomingMediaMessage retrieved, long threadId, long serverTimestamp)
|
|
|
|
|
throws MmsException
|
|
|
|
|
{
|
|
|
|
|
long type = Types.BASE_INBOX_TYPE | Types.SECURE_MESSAGE_BIT;
|
|
|
|
|
|
|
|
|
@ -909,7 +916,13 @@ public class MmsDatabase extends MessagingDatabase {
|
|
|
|
|
type |= Types.EXPIRATION_TIMER_UPDATE_BIT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return insertMessageInbox(retrieved, "", threadId, type);
|
|
|
|
|
return insertMessageInbox(retrieved, "", threadId, type, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Optional<InsertResult> insertSecureDecryptedMessageInbox(IncomingMediaMessage retrieved, long threadId)
|
|
|
|
|
throws MmsException
|
|
|
|
|
{
|
|
|
|
|
return insertSecureDecryptedMessageInbox(retrieved, threadId, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Pair<Long, Long> insertMessageInbox(@NonNull NotificationInd notification, int subscriptionId) {
|
|
|
|
|