mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
clean up jobs
This commit is contained in:
parent
dee7d78acb
commit
12a2061251
@ -250,7 +250,8 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||
"MmsDownloadJob",
|
||||
"SmsSendJob",
|
||||
"SmsSentJob",
|
||||
"SmsReceiveJob");
|
||||
"SmsReceiveJob",
|
||||
"PushGroupUpdateJob");
|
||||
}
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
|
@ -12,7 +12,6 @@ import org.thoughtcrime.securesms.jobs.AttachmentUploadJob;
|
||||
import org.thoughtcrime.securesms.jobs.AvatarDownloadJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushDecryptJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushGroupSendJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushGroupUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushMediaSendJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushTextSendJob;
|
||||
import org.thoughtcrime.securesms.jobs.RequestGroupInfoJob;
|
||||
@ -33,7 +32,6 @@ import dagger.Provides;
|
||||
PushMediaSendJob.class,
|
||||
AttachmentDownloadJob.class,
|
||||
RequestGroupInfoJob.class,
|
||||
PushGroupUpdateJob.class,
|
||||
AvatarDownloadJob.class,
|
||||
RetrieveProfileAvatarJob.class,
|
||||
SendReadReceiptJob.class,
|
||||
|
@ -1,169 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.migration;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.session.libsession.messaging.jobs.Data;
|
||||
import org.session.libsignal.utilities.logging.Log;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Takes a persisted data blob stored by WorkManager and converts it to our {@link Data} class.
|
||||
*/
|
||||
final class DataMigrator {
|
||||
|
||||
private static final String TAG = Log.tag(DataMigrator.class);
|
||||
|
||||
static final Data convert(@NonNull byte[] workManagerData) {
|
||||
Map<String, Object> values = parseWorkManagerDataMap(workManagerData);
|
||||
|
||||
Data.Builder builder = new Data.Builder();
|
||||
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
|
||||
if (value == null) {
|
||||
builder.putString(entry.getKey(), null);
|
||||
} else {
|
||||
Class type = value.getClass();
|
||||
|
||||
if (type == String.class) {
|
||||
builder.putString(entry.getKey(), (String) value);
|
||||
} else if (type == String[].class) {
|
||||
builder.putStringArray(entry.getKey(), (String[]) value);
|
||||
} else if (type == Integer.class || type == int.class) {
|
||||
builder.putInt(entry.getKey(), (int) value);
|
||||
} else if (type == Integer[].class || type == int[].class) {
|
||||
builder.putIntArray(entry.getKey(), convertToIntArray(value, type));
|
||||
} else if (type == Long.class || type == long.class) {
|
||||
builder.putLong(entry.getKey(), (long) value);
|
||||
} else if (type == Long[].class || type == long[].class) {
|
||||
builder.putLongArray(entry.getKey(), convertToLongArray(value, type));
|
||||
} else if (type == Float.class || type == float.class) {
|
||||
builder.putFloat(entry.getKey(), (float) value);
|
||||
} else if (type == Float[].class || type == float[].class) {
|
||||
builder.putFloatArray(entry.getKey(), convertToFloatArray(value, type));
|
||||
} else if (type == Double.class || type == double.class) {
|
||||
builder.putDouble(entry.getKey(), (double) value);
|
||||
} else if (type == Double[].class || type == double[].class) {
|
||||
builder.putDoubleArray(entry.getKey(), convertToDoubleArray(value, type));
|
||||
} else if (type == Boolean.class || type == boolean.class) {
|
||||
builder.putBoolean(entry.getKey(), (boolean) value);
|
||||
} else if (type == Boolean[].class || type == boolean[].class) {
|
||||
builder.putBooleanArray(entry.getKey(), convertToBooleanArray(value, type));
|
||||
} else {
|
||||
Log.w(TAG, "Encountered unexpected type '" + type + "'. Skipping.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private static @NonNull Map<String, Object> parseWorkManagerDataMap(@NonNull byte[] bytes) throws IllegalStateException {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
|
||||
ObjectInputStream objectInputStream = null;
|
||||
|
||||
try {
|
||||
objectInputStream = new ObjectInputStream(inputStream);
|
||||
|
||||
for (int i = objectInputStream.readInt(); i > 0; i--) {
|
||||
map.put(objectInputStream.readUTF(), objectInputStream.readObject());
|
||||
}
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
Log.w(TAG, "Failed to read WorkManager data.", e);
|
||||
} finally {
|
||||
try {
|
||||
inputStream.close();
|
||||
|
||||
if (objectInputStream != null) {
|
||||
objectInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to close streams after reading WorkManager data.", e);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static int[] convertToIntArray(Object value, Class type) {
|
||||
if (type == int[].class) {
|
||||
return (int[]) value;
|
||||
}
|
||||
|
||||
Integer[] casted = (Integer[]) value;
|
||||
int[] output = new int[casted.length];
|
||||
|
||||
for (int i = 0; i < casted.length; i++) {
|
||||
output[i] = casted[i];
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private static long[] convertToLongArray(Object value, Class type) {
|
||||
if (type == long[].class) {
|
||||
return (long[]) value;
|
||||
}
|
||||
|
||||
Long[] casted = (Long[]) value;
|
||||
long[] output = new long[casted.length];
|
||||
|
||||
for (int i = 0; i < casted.length; i++) {
|
||||
output[i] = casted[i];
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private static float[] convertToFloatArray(Object value, Class type) {
|
||||
if (type == float[].class) {
|
||||
return (float[]) value;
|
||||
}
|
||||
|
||||
Float[] casted = (Float[]) value;
|
||||
float[] output = new float[casted.length];
|
||||
|
||||
for (int i = 0; i < casted.length; i++) {
|
||||
output[i] = casted[i];
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private static double[] convertToDoubleArray(Object value, Class type) {
|
||||
if (type == double[].class) {
|
||||
return (double[]) value;
|
||||
}
|
||||
|
||||
Double[] casted = (Double[]) value;
|
||||
double[] output = new double[casted.length];
|
||||
|
||||
for (int i = 0; i < casted.length; i++) {
|
||||
output[i] = casted[i];
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private static boolean[] convertToBooleanArray(Object value, Class type) {
|
||||
if (type == boolean[].class) {
|
||||
return (boolean[]) value;
|
||||
}
|
||||
|
||||
Boolean[] casted = (Boolean[]) value;
|
||||
boolean[] output = new boolean[casted.length];
|
||||
|
||||
for (int i = 0; i < casted.length; i++) {
|
||||
output[i] = casted[i];
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ public final class JobManagerFactories {
|
||||
put(PushContentReceiveJob.KEY, new PushContentReceiveJob.Factory());
|
||||
put(PushDecryptJob.KEY, new PushDecryptJob.Factory());
|
||||
put(PushGroupSendJob.KEY, new PushGroupSendJob.Factory());
|
||||
put(PushGroupUpdateJob.KEY, new PushGroupUpdateJob.Factory());
|
||||
put(PushMediaSendJob.KEY, new PushMediaSendJob.Factory());
|
||||
put(PushTextSendJob.KEY, new PushTextSendJob.Factory());
|
||||
put(RequestGroupInfoJob.KEY, new RequestGroupInfoJob.Factory());
|
||||
|
@ -24,10 +24,8 @@ import org.session.libsession.messaging.sending_receiving.linkpreview.LinkPrevie
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.Attachment;
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment;
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.PointerAttachment;
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.UriAttachment;
|
||||
import org.session.libsession.messaging.sending_receiving.sharecontacts.Contact;
|
||||
import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel;
|
||||
import org.session.libsession.messaging.sending_receiving.attachments.StickerLocator;
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.messaging.sending_receiving.notifications.MessageNotifier;
|
||||
@ -57,7 +55,6 @@ import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
||||
import org.thoughtcrime.securesms.loki.api.SessionProtocolImpl;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiAPIDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiMessageDatabase;
|
||||
import org.thoughtcrime.securesms.loki.database.LokiThreadDatabase;
|
||||
import org.thoughtcrime.securesms.loki.protocol.ClosedGroupsProtocolV2;
|
||||
import org.thoughtcrime.securesms.loki.protocol.MultiDeviceProtocol;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
|
||||
@ -67,7 +64,6 @@ import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.sms.IncomingEncryptedMessage;
|
||||
import org.thoughtcrime.securesms.sms.IncomingEndSessionMessage;
|
||||
import org.thoughtcrime.securesms.sms.IncomingTextMessage;
|
||||
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
@ -259,10 +255,6 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
}
|
||||
|
||||
resetRecipientToPush(Recipient.from(context, Address.fromSerialized(content.getSender()), false));
|
||||
|
||||
// if (envelope.isPreKeySignalMessage()) {
|
||||
// ApplicationContext.getInstance(context).getJobManager().add(new RefreshPreKeysJob());
|
||||
// }
|
||||
} catch (ProtocolInvalidMessageException e) {
|
||||
Log.w(TAG, e);
|
||||
if (!isPushNotification) { // This can be triggered if a PN encrypted with an old session comes in after the user performed a session reset
|
||||
@ -678,12 +670,9 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
if (!TextSecurePreferences.isTypingIndicatorsEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Recipient author = Recipient.from(context, Address.fromSerialized(content.getSender()), false);
|
||||
|
||||
long threadId;
|
||||
|
||||
author = getMessageMasterDestination(content.getSender());
|
||||
Recipient author = getMessageMasterDestination(content.getSender());
|
||||
threadId = DatabaseFactory.getThreadDatabase(context).getOrCreateThreadIdFor(author);
|
||||
|
||||
if (threadId <= 0) {
|
||||
|
@ -15,9 +15,7 @@ import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.session.libsession.utilities.GroupUtil;
|
||||
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsignal.service.api.crypto.UnidentifiedAccess;
|
||||
import org.session.libsignal.service.internal.push.SignalServiceProtos;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
@ -35,10 +33,8 @@ import org.thoughtcrime.securesms.mms.MmsException;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
import org.session.libsignal.service.api.SignalServiceMessageSender;
|
||||
import org.session.libsignal.service.api.crypto.UntrustedIdentityException;
|
||||
import org.session.libsignal.service.api.messages.SendMessageResult;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceAttachment;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceDataMessage;
|
||||
@ -138,16 +134,13 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
@Override
|
||||
public void onPushSend()
|
||||
throws IOException, MmsException, NoSuchMessageException, RetryLaterException
|
||||
throws MmsException, NoSuchMessageException
|
||||
{
|
||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
List<NetworkFailure> existingNetworkFailures = message.getNetworkFailures();
|
||||
List<IdentityKeyMismatch> existingIdentityMismatches = message.getIdentityKeyMismatches();
|
||||
|
||||
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||
SignalServiceAddress localAddress = new SignalServiceAddress(userPublicKey);
|
||||
|
||||
if (database.isSent(messageId)) {
|
||||
log(TAG, "Message " + messageId + " was already sent. Ignoring.");
|
||||
return;
|
||||
@ -231,7 +224,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
private List<SendMessageResult> deliver(OutgoingMediaMessage message, @NonNull List<Address> destinations)
|
||||
throws IOException, UntrustedIdentityException, UndeliverableMessageException {
|
||||
throws IOException {
|
||||
|
||||
Address address = message.getRecipient().getAddress();
|
||||
|
||||
@ -267,7 +260,7 @@ public class PushGroupSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
}
|
||||
|
||||
public SignalServiceDataMessage.Builder getDataMessage(Address address, OutgoingMediaMessage message) throws IOException {
|
||||
public SignalServiceDataMessage.Builder getDataMessage(Address address, OutgoingMediaMessage message) {
|
||||
|
||||
SignalServiceGroup.GroupType groupType = address.isOpenGroup() ? SignalServiceGroup.GroupType.PUBLIC_CHAT : SignalServiceGroup.GroupType.SIGNAL;
|
||||
|
||||
|
@ -1,152 +0,0 @@
|
||||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.session.libsession.messaging.jobs.Data;
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.session.libsession.messaging.threads.GroupRecord;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.utilities.GroupUtil;
|
||||
|
||||
import org.thoughtcrime.securesms.crypto.UnidentifiedAccessUtil;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.session.libsignal.utilities.logging.Log;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
import org.session.libsignal.service.api.SignalServiceMessageSender;
|
||||
import org.session.libsignal.service.api.crypto.UntrustedIdentityException;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceAttachment;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceAttachmentStream;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceDataMessage;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceGroup;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceGroup.Type;
|
||||
import org.session.libsignal.service.api.push.SignalServiceAddress;
|
||||
import org.session.libsignal.service.api.push.exceptions.PushNetworkException;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushGroupUpdateJob extends BaseJob implements InjectableType {
|
||||
|
||||
public static final String KEY = "PushGroupUpdateJob";
|
||||
|
||||
private static final String TAG = PushGroupUpdateJob.class.getSimpleName();
|
||||
|
||||
private static final String KEY_SOURCE = "source";
|
||||
private static final String KEY_GROUP_ID = "group_id";
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
private String source;
|
||||
private byte[] groupId;
|
||||
|
||||
public PushGroupUpdateJob(String source, byte[] groupId) {
|
||||
this(new Job.Parameters.Builder()
|
||||
.addConstraint(NetworkConstraint.KEY)
|
||||
.setLifespan(TimeUnit.DAYS.toMillis(1))
|
||||
.setMaxAttempts(Parameters.UNLIMITED)
|
||||
.build(),
|
||||
source,
|
||||
groupId);
|
||||
}
|
||||
|
||||
private PushGroupUpdateJob(@NonNull Job.Parameters parameters, String source, byte[] groupId) {
|
||||
super(parameters);
|
||||
|
||||
this.source = source;
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull
|
||||
Data serialize() {
|
||||
return new Data.Builder().putString(KEY_SOURCE, source)
|
||||
.putString(KEY_GROUP_ID, GroupUtil.getEncodedClosedGroupID(groupId))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String getFactoryKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException, UntrustedIdentityException {
|
||||
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
|
||||
Optional<GroupRecord> record = groupDatabase.getGroup(GroupUtil.getEncodedClosedGroupID(groupId));
|
||||
SignalServiceAttachment avatar = null;
|
||||
|
||||
if (record == null) {
|
||||
Log.w(TAG, "No information for group record info request: " + new String(groupId));
|
||||
return;
|
||||
}
|
||||
|
||||
if (record.get().getAvatar() != null) {
|
||||
avatar = SignalServiceAttachmentStream.newStreamBuilder()
|
||||
.withContentType("image/jpeg")
|
||||
.withStream(new ByteArrayInputStream(record.get().getAvatar()))
|
||||
.withLength(record.get().getAvatar().length)
|
||||
.build();
|
||||
}
|
||||
|
||||
List<String> members = new LinkedList<>();
|
||||
for (Address member : record.get().getMembers()) {
|
||||
members.add(member.serialize());
|
||||
}
|
||||
|
||||
List<String> admins = new LinkedList<>();
|
||||
for (Address admin : record.get().getAdmins()) {
|
||||
admins.add(admin.serialize());
|
||||
}
|
||||
|
||||
SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE)
|
||||
.withAvatar(avatar)
|
||||
.withId(groupId, SignalServiceGroup.GroupType.SIGNAL)
|
||||
.withMembers(members)
|
||||
.withAdmins(admins)
|
||||
.withName(record.get().getTitle())
|
||||
.build();
|
||||
|
||||
Address groupAddress = Address.fromSerialized(GroupUtil.getEncodedClosedGroupID(groupId));
|
||||
Recipient groupRecipient = Recipient.from(context, groupAddress, false);
|
||||
|
||||
SignalServiceDataMessage message = SignalServiceDataMessage.newBuilder()
|
||||
.asGroupMessage(groupContext)
|
||||
.withTimestamp(System.currentTimeMillis())
|
||||
.withExpiration(groupRecipient.getExpireMessages())
|
||||
.build();
|
||||
|
||||
messageSender.sendMessage(0, new SignalServiceAddress(source),
|
||||
UnidentifiedAccessUtil.getAccessFor(context, Recipient.from(context, Address.fromSerialized(source), false)),
|
||||
message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(@NonNull Exception e) {
|
||||
Log.w(TAG, e);
|
||||
return e instanceof PushNetworkException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCanceled() {
|
||||
|
||||
}
|
||||
|
||||
public static final class Factory implements Job.Factory<PushGroupUpdateJob> {
|
||||
@Override
|
||||
public @NonNull PushGroupUpdateJob create(@NonNull Parameters parameters, @NonNull Data data) {
|
||||
return new PushGroupUpdateJob(parameters,
|
||||
data.getString(KEY_SOURCE),
|
||||
GroupUtil.getDecodedGroupIDAsData(data.getString(KEY_GROUP_ID)));
|
||||
}
|
||||
}
|
||||
}
|
@ -66,10 +66,6 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
private long templateMessageId;
|
||||
private Address destination;
|
||||
|
||||
public PushMediaSendJob(long messageId, Address destination) {
|
||||
this(messageId, messageId, destination);
|
||||
}
|
||||
|
||||
public PushMediaSendJob(long templateMessageId, long messageId, Address destination) {
|
||||
this(constructParameters(destination), templateMessageId, messageId, destination);
|
||||
}
|
||||
@ -197,12 +193,6 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
log(TAG, "Sent message: " + messageId);
|
||||
|
||||
} catch (InsecureFallbackApprovalException ifae) {
|
||||
warn(TAG, "Failure", ifae);
|
||||
if (messageId >= 0) {
|
||||
database.markAsPendingInsecureSmsFallback(messageId);
|
||||
notifyMediaMessageDeliveryFailed(context, messageId);
|
||||
}
|
||||
} catch (SnodeAPI.Error e) {
|
||||
Log.d("Loki", "Couldn't send message due to error: " + e.getDescription());
|
||||
if (messageId >= 0) {
|
||||
@ -228,7 +218,7 @@ public class PushMediaSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
|
||||
private boolean deliver(OutgoingMediaMessage message)
|
||||
throws RetryLaterException, InsecureFallbackApprovalException, UndeliverableMessageException, SnodeAPI.Error
|
||||
throws RetryLaterException, UndeliverableMessageException, SnodeAPI.Error
|
||||
{
|
||||
try {
|
||||
Recipient recipient = Recipient.from(context, destination, false);
|
||||
|
@ -1,11 +1,9 @@
|
||||
package org.thoughtcrime.securesms.jobs;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.session.libsession.messaging.threads.Address;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.database.MessagingDatabase.SyncMessageId;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.session.libsignal.utilities.logging.Log;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
|
@ -89,19 +89,6 @@ public abstract class PushSendJob extends SendJob {
|
||||
return new SignalServiceAddress(address.toString(), Optional.fromNullable(relay));
|
||||
}
|
||||
|
||||
protected List<SignalServiceAttachment> getAttachmentsFor(List<Attachment> parts) {
|
||||
List<SignalServiceAttachment> attachments = new LinkedList<>();
|
||||
|
||||
for (final Attachment attachment : parts) {
|
||||
SignalServiceAttachment converted = getAttachmentFor(attachment);
|
||||
if (converted != null) {
|
||||
attachments.add(converted);
|
||||
}
|
||||
}
|
||||
|
||||
return attachments;
|
||||
}
|
||||
|
||||
protected SignalServiceAttachment getAttachmentFor(Attachment attachment) {
|
||||
try {
|
||||
if (attachment.getDataUri() == null || attachment.getSize() == 0) throw new IOException("Assertion failed, outgoing attachment has no data!");
|
||||
|
@ -26,7 +26,6 @@ import org.thoughtcrime.securesms.transport.InsecureFallbackApprovalException;
|
||||
import org.thoughtcrime.securesms.transport.RetryLaterException;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
import org.session.libsignal.service.api.SignalServiceMessageSender;
|
||||
import org.session.libsignal.service.api.crypto.UntrustedIdentityException;
|
||||
import org.session.libsignal.service.api.messages.SendMessageResult;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceDataMessage;
|
||||
import org.session.libsignal.service.api.push.SignalServiceAddress;
|
||||
@ -140,19 +139,6 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
|
||||
log(TAG, "Sent message: " + templateMessageId + (hasSameDestination ? "" : "to a linked device."));
|
||||
|
||||
} catch (InsecureFallbackApprovalException e) {
|
||||
warn(TAG, "Couldn't send message due to error: ", e);
|
||||
if (messageId >= 0) {
|
||||
database.markAsPendingInsecureSmsFallback(record.getId());
|
||||
ApplicationContext.getInstance(context).messageNotifier.notifyMessageDeliveryFailed(context, record.getRecipient(), record.getThreadId());
|
||||
}
|
||||
} catch (UntrustedIdentityException e) {
|
||||
warn(TAG, "Couldn't send message due to error: ", e);
|
||||
if (messageId >= 0) {
|
||||
database.addMismatchedIdentity(record.getId(), Address.fromSerialized(e.getE164Number()), e.getIdentityKey());
|
||||
database.markAsSentFailed(record.getId());
|
||||
database.markAsPush(record.getId());
|
||||
}
|
||||
} catch (SnodeAPI.Error e) {
|
||||
Log.d("Loki", "Couldn't send message due to error: " + e.getDescription());
|
||||
if (messageId >= 0) {
|
||||
@ -183,8 +169,7 @@ public class PushTextSendJob extends PushSendJob implements InjectableType {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean deliver(SmsMessageRecord message)
|
||||
throws UntrustedIdentityException, InsecureFallbackApprovalException, RetryLaterException, SnodeAPI.Error
|
||||
private boolean deliver(SmsMessageRecord message) throws RetryLaterException, SnodeAPI.Error
|
||||
{
|
||||
try {
|
||||
String userPublicKey = TextSecurePreferences.getLocalNumber(context);
|
||||
|
@ -12,7 +12,6 @@ import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.session.libsignal.service.api.SignalServiceMessageSender;
|
||||
import org.session.libsignal.service.api.crypto.UntrustedIdentityException;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceDataMessage;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceGroup;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceGroup.Type;
|
||||
@ -71,7 +70,7 @@ public class RequestGroupInfoJob extends BaseJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException, UntrustedIdentityException {
|
||||
public void onRun() throws IOException {
|
||||
SignalServiceGroup group = SignalServiceGroup.newBuilder(Type.REQUEST_INFO)
|
||||
.withId(groupId, SignalServiceGroup.GroupType.SIGNAL)
|
||||
.build();
|
||||
|
@ -12,7 +12,6 @@ import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
|
||||
import org.session.libsignal.utilities.logging.Log;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsignal.service.api.SignalServiceMessageSender;
|
||||
import org.session.libsignal.service.api.crypto.UntrustedIdentityException;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceReceiptMessage;
|
||||
import org.session.libsignal.service.api.push.SignalServiceAddress;
|
||||
import org.session.libsignal.service.api.push.exceptions.PushNetworkException;
|
||||
@ -78,7 +77,7 @@ public class SendDeliveryReceiptJob extends BaseJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException, UntrustedIdentityException {
|
||||
public void onRun() throws IOException {
|
||||
Log.d("Loki", "Sending delivery receipt.");
|
||||
SignalServiceAddress remoteAddress = new SignalServiceAddress(address);
|
||||
SignalServiceReceiptMessage receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.DELIVERY,
|
||||
|
@ -45,36 +45,6 @@ public abstract class SendJob extends BaseJob {
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Attachment> scaleAndStripExifFromAttachments(@NonNull MediaConstraints constraints,
|
||||
@NonNull List<Attachment> attachments)
|
||||
throws UndeliverableMessageException
|
||||
{
|
||||
AttachmentDatabase attachmentDatabase = DatabaseFactory.getAttachmentDatabase(context);
|
||||
List<Attachment> results = new LinkedList<>();
|
||||
|
||||
for (Attachment attachment : attachments) {
|
||||
try {
|
||||
if (constraints.isSatisfied(context, attachment)) {
|
||||
if (MediaUtil.isJpeg(attachment)) {
|
||||
MediaStream stripped = constraints.getResizedMedia(context, attachment);
|
||||
results.add(attachmentDatabase.updateAttachmentData(attachment, stripped));
|
||||
} else {
|
||||
results.add(attachment);
|
||||
}
|
||||
} else if (constraints.canResize(attachment)) {
|
||||
MediaStream resized = constraints.getResizedMedia(context, attachment);
|
||||
results.add(attachmentDatabase.updateAttachmentData(attachment, resized));
|
||||
} else {
|
||||
throw new UndeliverableMessageException("Size constraints could not be met!");
|
||||
}
|
||||
} catch (IOException | MmsException e) {
|
||||
throw new UndeliverableMessageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
protected void log(@NonNull String tag, @NonNull String message) {
|
||||
Log.i(tag, JobLogger.format(this, message));
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import org.session.libsignal.utilities.logging.Log;
|
||||
import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.utilities.TextSecurePreferences;
|
||||
import org.session.libsignal.service.api.SignalServiceMessageSender;
|
||||
import org.session.libsignal.service.api.crypto.UntrustedIdentityException;
|
||||
import org.session.libsignal.service.api.messages.SignalServiceReceiptMessage;
|
||||
import org.session.libsignal.service.api.push.SignalServiceAddress;
|
||||
import org.session.libsignal.service.api.push.exceptions.PushNetworkException;
|
||||
@ -84,7 +83,7 @@ public class SendReadReceiptJob extends BaseJob implements InjectableType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException, UntrustedIdentityException {
|
||||
public void onRun() throws IOException {
|
||||
if (!TextSecurePreferences.isReadReceiptsEnabled(context) || messageIds.isEmpty()) return;
|
||||
|
||||
SignalServiceAddress remoteAddress = new SignalServiceAddress(address);
|
||||
|
Loading…
Reference in New Issue
Block a user