kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix possible crash in ProfileKeySendJob if given an invalid threadId.
rodzic
e413ee4ed9
commit
be2ed8989f
|
@ -1153,7 +1153,6 @@ public class ThreadDatabase extends Database {
|
|||
SQLiteDatabase db = databaseHelper.getSignalReadableDatabase();
|
||||
|
||||
try (Cursor cursor = db.query(TABLE_NAME, RECIPIENT_ID_PROJECTION, ID_WHERE, SqlUtil.buildArgs(threadId), null, null, null)) {
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
return RecipientId.from(cursor.getLong(cursor.getColumnIndexOrThrow(RECIPIENT_ID)));
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.jobs;
|
|||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
@ -45,13 +46,16 @@ public class ProfileKeySendJob extends BaseJob {
|
|||
*
|
||||
* @param queueLimits True if you only want one of these to be run per person after decryptions
|
||||
* are drained, otherwise false.
|
||||
*
|
||||
* @return The job that is created, or null if the threadId provided was invalid.
|
||||
*/
|
||||
@WorkerThread
|
||||
public static ProfileKeySendJob create(@NonNull Context context, long threadId, boolean queueLimits) {
|
||||
public static @Nullable ProfileKeySendJob create(long threadId, boolean queueLimits) {
|
||||
Recipient conversationRecipient = SignalDatabase.threads().getRecipientForThreadId(threadId);
|
||||
|
||||
if (conversationRecipient == null) {
|
||||
throw new AssertionError("We have a thread but no recipient!");
|
||||
Log.w(TAG, "Thread no longer valid! Aborting.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (conversationRecipient.isPushV2Group()) {
|
||||
|
|
|
@ -144,7 +144,7 @@ final class MessageRequestRepository {
|
|||
RecipientDatabase recipientDatabase = SignalDatabase.recipients();
|
||||
recipientDatabase.setProfileSharing(liveRecipient.getId(), true);
|
||||
|
||||
MessageSender.sendProfileKey(context, threadId);
|
||||
MessageSender.sendProfileKey(threadId);
|
||||
|
||||
List<MessageDatabase.MarkedMessageInfo> messageIds = SignalDatabase.threads().setEntireThreadRead(threadId);
|
||||
ApplicationDependencies.getMessageNotifier().updateNotification(context);
|
||||
|
|
|
@ -325,10 +325,14 @@ public final class MessageContentProcessor {
|
|||
.enqueue();
|
||||
} else if (!threadRecipient.isGroup()) {
|
||||
Log.i(TAG, "Message was to a 1:1. Ensuring this user has our profile key.");
|
||||
ApplicationDependencies.getJobManager()
|
||||
.startChain(new RefreshAttributesJob(false))
|
||||
.then(ProfileKeySendJob.create(context, SignalDatabase.threads().getOrCreateThreadIdFor(threadRecipient), true))
|
||||
.enqueue();
|
||||
ProfileKeySendJob profileSendJob = ProfileKeySendJob.create(SignalDatabase.threads().getOrCreateThreadIdFor(threadRecipient), true);
|
||||
|
||||
if (profileSendJob != null) {
|
||||
ApplicationDependencies.getJobManager()
|
||||
.startChain(new RefreshAttributesJob(false))
|
||||
.then(profileSendJob)
|
||||
.enqueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,8 +102,11 @@ public class MessageSender {
|
|||
* Suitable for a 1:1 conversation or a GV1 group only.
|
||||
*/
|
||||
@WorkerThread
|
||||
public static void sendProfileKey(final Context context, final long threadId) {
|
||||
ApplicationDependencies.getJobManager().add(ProfileKeySendJob.create(context, threadId, false));
|
||||
public static void sendProfileKey(final long threadId) {
|
||||
ProfileKeySendJob job = ProfileKeySendJob.create(threadId, false);
|
||||
if (job != null) {
|
||||
ApplicationDependencies.getJobManager().add(job);
|
||||
}
|
||||
}
|
||||
|
||||
public static long send(final Context context,
|
||||
|
|
Ładowanie…
Reference in New Issue