mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-21 07:49:09 +00:00
Support for multi-device.
1) In addition to the Recipient interface, there is now RecipientDevice. A Recipient can have multiple corresponding RecipientDevices. All addressing is done to a Recipient, but crypto sessions and transport delivery are done to RecipientDevice. 2) The Push transport handles the discovery and session setup of additional Recipient devices. 3) Some internal rejiggering of Groups.
This commit is contained in:
27
src/org/thoughtcrime/securesms/util/GroupUtil.java
Normal file
27
src/org/thoughtcrime/securesms/util/GroupUtil.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.thoughtcrime.securesms.util;
|
||||
|
||||
import org.whispersystems.textsecure.util.Hex;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GroupUtil {
|
||||
|
||||
private static final String ENCODED_GROUP_PREFIX = "__textsecure_group__!";
|
||||
|
||||
public static String getEncodedId(byte[] groupId) {
|
||||
return ENCODED_GROUP_PREFIX + Hex.toStringCondensed(groupId);
|
||||
}
|
||||
|
||||
public static byte[] getDecodedId(String groupId) throws IOException {
|
||||
if (!isEncodedGroup(groupId)) {
|
||||
throw new IOException("Invalid encoding");
|
||||
}
|
||||
|
||||
return Hex.fromStringCondensed(groupId.split("!", 2)[1]);
|
||||
}
|
||||
|
||||
public static boolean isEncodedGroup(String groupId) {
|
||||
return groupId.startsWith(ENCODED_GROUP_PREFIX);
|
||||
}
|
||||
|
||||
}
|
@@ -34,6 +34,12 @@ public class NumberUtil {
|
||||
return PhoneNumberUtils.isWellFormedSmsAddress(number) || isValidEmail(number);
|
||||
}
|
||||
|
||||
public static boolean isValidSmsOrEmailOrGroup(String number) {
|
||||
return PhoneNumberUtils.isWellFormedSmsAddress(number) ||
|
||||
isValidEmail(number) ||
|
||||
GroupUtil.isEncodedGroup(number);
|
||||
}
|
||||
|
||||
public static String filterNumber(String number) {
|
||||
if (number == null) return null;
|
||||
|
||||
|
Reference in New Issue
Block a user