From a852b019aaad60f1ba35bd6b6bcb5e7cf860ab87 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Wed, 27 Nov 2019 15:25:53 +1100 Subject: [PATCH] Enable profile sharing upon becoming friends with a contact. --- .../securesms/conversation/ConversationActivity.java | 12 +++++++++--- .../thoughtcrime/securesms/jobs/PushDecryptJob.java | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index a0dc86eaf4..228382df91 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -2376,9 +2376,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity new AsyncTask() { @Override protected Long doInBackground(Void... param) { + /* Loki - Don't enable profile sharing if we initiate conversation if (initiating) { DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient, true); } + */ return MessageSender.send(context, outgoingMessage, threadId, forceSms, () -> fragment.releaseOutgoingMessage(id)); } @@ -2431,9 +2433,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity new AsyncTask() { @Override protected Long doInBackground(OutgoingTextMessage... messages) { + /* Loki - Don't enable profile sharing if we initiate conversation if (initiatingConversation) { DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient, true); } + */ return MessageSender.send(context, messages[0], threadId, forceSms, () -> fragment.releaseOutgoingMessage(id)); } @@ -3052,12 +3056,14 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity long originalThreadID = lokiMessageDatabase.getOriginalThreadID(friendRequest.id); long threadId = originalThreadID < 0 ? this.threadId : originalThreadID; - Address contact = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadId).getAddress(); - String contactPubKey = contact.toString(); + Recipient contact = DatabaseFactory.getThreadDatabase(this).getRecipientForThreadId(threadId); + Address address = contact.getAddress(); + String contactPubKey = address.serialize(); DatabaseFactory.getLokiThreadDatabase(this).setFriendRequestStatus(threadId, LokiThreadFriendRequestStatus.FRIENDS); lokiMessageDatabase.setFriendRequestStatus(friendRequest.id, LokiMessageFriendRequestStatus.REQUEST_ACCEPTED); + DatabaseFactory.getRecipientDatabase(this).setProfileSharing(contact, true); MessageSender.sendBackgroundMessageToAllDevices(this, contactPubKey); - MessageSender.syncContact(this, contact); + MessageSender.syncContact(this, address); updateInputPanel(); } diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index b1c8affe52..32dd6c9567 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -1200,6 +1200,8 @@ public class PushDecryptJob extends BaseJob implements InjectableType { if (syncContact) { MessageSender.syncContact(context, contactID.getAddress()); } + // Allow profile sharing with contact + DatabaseFactory.getRecipientDatabase(context).setProfileSharing(contactID, true); // Update the last message if needed LokiStorageAPI.shared.getPrimaryDevicePublicKey(pubKey).success(primaryDevice -> { Util.runOnMain(() -> {