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.LokiThreadDatabase;
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.messaging.LokiAPIUtilities;
import org.thoughtcrime.securesms.loki.redesign.messaging.LokiPreKeyBundleDatabase;
@ -764,7 +764,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
String url = openGroup.getServer();
long channel = openGroup.getChannel();
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;
});
}

View File

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

View File

@ -18,7 +18,7 @@ import nl.komponents.kovenant.ui.failUi
import nl.komponents.kovenant.ui.successUi
import org.thoughtcrime.securesms.BaseActionBarActivity
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.ScanQRCodeWrapperFragmentDelegate
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 nl.komponents.kovenant.Promise
@ -11,19 +11,17 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.signalservice.loki.api.LokiPublicChat
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
val application = ApplicationContext.getInstance(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 ->
DatabaseFactory.getLokiAPIDatabase(context).removeLastMessageServerID(channel, url)
DatabaseFactory.getLokiAPIDatabase(context).removeLastDeletionServerID(channel, url)