Enforce media constraints on group messages

Fixes #2913
Closes #2917

// FREEBIE
This commit is contained in:
Jake McGinty 2015-04-07 14:16:05 -07:00 committed by Moxie Marlinspike
parent 1f9a0fab3c
commit e4e24f7ae5

View File

@ -11,11 +11,13 @@ import org.thoughtcrime.securesms.database.NoSuchMessageException;
import org.thoughtcrime.securesms.database.documents.NetworkFailure; import org.thoughtcrime.securesms.database.documents.NetworkFailure;
import org.thoughtcrime.securesms.dependencies.InjectableType; import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement; import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement;
import org.thoughtcrime.securesms.mms.MediaConstraints;
import org.thoughtcrime.securesms.mms.PartParser; import org.thoughtcrime.securesms.mms.PartParser;
import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory; import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientFormattingException; import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
import org.thoughtcrime.securesms.util.Base64; import org.thoughtcrime.securesms.util.Base64;
import org.thoughtcrime.securesms.util.GroupUtil; import org.thoughtcrime.securesms.util.GroupUtil;
import org.whispersystems.jobqueue.JobParameters; import org.whispersystems.jobqueue.JobParameters;
@ -83,7 +85,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
database.markAsPush(messageId); database.markAsPush(messageId);
database.markAsSecure(messageId); database.markAsSecure(messageId);
database.markAsSent(messageId, "push".getBytes(), 0); database.markAsSent(messageId, "push".getBytes(), 0);
} catch (InvalidNumberException | RecipientFormattingException e) { } catch (InvalidNumberException | RecipientFormattingException | UndeliverableMessageException e) {
Log.w(TAG, e); Log.w(TAG, e);
database.markAsSentFailed(messageId); database.markAsSentFailed(messageId);
notifyMediaMessageDeliveryFailed(context, messageId); notifyMediaMessageDeliveryFailed(context, messageId);
@ -126,8 +128,11 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
} }
private void deliver(MasterSecret masterSecret, SendReq message, long filterRecipientId) private void deliver(MasterSecret masterSecret, SendReq message, long filterRecipientId)
throws IOException, RecipientFormattingException, InvalidNumberException, EncapsulatedExceptions throws IOException, RecipientFormattingException, InvalidNumberException,
EncapsulatedExceptions, UndeliverableMessageException
{ {
message = getResolvedMessage(masterSecret, message, MediaConstraints.PUSH_CONSTRAINTS, false);
TextSecureMessageSender messageSender = messageSenderFactory.create(masterSecret); TextSecureMessageSender messageSender = messageSenderFactory.create(masterSecret);
byte[] groupId = GroupUtil.getDecodedId(message.getTo()[0].getString()); byte[] groupId = GroupUtil.getDecodedId(message.getTo()[0].getString());
Recipients recipients = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupId, false); Recipients recipients = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupId, false);