mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Update RefreshPreKeysJob.
This commit is contained in:
parent
96efb5d296
commit
384a5ba35d
@ -36,6 +36,8 @@ import org.thoughtcrime.securesms.database.SmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.jobs.RefreshPreKeysJob;
|
||||
import org.thoughtcrime.securesms.loki.LokiAPIDatabase;
|
||||
import org.thoughtcrime.securesms.loki.LokiContactPreKeyDatabase;
|
||||
import org.thoughtcrime.securesms.loki.LokiPreKeyBundleDatabase;
|
||||
import org.thoughtcrime.securesms.notifications.NotificationChannels;
|
||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
@ -116,6 +118,8 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||
db.execSQL(LokiAPIDatabase.getCreateSwarmCacheTableCommand());
|
||||
db.execSQL(LokiAPIDatabase.getCreateLastMessageHashValueTableCommand());
|
||||
db.execSQL(LokiAPIDatabase.getCreateReceivedMessageHashValuesTableCommand());
|
||||
db.execSQL(LokiPreKeyBundleDatabase.getCreateTableCommand());
|
||||
db.execSQL(LokiContactPreKeyDatabase.getCreateTableCommand());
|
||||
|
||||
executeStatements(db, SmsDatabase.CREATE_INDEXS);
|
||||
executeStatements(db, MmsDatabase.CREATE_INDEXS);
|
||||
|
@ -55,6 +55,26 @@ public class RefreshPreKeysJob extends BaseJob implements InjectableType {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun() throws IOException {
|
||||
if (!TextSecurePreferences.isPushRegistered(context)) return;
|
||||
|
||||
if (TextSecurePreferences.isSignedPreKeyRegistered(context)) {
|
||||
Log.i(TAG, "Already have a signed pre key set");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.i(TAG, "Registering new signed pre key...");
|
||||
IdentityKeyPair identityKey = IdentityKeyUtil.getIdentityKeyPair(context);
|
||||
PreKeyUtil.generateSignedPreKey(context, identityKey, true);
|
||||
TextSecurePreferences.setSignedPreKeyRegistered(context, true);
|
||||
|
||||
ApplicationContext.getInstance(context)
|
||||
.getJobManager()
|
||||
.add(new CleanPreKeysJob());
|
||||
}
|
||||
|
||||
/* Loki - Original Code
|
||||
@Override
|
||||
public void onRun() throws IOException {
|
||||
if (!TextSecurePreferences.isPushRegistered(context)) return;
|
||||
@ -81,6 +101,7 @@ public class RefreshPreKeysJob extends BaseJob implements InjectableType {
|
||||
.getJobManager()
|
||||
.add(new CleanPreKeysJob());
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean onShouldRetry(Exception exception) {
|
||||
|
@ -50,9 +50,7 @@ class LokiPreKeyBundleDatabase(context: Context, helper: SQLCipherOpenHelper) :
|
||||
* @return PreKeyBundle? A pre key bundle or `null` if something went wrong.
|
||||
*/
|
||||
fun generatePreKeyBundle(pubKey: String): PreKeyBundle? {
|
||||
// TODO: Check if we have pre keys
|
||||
val identityKeyPair = IdentityKeyUtil.getIdentityKeyPair(context)
|
||||
|
||||
val signedPreKey = PreKeyUtil.getActiveSignedPreKey(context) ?: return null
|
||||
|
||||
val preKeyRecord = DatabaseFactory.getLokiContactPreKeyDatabase(context).getOrCreatePreKey(pubKey)
|
||||
|
Loading…
x
Reference in New Issue
Block a user