Move file

This commit is contained in:
Niels Andriesse 2020-02-28 09:04:57 +07:00
parent fb9567a61b
commit 597b7f157c
4 changed files with 17 additions and 22 deletions

View File

@ -73,7 +73,7 @@ import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
import org.thoughtcrime.securesms.loki.LokiSessionResetImplementation; import org.thoughtcrime.securesms.loki.LokiSessionResetImplementation;
import org.thoughtcrime.securesms.loki.LokiThreadDatabase; import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities; import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
import org.thoughtcrime.securesms.loki.OpenGroupUtilities; import org.thoughtcrime.securesms.loki.redesign.utilities.OpenGroupUtilities;
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity; import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiAPIUtilities; import org.thoughtcrime.securesms.loki.redesign.messaging.LokiAPIUtilities;
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiPreKeyBundleDatabase; import org.thoughtcrime.securesms.loki.redesign.messaging.LokiPreKeyBundleDatabase;
@ -764,7 +764,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
String url = openGroup.getServer(); String url = openGroup.getServer();
long channel = openGroup.getChannel(); long channel = openGroup.getChannel();
OpenGroupUtilities.addGroup(context, url, channel).fail(e -> { OpenGroupUtilities.addGroup(context, url, channel).fail(e -> {
Log.d("Loki", "Failed to sync open group " + url + " due to error: " + e + "."); Log.d("Loki", "Failed to sync open group: " + url + " due to error: " + e + ".");
return Unit.INSTANCE; return Unit.INSTANCE;
}); });
} }

View File

@ -17,9 +17,9 @@ import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
class MultiDeviceOpenGroupUpdateJob private constructor(parameters: Parameters) : BaseJob(parameters), InjectableType { class MultiDeviceOpenGroupUpdateJob private constructor(parameters: Parameters) : BaseJob(parameters), InjectableType {
companion object { companion object {
const val KEY = "MultiDeviceGroupUpdateJob" const val KEY = "MultiDeviceGroupUpdateJob"
private val TAG = MultiDeviceOpenGroupUpdateJob::class.java.simpleName
} }
@Inject @Inject
@ -32,18 +32,14 @@ class MultiDeviceOpenGroupUpdateJob private constructor(parameters: Parameters)
.setMaxAttempts(Parameters.UNLIMITED) .setMaxAttempts(Parameters.UNLIMITED)
.build()) .build())
override fun getFactoryKey(): String { override fun getFactoryKey(): String { return KEY }
return KEY
}
override fun serialize(): Data { override fun serialize(): Data { return Data.EMPTY }
return Data.EMPTY
}
@Throws(Exception::class) @Throws(Exception::class)
public override fun onRun() { public override fun onRun() {
if (!TextSecurePreferences.isMultiDevice(context)) { if (!TextSecurePreferences.isMultiDevice(context)) {
Log.i(TAG, "Not multi device, aborting...") Log.d("Loki", "Not multi device; aborting...")
return return
} }
@ -65,7 +61,7 @@ class MultiDeviceOpenGroupUpdateJob private constructor(parameters: Parameters)
messageSender.sendMessage(0, SignalServiceSyncMessage.forOpenGroups(openGroups), messageSender.sendMessage(0, SignalServiceSyncMessage.forOpenGroups(openGroups),
UnidentifiedAccessUtil.getAccessForSync(context)) UnidentifiedAccessUtil.getAccessForSync(context))
} else { } else {
Log.d(TAG, "No open groups to sync.") Log.d("Loki", "No open groups to sync.")
} }
} }
@ -76,6 +72,7 @@ class MultiDeviceOpenGroupUpdateJob private constructor(parameters: Parameters)
override fun onCanceled() { } override fun onCanceled() { }
class Factory : Job.Factory<MultiDeviceOpenGroupUpdateJob> { class Factory : Job.Factory<MultiDeviceOpenGroupUpdateJob> {
override fun create(parameters: Parameters, data: Data): MultiDeviceOpenGroupUpdateJob { override fun create(parameters: Parameters, data: Data): MultiDeviceOpenGroupUpdateJob {
return MultiDeviceOpenGroupUpdateJob(parameters) return MultiDeviceOpenGroupUpdateJob(parameters)
} }

View File

@ -18,7 +18,7 @@ import nl.komponents.kovenant.ui.failUi
import nl.komponents.kovenant.ui.successUi import nl.komponents.kovenant.ui.successUi
import org.thoughtcrime.securesms.BaseActionBarActivity import org.thoughtcrime.securesms.BaseActionBarActivity
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.loki.OpenGroupUtilities import org.thoughtcrime.securesms.loki.redesign.utilities.OpenGroupUtilities
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragment import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragment
import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragmentDelegate import org.thoughtcrime.securesms.loki.redesign.fragments.ScanQRCodeWrapperFragmentDelegate
import org.thoughtcrime.securesms.sms.MessageSender import org.thoughtcrime.securesms.sms.MessageSender

View File

@ -1,4 +1,4 @@
package org.thoughtcrime.securesms.loki package org.thoughtcrime.securesms.loki.redesign.utilities
import android.content.Context import android.content.Context
import nl.komponents.kovenant.Promise import nl.komponents.kovenant.Promise
@ -11,19 +11,17 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.signalservice.loki.api.LokiPublicChat import org.whispersystems.signalservice.loki.api.LokiPublicChat
object OpenGroupUtilities { object OpenGroupUtilities {
@JvmStatic fun addGroup(context: Context, url: String, channel: Long): Promise<LokiPublicChat, Exception> {
// Check if we have an existing group
val groupId = LokiPublicChat.getId(channel, url)
val threadID = GroupManager.getPublicChatThreadId(groupId, context)
val openGroup = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID)
if (openGroup != null) {
return Promise.of(openGroup)
}
@JvmStatic fun addGroup(context: Context, url: String, channel: Long): Promise<LokiPublicChat, Exception> {
// Check for an existing group
val groupID = LokiPublicChat.getId(channel, url)
val threadID = GroupManager.getPublicChatThreadId(groupID, context)
val openGroup = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(threadID)
if (openGroup != null) { return Promise.of(openGroup) }
// Add the new group // Add the new group
val application = ApplicationContext.getInstance(context) val application = ApplicationContext.getInstance(context)
val displayName = TextSecurePreferences.getProfileName(context) val displayName = TextSecurePreferences.getProfileName(context)
val lokiPublicChatAPI = application.lokiPublicChatAPI ?: throw Error("LokiPublicChatAPI is not initialized") val lokiPublicChatAPI = application.lokiPublicChatAPI ?: throw Error("LokiPublicChatAPI is not initialized.")
return application.lokiPublicChatManager.addChat(url, channel).then { group -> return application.lokiPublicChatManager.addChat(url, channel).then { group ->
DatabaseFactory.getLokiAPIDatabase(context).removeLastMessageServerID(channel, url) DatabaseFactory.getLokiAPIDatabase(context).removeLastMessageServerID(channel, url)
DatabaseFactory.getLokiAPIDatabase(context).removeLastDeletionServerID(channel, url) DatabaseFactory.getLokiAPIDatabase(context).removeLastDeletionServerID(channel, url)