mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-05 07:32:14 +00:00
Support for server federation.
This commit is contained in:
@@ -10,6 +10,7 @@ import android.util.Log;
|
||||
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.textsecure.directory.Directory;
|
||||
import org.whispersystems.textsecure.push.ContactTokenDetails;
|
||||
import org.whispersystems.textsecure.push.PushServiceSocket;
|
||||
|
||||
import java.util.List;
|
||||
@@ -61,11 +62,14 @@ public class DirectoryRefreshService extends Service {
|
||||
String password = TextSecurePreferences.getPushServerPassword(context);
|
||||
PushServiceSocket socket = new PushServiceSocket(context, localNumber, password);
|
||||
|
||||
Set<String> eligibleContactTokens = directory.getPushEligibleContactTokens(localNumber);
|
||||
List<String> activeTokens = socket.retrieveDirectory(eligibleContactTokens);
|
||||
Set<String> eligibleContactTokens = directory.getPushEligibleContactTokens(localNumber);
|
||||
List<ContactTokenDetails> activeTokens = socket.retrieveDirectory(eligibleContactTokens);
|
||||
|
||||
if (activeTokens != null) {
|
||||
eligibleContactTokens.removeAll(activeTokens);
|
||||
for (ContactTokenDetails activeToken : activeTokens) {
|
||||
eligibleContactTokens.remove(activeToken.getToken());
|
||||
}
|
||||
|
||||
directory.setTokens(activeTokens, eligibleContactTokens);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.whispersystems.textsecure.crypto.IdentityKey;
|
||||
import org.whispersystems.textsecure.crypto.MasterSecret;
|
||||
import org.whispersystems.textsecure.crypto.PreKeyUtil;
|
||||
import org.whispersystems.textsecure.directory.Directory;
|
||||
import org.whispersystems.textsecure.push.ContactTokenDetails;
|
||||
import org.whispersystems.textsecure.push.PushServiceSocket;
|
||||
import org.whispersystems.textsecure.storage.PreKeyRecord;
|
||||
import org.whispersystems.textsecure.util.Util;
|
||||
@@ -282,11 +283,13 @@ public class RegistrationService extends Service {
|
||||
String gcmRegistrationId = waitForGcmRegistrationId();
|
||||
socket.registerGcmId(gcmRegistrationId);
|
||||
|
||||
Set<String> contactTokens = Directory.getInstance(this).getPushEligibleContactTokens(number);
|
||||
List<String> activeTokens = socket.retrieveDirectory(contactTokens);
|
||||
Set<String> contactTokens = Directory.getInstance(this).getPushEligibleContactTokens(number);
|
||||
List<ContactTokenDetails> activeTokens = socket.retrieveDirectory(contactTokens);
|
||||
|
||||
if (activeTokens != null) {
|
||||
contactTokens.removeAll(activeTokens);
|
||||
for (ContactTokenDetails activeToken : activeTokens) {
|
||||
contactTokens.remove(activeToken.getToken());
|
||||
}
|
||||
Directory.getInstance(this).setTokens(activeTokens, contactTokens);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user