mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Glue some things together again
This commit is contained in:
parent
27b5a93161
commit
e668341e38
@ -19,7 +19,6 @@ package org.thoughtcrime.securesms;
|
||||
import android.arch.lifecycle.DefaultLifecycleObserver;
|
||||
import android.arch.lifecycle.LifecycleOwner;
|
||||
import android.arch.lifecycle.ProcessLifecycleOwner;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
@ -106,6 +105,7 @@ import org.whispersystems.signalservice.loki.database.LokiAPIDatabaseProtocol;
|
||||
import org.whispersystems.signalservice.loki.protocol.friendrequests.FriendRequestProtocol;
|
||||
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager;
|
||||
import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol;
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.DeviceLink;
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol;
|
||||
import org.whispersystems.signalservice.loki.protocol.sessionmanagement.SessionManagementProtocol;
|
||||
import org.whispersystems.signalservice.loki.protocol.sessionmanagement.SessionManagementProtocolDelegate;
|
||||
@ -201,7 +201,8 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
LokiPushNotificationAcknowledgement.Companion.configureIfNeeded(BuildConfig.DEBUG);
|
||||
if (setUpStorageAPIIfNeeded()) {
|
||||
if (userPublicKey != null) {
|
||||
MultiDeviceUtilities.updateDeviceLinksOnServer(this);
|
||||
Set<DeviceLink> deviceLinks = DatabaseFactory.getLokiAPIDatabase(this).getDeviceLinks(userPublicKey);
|
||||
LokiFileServerAPI.shared.setDeviceLinks(deviceLinks);
|
||||
}
|
||||
}
|
||||
resubmitProfilePictureIfNeeded();
|
||||
|
@ -86,13 +86,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
protected void onPreCreate() {
|
||||
dynamicTheme.onCreate(this);
|
||||
dynamicLanguage.onCreate(this);
|
||||
if (TextSecurePreferences.getLocalNumber(this) != null) {
|
||||
ApplicationContext application = ApplicationContext.getInstance(this);
|
||||
application.createDefaultPublicChatsIfNeeded();
|
||||
application.createRSSFeedsIfNeeded();
|
||||
application.getLokiPublicChatManager().startPollersIfNeeded();
|
||||
application.startRSSFeedPollersIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2272,7 +2272,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void updateInputPanel() {
|
||||
boolean shouldInputPanelBeEnabled = FriendRequestProtocol.shouldInputPanelBeEnabled(this, threadId);
|
||||
boolean shouldInputPanelBeEnabled = FriendRequestProtocol.shouldInputPanelBeEnabled(this, recipient);
|
||||
Util.runOnMain(() -> {
|
||||
updateToggleButtonState();
|
||||
String hint = shouldInputPanelBeEnabled ? "Message" : "Pending session request";
|
||||
@ -2472,7 +2472,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
private void updateToggleButtonState() {
|
||||
if (!FriendRequestProtocol.shouldAttachmentButtonBeEnabled(this, threadId)) {
|
||||
if (!FriendRequestProtocol.shouldAttachmentButtonBeEnabled(this, recipient)) {
|
||||
buttonToggle.display(sendButton);
|
||||
quickAttachmentToggle.hide();
|
||||
inlineAttachmentToggle.hide();
|
||||
|
@ -11,8 +11,8 @@ import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities;
|
||||
import org.thoughtcrime.securesms.util.AsyncLoader;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.LokiDeviceLinkUtilities;
|
||||
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec;
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
@ -33,9 +33,9 @@ public class DeviceListLoader extends AsyncLoader<List<Device>> {
|
||||
@Override
|
||||
public List<Device> loadInBackground() {
|
||||
try {
|
||||
String ourPublicKey = TextSecurePreferences.getLocalNumber(getContext());
|
||||
Set<String> secondaryDevicePublicKeys = LokiDeviceLinkUtilities.INSTANCE.getSlaveHexEncodedPublicKeys(ourPublicKey).get();
|
||||
List<Device> devices = Stream.of(secondaryDevicePublicKeys).map(this::mapToDevice).toList();
|
||||
String userPublicKey = TextSecurePreferences.getLocalNumber(getContext());
|
||||
Set<String> slaveDevicePublicKeys = MultiDeviceProtocol.shared.getSlaveDevices(userPublicKey);
|
||||
List<Device> devices = Stream.of(slaveDevicePublicKeys).map(this::mapToDevice).toList();
|
||||
Collections.sort(devices, new DeviceComparator());
|
||||
return devices;
|
||||
} catch (Exception e) {
|
||||
|
@ -47,7 +47,6 @@ import org.thoughtcrime.securesms.linkpreview.LinkPreviewRepository;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.protocol.LokiSessionResetImplementation;
|
||||
import org.thoughtcrime.securesms.loki.protocol.MultiDeviceOpenGroupUpdateJob;
|
||||
import org.thoughtcrime.securesms.loki.PushMessageSyncSendJob;
|
||||
import org.thoughtcrime.securesms.preferences.AppProtectionPreferenceFragment;
|
||||
import org.thoughtcrime.securesms.push.MessageSenderEventListener;
|
||||
import org.thoughtcrime.securesms.push.SignalServiceNetworkAccess;
|
||||
@ -112,7 +111,6 @@ import network.loki.messenger.BuildConfig;
|
||||
MultiDeviceStickerPackOperationJob.class,
|
||||
MultiDeviceStickerPackSyncJob.class,
|
||||
LinkPreviewRepository.class,
|
||||
PushMessageSyncSendJob.class,
|
||||
MultiDeviceOpenGroupUpdateJob.class})
|
||||
|
||||
public class SignalCommunicationModule {
|
||||
@ -154,6 +152,7 @@ public class SignalCommunicationModule {
|
||||
Optional.fromNullable(IncomingMessageObserver.getUnidentifiedPipe()),
|
||||
Optional.of(new MessageSenderEventListener(context)),
|
||||
TextSecurePreferences.getLocalNumber(context),
|
||||
TextSecurePreferences.getMasterHexEncodedPublicKey(context),
|
||||
DatabaseFactory.getLokiAPIDatabase(context),
|
||||
DatabaseFactory.getLokiThreadDatabase(context),
|
||||
DatabaseFactory.getLokiMessageDatabase(context),
|
||||
|
@ -15,7 +15,6 @@ import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraint;
|
||||
import org.thoughtcrime.securesms.jobmanager.impl.SqlCipherMigrationConstraintObserver;
|
||||
import org.thoughtcrime.securesms.loki.protocol.MultiDeviceOpenGroupUpdateJob;
|
||||
import org.thoughtcrime.securesms.loki.protocol.PushEphemeralMessageSendJob;
|
||||
import org.thoughtcrime.securesms.loki.PushMessageSyncSendJob;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -71,7 +70,6 @@ public final class JobManagerFactories {
|
||||
put(TrimThreadJob.KEY, new TrimThreadJob.Factory());
|
||||
put(TypingSendJob.KEY, new TypingSendJob.Factory());
|
||||
put(UpdateApkJob.KEY, new UpdateApkJob.Factory());
|
||||
put(PushMessageSyncSendJob.KEY, new PushMessageSyncSendJob.Factory());
|
||||
put(PushEphemeralMessageSendJob.KEY, new PushEphemeralMessageSendJob.Factory());
|
||||
put(MultiDeviceOpenGroupUpdateJob.KEY, new MultiDeviceOpenGroupUpdateJob.Factory());
|
||||
}};
|
||||
|
@ -331,7 +331,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
}
|
||||
|
||||
// Loki - Handle friend request message if needed
|
||||
FriendRequestProtocol.handleFriendRequestMessageIfNeeded(content);
|
||||
FriendRequestProtocol.handleFriendRequestMessageIfNeeded(context, content.getSender(), content);
|
||||
}
|
||||
} else if (content.getSyncMessage().isPresent()) {
|
||||
TextSecurePreferences.setMultiDevice(context, true);
|
||||
@ -803,8 +803,13 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
MessageNotifier.updateNotification(context, insertResult.get().getThreadId());
|
||||
}
|
||||
|
||||
// Loki - Store message server ID if needed
|
||||
updateGroupChatMessageServerID(messageServerIDOrNull, insertResult);
|
||||
// Loki - Store message open group server ID if needed
|
||||
if (insertResult.isPresent() && messageServerIDOrNull.isPresent()) {
|
||||
long messageID = insertResult.get().getMessageId();
|
||||
long messageServerID = messageServerIDOrNull.get();
|
||||
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||
lokiMessageDatabase.setServerID(messageID, messageServerID);
|
||||
}
|
||||
|
||||
// Loki - Update mapping of message ID to original thread ID
|
||||
if (insertResult.isPresent()) {
|
||||
@ -978,7 +983,12 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
MentionsManager.shared.cache(textMessage.getSender().serialize(), result.getThreadId());
|
||||
|
||||
// Loki - Store message server ID
|
||||
updateGroupChatMessageServerID(messageServerIDOrNull, insertResult);
|
||||
if (insertResult.isPresent() && messageServerIDOrNull.isPresent()) {
|
||||
long messageID = insertResult.get().getMessageId();
|
||||
long messageServerID = messageServerIDOrNull.get();
|
||||
LokiMessageDatabase lokiMessageDatabase = DatabaseFactory.getLokiMessageDatabase(context);
|
||||
lokiMessageDatabase.setServerID(messageID, messageServerID);
|
||||
}
|
||||
|
||||
// Loki - Update mapping of message to original thread ID
|
||||
if (result.getMessageId() > -1) {
|
||||
@ -1073,19 +1083,16 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context);
|
||||
|
||||
if (!smsMessageId.isPresent()) {
|
||||
SmsMessageRecord lastMessage = getLastMessage(sender);
|
||||
if (lastMessage == null || !SmsDatabase.Types.isFailedDecryptType(lastMessage.getType())) {
|
||||
Optional<InsertResult> insertResult = insertPlaceholder(sender, senderDevice, timestamp);
|
||||
|
||||
if (insertResult.isPresent()) {
|
||||
smsDatabase.markAsDecryptFailed(insertResult.get().getMessageId());
|
||||
MessageNotifier.updateNotification(context, insertResult.get().getThreadId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
smsDatabase.markAsDecryptFailed(smsMessageId.get());
|
||||
}
|
||||
triggerSessionRestorePrompt(sender);
|
||||
SessionManagementProtocol.triggerSessionRestorationUI(context, sender);
|
||||
}
|
||||
|
||||
private void handleNoSessionMessage(@NonNull String sender, int senderDevice, long timestamp,
|
||||
@ -1094,19 +1101,16 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
SmsDatabase smsDatabase = DatabaseFactory.getSmsDatabase(context);
|
||||
|
||||
if (!smsMessageId.isPresent()) {
|
||||
SmsMessageRecord lastMessage = getLastMessage(sender);
|
||||
if (lastMessage == null || !SmsDatabase.Types.isNoRemoteSessionType(lastMessage.getType())) {
|
||||
Optional<InsertResult> insertResult = insertPlaceholder(sender, senderDevice, timestamp);
|
||||
|
||||
if (insertResult.isPresent()) {
|
||||
smsDatabase.markAsNoSession(insertResult.get().getMessageId());
|
||||
MessageNotifier.updateNotification(context, insertResult.get().getThreadId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
smsDatabase.markAsNoSession(smsMessageId.get());
|
||||
}
|
||||
triggerSessionRestorePrompt(sender);
|
||||
SessionManagementProtocol.triggerSessionRestorationUI(context, sender);
|
||||
}
|
||||
|
||||
private void handleLegacyMessage(@NonNull String sender, int senderDevice, long timestamp,
|
||||
@ -1160,7 +1164,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
||||
String url = content.senderProfilePictureURL.or("");
|
||||
ApplicationContext.getInstance(context).getJobManager().add(new RetrieveProfileAvatarJob(recipient, url));
|
||||
|
||||
SessionMetaProtocol.handleProfileKeyUpdateIfNeeded(content, message);
|
||||
SessionMetaProtocol.handleProfileKeyUpdateIfNeeded(context, content);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,9 @@ import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||
import org.thoughtcrime.securesms.loki.dialogs.PNModeBottomSheet
|
||||
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
|
||||
import org.thoughtcrime.securesms.loki.protocol.ClosedGroupsProtocol
|
||||
import org.thoughtcrime.securesms.loki.protocol.LokiSessionResetImplementation
|
||||
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
|
||||
import org.thoughtcrime.securesms.loki.utilities.push
|
||||
import org.thoughtcrime.securesms.loki.utilities.show
|
||||
import org.thoughtcrime.securesms.loki.views.ConversationView
|
||||
@ -43,6 +44,11 @@ import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.notifications.MessageNotifier
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.signalservice.loki.protocol.friendrequests.FriendRequestProtocol
|
||||
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager
|
||||
import org.whispersystems.signalservice.loki.protocol.meta.SessionMetaProtocol
|
||||
import org.whispersystems.signalservice.loki.protocol.sessionmanagement.SessionManagementProtocol
|
||||
import org.whispersystems.signalservice.loki.protocol.syncmessages.SyncMessagesProtocol
|
||||
import kotlin.math.abs
|
||||
|
||||
class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListener, SeedReminderViewDelegate, NewConversationButtonSetViewDelegate {
|
||||
@ -143,13 +149,21 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
||||
val adapter = recyclerView.adapter as HomeAdapter
|
||||
adapter.typingThreadIDs = threadIDs ?: setOf()
|
||||
})
|
||||
// Set up public chats and RSS feeds if needed
|
||||
if (TextSecurePreferences.getLocalNumber(this) != null) {
|
||||
// Set up remaining components if needed
|
||||
val userPublicKey = TextSecurePreferences.getLocalNumber(this)
|
||||
if (userPublicKey != null) {
|
||||
val application = ApplicationContext.getInstance(this)
|
||||
application.createDefaultPublicChatsIfNeeded()
|
||||
application.createRSSFeedsIfNeeded()
|
||||
val apiDB = DatabaseFactory.getLokiAPIDatabase(this)
|
||||
val threadDB = DatabaseFactory.getLokiThreadDatabase(this)
|
||||
val userDB = DatabaseFactory.getLokiUserDatabase(this)
|
||||
val sessionResetImpl = LokiSessionResetImplementation(this)
|
||||
FriendRequestProtocol.configureIfNeeded(apiDB, userPublicKey)
|
||||
MentionsManager.configureIfNeeded(userPublicKey, threadDB, userDB)
|
||||
SessionMetaProtocol.configureIfNeeded(apiDB, userPublicKey)
|
||||
org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol.configureIfNeeded(apiDB)
|
||||
SessionManagementProtocol.configureIfNeeded(sessionResetImpl, threadDB, application)
|
||||
SyncMessagesProtocol.configureIfNeeded(apiDB, userPublicKey)
|
||||
application.lokiPublicChatManager.startPollersIfNeeded()
|
||||
application.startRSSFeedPollersIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import kotlinx.android.synthetic.main.activity_pn_mode.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.loki.utilities.setUpActionBarSessionLogo
|
||||
import org.thoughtcrime.securesms.loki.utilities.show
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
@ -92,13 +91,6 @@ class PNModeActivity : BaseActionBarActivity() {
|
||||
val application = ApplicationContext.getInstance(this)
|
||||
application.setUpStorageAPIIfNeeded()
|
||||
application.setUpP2PAPIIfNeeded()
|
||||
val publicChatAPI = ApplicationContext.getInstance(this).lokiPublicChatAPI
|
||||
if (publicChatAPI != null) {
|
||||
// TODO: This won't be necessary anymore when we don't auto-join the Loki Public Chat anymore
|
||||
application.createDefaultPublicChatsIfNeeded()
|
||||
val servers = DatabaseFactory.getLokiThreadDatabase(this).getAllPublicChatServers()
|
||||
servers.forEach { publicChatAPI.setDisplayName(displayName, it) }
|
||||
}
|
||||
application.registerForFCMIfNeeded(true)
|
||||
val intent = Intent(this, HomeActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.util.Log
|
||||
import nl.komponents.kovenant.Promise
|
||||
import nl.komponents.kovenant.functional.bind
|
||||
import nl.komponents.kovenant.then
|
||||
import org.thoughtcrime.securesms.ApplicationContext
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||
@ -11,6 +12,7 @@ import org.thoughtcrime.securesms.database.Address
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
import org.thoughtcrime.securesms.jobs.PushDecryptJob
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveProfileAvatarJob
|
||||
import org.thoughtcrime.securesms.loki.utilities.successBackground
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.libsignal.util.guava.Optional
|
||||
@ -21,12 +23,11 @@ import org.whispersystems.signalservice.api.messages.SignalServiceGroup
|
||||
import org.whispersystems.signalservice.api.messages.multidevice.SentTranscriptMessage
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
||||
import org.whispersystems.signalservice.loki.api.fileserver.LokiFileServerAPI
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.LokiDeviceLinkUtilities
|
||||
import org.whispersystems.signalservice.loki.api.opengroups.LokiPublicChat
|
||||
import org.whispersystems.signalservice.loki.api.opengroups.LokiPublicChatAPI
|
||||
import org.whispersystems.signalservice.loki.api.opengroups.LokiPublicChatMessage
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol
|
||||
import org.whispersystems.signalservice.loki.protocol.todo.LokiThreadFriendRequestStatus
|
||||
import org.whispersystems.signalservice.loki.utilities.successBackground
|
||||
import java.security.MessageDigest
|
||||
import java.util.*
|
||||
|
||||
@ -157,7 +158,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
||||
fun pollForNewMessages() {
|
||||
fun processIncomingMessage(message: LokiPublicChatMessage) {
|
||||
// If the sender of the current message is not a slave device, set the display name in the database
|
||||
val masterHexEncodedPublicKey = LokiDeviceLinkUtilities.getMasterHexEncodedPublicKey(message.hexEncodedPublicKey).get()
|
||||
val masterHexEncodedPublicKey = MultiDeviceProtocol.shared.getMasterDevice(message.hexEncodedPublicKey)
|
||||
if (masterHexEncodedPublicKey == null) {
|
||||
val senderDisplayName = "${message.displayName} (...${message.hexEncodedPublicKey.takeLast(8)})"
|
||||
DatabaseFactory.getLokiUserDatabase(context).setServerDisplayName(group.id, message.hexEncodedPublicKey, senderDisplayName)
|
||||
@ -216,16 +217,13 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
||||
}
|
||||
}
|
||||
}
|
||||
var userDevices = setOf<String>()
|
||||
val userDevices = MultiDeviceProtocol.shared.getAllLinkedDevices(userHexEncodedPublicKey)
|
||||
var uniqueDevices = setOf<String>()
|
||||
val userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(context).privateKey.serialize()
|
||||
val database = DatabaseFactory.getLokiAPIDatabase(context)
|
||||
LokiFileServerAPI.configure(false, userHexEncodedPublicKey, userPrivateKey, database)
|
||||
val apiDB = DatabaseFactory.getLokiAPIDatabase(context)
|
||||
LokiFileServerAPI.configure(false, userHexEncodedPublicKey, userPrivateKey, apiDB)
|
||||
// Kovenant propagates a context to chained promises, so LokiPublicChatAPI.sharedContext should be used for all of the below
|
||||
LokiDeviceLinkUtilities.getAllLinkedDeviceHexEncodedPublicKeys(userHexEncodedPublicKey).bind(LokiPublicChatAPI.sharedContext) { devices ->
|
||||
userDevices = devices
|
||||
api.getMessages(group.channel, group.server)
|
||||
}.bind(LokiPublicChatAPI.sharedContext) { messages ->
|
||||
api.getMessages(group.channel, group.server).bind(LokiPublicChatAPI.sharedContext) { messages ->
|
||||
if (messages.isNotEmpty()) {
|
||||
if (messages.count() == 1) {
|
||||
Log.d("Loki", "Fetched 1 new message.")
|
||||
@ -243,7 +241,7 @@ class LokiPublicChatPoller(private val context: Context, private val group: Loki
|
||||
}.successBackground {
|
||||
val newDisplayNameUpdatees = uniqueDevices.mapNotNull {
|
||||
// This will return null if the current device is a master device
|
||||
LokiDeviceLinkUtilities.getMasterHexEncodedPublicKey(it).get()
|
||||
MultiDeviceProtocol.shared.getMasterDevice(it)
|
||||
}.toSet()
|
||||
// Fetch the display names of the master devices
|
||||
displayNameUpdatees = displayNameUpdatees.union(newDisplayNameUpdatees)
|
||||
|
@ -125,6 +125,7 @@ object FriendRequestProtocol {
|
||||
return false
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getLastMessageID(context: Context, threadID: Long): Long? {
|
||||
val db = DatabaseFactory.getSmsDatabase(context)
|
||||
val messageCount = db.getMessageCountForThread(threadID)
|
||||
|
@ -15,6 +15,7 @@ import org.thoughtcrime.securesms.sms.OutgoingTextMessage
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.libsignal.loki.LokiSessionResetStatus
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
||||
import org.whispersystems.signalservice.loki.protocol.multidevice.MultiDeviceProtocol
|
||||
import org.whispersystems.signalservice.loki.protocol.todo.LokiThreadFriendRequestStatus
|
||||
|
||||
object SessionManagementProtocol {
|
||||
@ -94,7 +95,11 @@ object SessionManagementProtocol {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
private fun isSessionRequest(content: SignalServiceContent): Boolean {
|
||||
return content.dataMessage.isPresent && content.dataMessage.get().isSessionRequest
|
||||
fun triggerSessionRestorationUI(context: Context, publicKey: String) {
|
||||
val masterDevicePublicKey = MultiDeviceProtocol.shared.getMasterDevice(publicKey) ?: publicKey
|
||||
val masterDeviceAsRecipient = recipient(context, masterDevicePublicKey)
|
||||
if (masterDeviceAsRecipient.isGroupRecipient) { return }
|
||||
val threadID = DatabaseFactory.getThreadDatabase(context).getThreadIdFor(masterDeviceAsRecipient)
|
||||
DatabaseFactory.getLokiThreadDatabase(context).addSessionRestoreDevice(threadID, publicKey)
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import com.prof.rssparser.engine.XMLParser
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.Runnable
|
||||
import org.thoughtcrime.securesms.jobs.PushDecryptJob
|
||||
import org.thoughtcrime.securesms.loki.utilities.successBackground
|
||||
import org.whispersystems.libsignal.util.guava.Optional
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceContent
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage
|
||||
@ -15,7 +16,6 @@ import org.whispersystems.signalservice.api.messages.SignalServiceGroup
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress
|
||||
import org.whispersystems.signalservice.loki.api.rssfeeds.LokiRSSFeed
|
||||
import org.whispersystems.signalservice.loki.api.rssfeeds.LokiRSSFeedProxy
|
||||
import org.whispersystems.signalservice.loki.utilities.successBackground
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package org.thoughtcrime.securesms.loki.utilities
|
||||
|
||||
import android.util.Log
|
||||
import nl.komponents.kovenant.Promise
|
||||
|
||||
fun <V, E> Promise<V, E>.successBackground(callback: (value: V) -> Unit): Promise<V, E> {
|
||||
Thread {
|
||||
try {
|
||||
callback(get())
|
||||
} catch (e: Exception) {
|
||||
Log.d("Loki", "Failed to execute task in background: ${e.message}.")
|
||||
}
|
||||
}.start()
|
||||
return this
|
||||
}
|
@ -49,7 +49,6 @@ import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.logging.Log;
|
||||
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
|
||||
import org.thoughtcrime.securesms.loki.protocol.SessionMetaProtocol;
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
@ -60,8 +59,6 @@ import org.thoughtcrime.securesms.util.SpanUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.webrtc.CallNotificationBuilder;
|
||||
import org.whispersystems.signalservice.internal.util.Util;
|
||||
import org.whispersystems.signalservice.loki.protocol.todo.LokiThreadFriendRequestStatus;
|
||||
import org.whispersystems.signalservice.loki.utilities.PromiseUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -74,7 +71,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import me.leolin.shortcutbadger.ShortcutBadger;
|
||||
import network.loki.messenger.R;
|
||||
import nl.komponents.kovenant.Promise;
|
||||
|
||||
/**
|
||||
* Handles posting system notifications for new messages.
|
||||
|
Loading…
Reference in New Issue
Block a user