mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 04:25:18 +00:00
Send friend request accept message back to the user.
This commit is contained in:
parent
858b34306b
commit
75a8123d1e
@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import org.thoughtcrime.securesms.gcm.FcmService;
|
||||
import org.thoughtcrime.securesms.jobs.AttachmentUploadJob;
|
||||
import org.thoughtcrime.securesms.jobs.MultiDeviceConfigurationUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.PushDecryptJob;
|
||||
import org.thoughtcrime.securesms.jobs.RefreshUnidentifiedDeliveryAbilityJob;
|
||||
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob;
|
||||
import org.thoughtcrime.securesms.jobs.TypingSendJob;
|
||||
@ -96,7 +97,8 @@ import dagger.Provides;
|
||||
MultiDeviceConfigurationUpdateJob.class,
|
||||
RefreshUnidentifiedDeliveryAbilityJob.class,
|
||||
TypingSendJob.class,
|
||||
AttachmentUploadJob.class})
|
||||
AttachmentUploadJob.class,
|
||||
PushDecryptJob.class})
|
||||
public class SignalCommunicationModule {
|
||||
|
||||
private static final String TAG = SignalCommunicationModule.class.getSimpleName();
|
||||
|
@ -54,6 +54,7 @@ import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.dependencies.InjectableType;
|
||||
import org.thoughtcrime.securesms.groups.GroupMessageProcessor;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.Job;
|
||||
@ -86,6 +87,8 @@ import org.whispersystems.libsignal.state.PreKeyBundle;
|
||||
import org.whispersystems.libsignal.state.SessionStore;
|
||||
import org.whispersystems.libsignal.state.SignalProtocolStore;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.SignalServiceMessageSender;
|
||||
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccessPair;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage.Preview;
|
||||
@ -115,7 +118,9 @@ import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class PushDecryptJob extends BaseJob {
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
|
||||
public static final String KEY = "PushDecryptJob";
|
||||
|
||||
@ -127,6 +132,8 @@ public class PushDecryptJob extends BaseJob {
|
||||
private long messageId;
|
||||
private long smsMessageId;
|
||||
|
||||
@Inject SignalServiceMessageSender messageSender;
|
||||
|
||||
public PushDecryptJob(Context context) {
|
||||
this(context, -1);
|
||||
}
|
||||
@ -834,7 +841,8 @@ public class PushDecryptJob extends BaseJob {
|
||||
// we can end up in a deadlock where both users' threads' friend request statuses are
|
||||
// `REQUEST_SENT`.
|
||||
database.setFriendRequestStatus(threadId, ThreadDatabase.LokiFriendRequestStatus.FRIENDS);
|
||||
// TODO: Send empty message here
|
||||
// Accept the friend request
|
||||
sendEmptyMessageTo(envelope.getSource());
|
||||
} else if (friendRequestStatus != ThreadDatabase.LokiFriendRequestStatus.FRIENDS) {
|
||||
// Checking that the sender of the message isn't already a friend is necessary because otherwise
|
||||
// the following situation can occur: Alice and Bob are friends. Bob loses his database and his
|
||||
@ -851,6 +859,18 @@ public class PushDecryptJob extends BaseJob {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendEmptyMessageTo(String pubKey) {
|
||||
try {
|
||||
SignalServiceAddress address = new SignalServiceAddress(pubKey);
|
||||
SignalServiceDataMessage message = new SignalServiceDataMessage(System.currentTimeMillis(), "");
|
||||
Optional<UnidentifiedAccessPair> access = Optional.absent();
|
||||
|
||||
messageSender.sendMessage(address, access, message);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Failed to send empty message to " + pubKey);
|
||||
}
|
||||
}
|
||||
|
||||
private long handleSynchronizeSentTextMessage(@NonNull SentTranscriptMessage message)
|
||||
throws MmsException
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user