mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 17:48:33 +00:00
Prevent attempting to send push media messages to non-phone addresses.
Prevents crash loop in #8910
This commit is contained in:
parent
5c870ca8ea
commit
03b1eb4bd5
@ -1,6 +1,7 @@
|
|||||||
package org.thoughtcrime.securesms.jobs;
|
package org.thoughtcrime.securesms.jobs;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.WorkerThread;
|
import androidx.annotation.WorkerThread;
|
||||||
|
|
||||||
@ -68,6 +69,10 @@ public class PushMediaSendJob extends PushSendJob {
|
|||||||
@WorkerThread
|
@WorkerThread
|
||||||
public static void enqueue(@NonNull Context context, @NonNull JobManager jobManager, long messageId, @NonNull Address destination) {
|
public static void enqueue(@NonNull Context context, @NonNull JobManager jobManager, long messageId, @NonNull Address destination) {
|
||||||
try {
|
try {
|
||||||
|
if (!destination.isPhone()) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||||
List<Attachment> attachments = new LinkedList<>();
|
List<Attachment> attachments = new LinkedList<>();
|
||||||
@ -200,11 +205,19 @@ public class PushMediaSendJob extends PushSendJob {
|
|||||||
throw new UndeliverableMessageException("No destination address.");
|
throw new UndeliverableMessageException("No destination address.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Address destination = message.getRecipient().getAddress();
|
||||||
|
|
||||||
|
if (!destination.isPhone()) {
|
||||||
|
if (destination.isEmail()) throw new UndeliverableMessageException("Not e164, is email");
|
||||||
|
if (destination.isGroup()) throw new UndeliverableMessageException("Not e164, is group");
|
||||||
|
throw new UndeliverableMessageException("Not e164, unknown");
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rotateSenderCertificateIfNecessary();
|
rotateSenderCertificateIfNecessary();
|
||||||
|
|
||||||
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
SignalServiceMessageSender messageSender = ApplicationDependencies.getSignalServiceMessageSender();
|
||||||
SignalServiceAddress address = getPushAddress(message.getRecipient().getAddress());
|
SignalServiceAddress address = getPushAddress(destination);
|
||||||
List<Attachment> attachments = Stream.of(message.getAttachments()).filterNot(Attachment::isSticker).toList();
|
List<Attachment> attachments = Stream.of(message.getAttachments()).filterNot(Attachment::isSticker).toList();
|
||||||
List<SignalServiceAttachment> serviceAttachments = getAttachmentPointersFor(attachments);
|
List<SignalServiceAttachment> serviceAttachments = getAttachmentPointersFor(attachments);
|
||||||
Optional<byte[]> profileKey = getProfileKey(message.getRecipient());
|
Optional<byte[]> profileKey = getProfileKey(message.getRecipient());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user