From 792d4a5939b4a55b75c08f3aa310edb88c35f78b Mon Sep 17 00:00:00 2001 From: FeuRenard Date: Thu, 4 Aug 2016 00:24:21 +0200 Subject: [PATCH] Resize group images Fixes #5461 Closes #5597 // FREEBIE --- .../securesms/jobs/PushGroupSendJob.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index e5e74ad7a5..49d65da996 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -4,6 +4,7 @@ import android.content.Context; import android.util.Log; import org.thoughtcrime.securesms.ApplicationContext; +import org.thoughtcrime.securesms.attachments.Attachment; import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.MmsDatabase; @@ -11,6 +12,7 @@ import org.thoughtcrime.securesms.database.NoSuchMessageException; import org.thoughtcrime.securesms.database.documents.NetworkFailure; import org.thoughtcrime.securesms.dependencies.InjectableType; import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement; +import org.thoughtcrime.securesms.mms.MediaConstraints; import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingMediaMessage; import org.thoughtcrime.securesms.recipients.Recipient; @@ -141,10 +143,11 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { throws IOException, RecipientFormattingException, InvalidNumberException, EncapsulatedExceptions, UndeliverableMessageException { - SignalServiceMessageSender messageSender = messageSenderFactory.create(); - byte[] groupId = GroupUtil.getDecodedId(message.getRecipients().getPrimaryRecipient().getNumber()); - Recipients recipients = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupId, false); - List attachments = getAttachmentsFor(masterSecret, message.getAttachments()); + SignalServiceMessageSender messageSender = messageSenderFactory.create(); + byte[] groupId = GroupUtil.getDecodedId(message.getRecipients().getPrimaryRecipient().getNumber()); + Recipients recipients = DatabaseFactory.getGroupDatabase(context).getGroupMembers(groupId, false); + List scaledAttachments = scaleAttachments(masterSecret, MediaConstraints.PUSH_CONSTRAINTS, message.getAttachments()); + List attachmentStreams = getAttachmentsFor(masterSecret, scaledAttachments); List addresses; if (filterRecipientId >= 0) addresses = getPushAddresses(filterRecipientId); @@ -153,7 +156,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { if (message.isGroup()) { OutgoingGroupMediaMessage groupMessage = (OutgoingGroupMediaMessage) message; GroupContext groupContext = groupMessage.getGroupContext(); - SignalServiceAttachment avatar = attachments.isEmpty() ? null : attachments.get(0); + SignalServiceAttachment avatar = attachmentStreams.isEmpty() ? null : attachmentStreams.get(0); SignalServiceGroup.Type type = groupMessage.isGroupQuit() ? SignalServiceGroup.Type.QUIT : SignalServiceGroup.Type.UPDATE; SignalServiceGroup group = new SignalServiceGroup(type, groupId, groupContext.getName(), groupContext.getMembersList(), avatar); SignalServiceDataMessage groupDataMessage = new SignalServiceDataMessage(message.getSentTimeMillis(), group, null, null); @@ -162,7 +165,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType { } else { SignalServiceGroup group = new SignalServiceGroup(groupId); SignalServiceDataMessage groupMessage = new SignalServiceDataMessage(message.getSentTimeMillis(), group, - attachments, message.getBody(), false, + attachmentStreams, message.getBody(), false, (int)(message.getExpiresIn() / 1000), message.isExpirationUpdate());