Enable profile sharing upon becoming friends with a contact.

This commit is contained in:
Mikunj 2019-11-27 15:25:53 +11:00
parent 88234c26a3
commit a852b019aa
2 changed files with 11 additions and 3 deletions

View File

@ -2376,9 +2376,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
new AsyncTask<Void, Void, Long>() {
@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<OutgoingTextMessage, Void, Long>() {
@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();
}

View File

@ -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(() -> {