diff --git a/src/org/thoughtcrime/securesms/database/MmsDatabase.java b/src/org/thoughtcrime/securesms/database/MmsDatabase.java index 0519681944..0e3aea9db9 100644 --- a/src/org/thoughtcrime/securesms/database/MmsDatabase.java +++ b/src/org/thoughtcrime/securesms/database/MmsDatabase.java @@ -519,7 +519,8 @@ public class MmsDatabase extends MessagingDatabase { cursor = rawQuery(RAW_ID_WHERE, new String[] {String.valueOf(messageId)}); if (cursor != null && cursor.moveToNext()) { - return Optional.of(new MmsNotificationInfo(cursor.getString(cursor.getColumnIndexOrThrow(CONTENT_LOCATION)), + return Optional.of(new MmsNotificationInfo(cursor.getString(cursor.getColumnIndexOrThrow(ADDRESS)), + cursor.getString(cursor.getColumnIndexOrThrow(CONTENT_LOCATION)), cursor.getString(cursor.getColumnIndexOrThrow(TRANSACTION_ID)), cursor.getInt(cursor.getColumnIndexOrThrow(SUBSCRIPTION_ID)))); } else { @@ -1002,11 +1003,13 @@ public class MmsDatabase extends MessagingDatabase { } public static class MmsNotificationInfo { - private final String contentLocation; - private final String transactionId; - private final int subscriptionId; + private final Address from; + private final String contentLocation; + private final String transactionId; + private final int subscriptionId; - public MmsNotificationInfo(String contentLocation, String transactionId, int subscriptionId) { + MmsNotificationInfo(@Nullable String from, String contentLocation, String transactionId, int subscriptionId) { + this.from = from == null ? null : Address.fromSerialized(from); this.contentLocation = contentLocation; this.transactionId = transactionId; this.subscriptionId = subscriptionId; @@ -1023,6 +1026,10 @@ public class MmsDatabase extends MessagingDatabase { public int getSubscriptionId() { return subscriptionId; } + + public @Nullable Address getFrom() { + return from; + } } public class OutgoingMessageReader { diff --git a/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java b/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java index b5255531da..1adb6e011b 100644 --- a/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.jobs; import android.content.Context; import android.net.Uri; +import android.support.annotation.Nullable; import android.util.Log; import com.google.android.mms.pdu_alt.CharacterSets; @@ -115,7 +116,7 @@ public class MmsDownloadJob extends MasterSecretJob { throw new MmsException("RetrieveConf was null"); } - storeRetrievedMms(masterSecret, contentLocation, messageId, threadId, retrieveConf, notification.get().getSubscriptionId()); + storeRetrievedMms(masterSecret, contentLocation, messageId, threadId, retrieveConf, notification.get().getSubscriptionId(), notification.get().getFrom()); } catch (ApnUnavailableException e) { Log.w(TAG, e); handleDownloadError(masterSecret, messageId, threadId, MmsDatabase.Status.DOWNLOAD_APN_UNAVAILABLE, @@ -163,7 +164,7 @@ public class MmsDownloadJob extends MasterSecretJob { private void storeRetrievedMms(MasterSecret masterSecret, String contentLocation, long messageId, long threadId, RetrieveConf retrieved, - int subscriptionId) + int subscriptionId, @Nullable Address notificationFrom) throws MmsException, NoSessionException, DuplicateMessageException, InvalidMessageException, LegacyMessageException { @@ -178,6 +179,8 @@ public class MmsDownloadJob extends MasterSecretJob { if (retrieved.getFrom() != null) { from = Address.fromExternal(context, Util.toIsoString(retrieved.getFrom().getTextString())); + } else if (notificationFrom != null) { + from = notificationFrom; } else { from = Address.UNKNOWN; } @@ -194,6 +197,7 @@ public class MmsDownloadJob extends MasterSecretJob { } } + members.add(from); members.add(Address.fromExternal(context, TextSecurePreferences.getLocalNumber(context))); if (retrieved.getBody() != null) {