MMS group includes the sender

Fixes #6942
// FREEBIE
master
Moxie Marlinspike 2017-09-08 11:19:57 -07:00
parent 0bd9606666
commit 989ea4042c
2 changed files with 18 additions and 7 deletions

View File

@ -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 {

View File

@ -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) {