mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-11 17:57:47 +00:00
Remove session id refs
This commit is contained in:
@@ -181,7 +181,7 @@ interface StorageProtocol {
|
||||
fun setLastLegacyRecipient(threadRecipient: String, senderRecipient: String?)
|
||||
|
||||
// Contacts
|
||||
fun getContactWithSessionID(sessionID: String): Contact?
|
||||
fun getContactWithAccountID(accountID: String): Contact?
|
||||
fun getAllContacts(): Set<Contact>
|
||||
fun setContact(contact: Contact)
|
||||
fun getRecipientForThread(threadId: Long): Recipient?
|
||||
|
@@ -2,7 +2,7 @@ package org.session.libsession.messaging.contacts
|
||||
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
|
||||
class Contact(val sessionID: String) {
|
||||
class Contact(val accountID: String) {
|
||||
/**
|
||||
* The URL from which to fetch the contact's profile picture.
|
||||
*/
|
||||
@@ -39,8 +39,8 @@ class Contact(val sessionID: String) {
|
||||
fun displayName(context: ContactContext): String? = nickname ?: when (context) {
|
||||
ContactContext.REGULAR -> name
|
||||
// In open groups, where it's more likely that multiple users have the same name,
|
||||
// we display a bit of the Session ID after a user's display name for added context.
|
||||
ContactContext.OPEN_GROUP -> name?.let { "$it (${sessionID.take(4)}...${sessionID.takeLast(4)})" }
|
||||
// we display a bit of the Account ID after a user's display name for added context.
|
||||
ContactContext.OPEN_GROUP -> name?.let { "$it (${accountID.take(4)}...${accountID.takeLast(4)})" }
|
||||
}
|
||||
|
||||
enum class ContactContext {
|
||||
@@ -54,15 +54,15 @@ class Contact(val sessionID: String) {
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return this.sessionID == (other as? Contact)?.sessionID
|
||||
return this.accountID == (other as? Contact)?.accountID
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return sessionID.hashCode()
|
||||
return accountID.hashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return nickname ?: name ?: sessionID
|
||||
return nickname ?: name ?: accountID
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@@ -95,7 +95,7 @@ class AttachmentDownloadJob(val attachmentID: Long, val databaseMessageID: Long)
|
||||
} else {
|
||||
messageDataProvider.getIndividualRecipientForMms(databaseMessageID)?.address?.serialize()
|
||||
}
|
||||
val contact = sender?.let { storage.getContactWithSessionID(it) }
|
||||
val contact = sender?.let { storage.getContactWithAccountID(it) }
|
||||
if (threadRecipient == null || sender == null || (contact == null && !selfSend)) {
|
||||
handleFailure(Error.NoSender, null)
|
||||
return
|
||||
|
@@ -28,7 +28,7 @@ import org.session.libsession.messaging.sending_receiving.handleOpenGroupReactio
|
||||
import org.session.libsession.messaging.sending_receiving.handleUnsendRequest
|
||||
import org.session.libsession.messaging.sending_receiving.handleVisibleMessage
|
||||
import org.session.libsession.messaging.utilities.Data
|
||||
import org.session.libsession.messaging.utilities.SessionId
|
||||
import org.session.libsession.messaging.utilities.AccountId
|
||||
import org.session.libsession.messaging.utilities.SodiumUtilities
|
||||
import org.session.libsession.utilities.SSKEnvironment
|
||||
import org.session.libsignal.protos.UtilProtos
|
||||
@@ -159,7 +159,7 @@ class BatchMessageReceiveJob(
|
||||
MessagingModuleConfiguration.shared.getUserED25519KeyPair()!!
|
||||
)
|
||||
}?.let {
|
||||
SessionId(
|
||||
AccountId(
|
||||
IdPrefix.BLINDED, it.publicKey.asBytes
|
||||
).hexString
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ object MentionsManager {
|
||||
val userPublicKey = storage.getUserPublicKey()
|
||||
// Gather candidates
|
||||
var candidates: List<Mention> = cache.mapNotNull { publicKey ->
|
||||
val contact = storage.getContactWithSessionID(publicKey)
|
||||
val contact = storage.getContactWithAccountID(publicKey)
|
||||
val displayName = contact?.displayName(context) ?: return@mapNotNull null
|
||||
Mention(publicKey, displayName)
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
import org.session.libsession.messaging.sending_receiving.pollers.OpenGroupPoller.Companion.maxInactivityPeriod
|
||||
import org.session.libsession.messaging.utilities.SessionId
|
||||
import org.session.libsession.messaging.utilities.AccountId
|
||||
import org.session.libsession.messaging.utilities.SodiumUtilities
|
||||
import org.session.libsession.messaging.utilities.SodiumUtilities.sodium
|
||||
import org.session.libsession.snode.OnionRequestAPI
|
||||
@@ -357,7 +357,7 @@ object OpenGroupApi {
|
||||
.plus(bodyHash)
|
||||
if (serverCapabilities.isEmpty() || serverCapabilities.contains(Capability.BLIND.name.lowercase())) {
|
||||
SodiumUtilities.blindedKeyPair(publicKey, ed25519KeyPair)?.let { keyPair ->
|
||||
pubKey = SessionId(
|
||||
pubKey = AccountId(
|
||||
IdPrefix.BLINDED,
|
||||
keyPair.publicKey.asBytes
|
||||
).hexString
|
||||
@@ -370,7 +370,7 @@ object OpenGroupApi {
|
||||
) ?: return Promise.ofFail(Error.SigningFailed)
|
||||
} ?: return Promise.ofFail(Error.SigningFailed)
|
||||
} else {
|
||||
pubKey = SessionId(
|
||||
pubKey = AccountId(
|
||||
IdPrefix.UN_BLINDED,
|
||||
ed25519KeyPair.publicKey.asBytes
|
||||
).hexString
|
||||
@@ -962,12 +962,12 @@ object OpenGroupApi {
|
||||
}
|
||||
}
|
||||
|
||||
fun sendDirectMessage(message: String, blindedSessionId: String, server: String): Promise<DirectMessage, Exception> {
|
||||
fun sendDirectMessage(message: String, blindedAccountId: String, server: String): Promise<DirectMessage, Exception> {
|
||||
val request = Request(
|
||||
verb = POST,
|
||||
room = null,
|
||||
server = server,
|
||||
endpoint = Endpoint.InboxFor(blindedSessionId),
|
||||
endpoint = Endpoint.InboxFor(blindedAccountId),
|
||||
parameters = mapOf("message" to message)
|
||||
)
|
||||
return getResponseBody(request).map { response ->
|
||||
|
@@ -36,7 +36,7 @@ data class OpenGroupMessage(
|
||||
val base64EncodedData = json["data"] as? String ?: return null
|
||||
val sentTimestamp = json["posted"] as? Double ?: return null
|
||||
val serverID = json["id"] as? Int
|
||||
val sender = json["session_id"] as? String
|
||||
val sender = json["account_id"] as? String
|
||||
val base64EncodedSignature = json["signature"] as? String
|
||||
return OpenGroupMessage(
|
||||
serverID = serverID?.toLong(),
|
||||
|
@@ -6,7 +6,7 @@ import com.goterl.lazysodium.interfaces.Box
|
||||
import com.goterl.lazysodium.interfaces.Sign
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
import org.session.libsession.messaging.sending_receiving.MessageReceiver.Error
|
||||
import org.session.libsession.messaging.utilities.SessionId
|
||||
import org.session.libsession.messaging.utilities.AccountId
|
||||
import org.session.libsession.messaging.utilities.SodiumUtilities
|
||||
import org.session.libsession.messaging.utilities.SodiumUtilities.sodium
|
||||
import org.session.libsignal.crypto.ecc.ECKeyPair
|
||||
@@ -58,7 +58,7 @@ object MessageDecrypter {
|
||||
val senderX25519PublicKey = ByteArray(Sign.CURVE25519_PUBLICKEYBYTES)
|
||||
sodium.convertPublicKeyEd25519ToCurve25519(senderX25519PublicKey, senderED25519PublicKey)
|
||||
|
||||
val id = SessionId(IdPrefix.STANDARD, senderX25519PublicKey)
|
||||
val id = AccountId(IdPrefix.STANDARD, senderX25519PublicKey)
|
||||
return Pair(plaintext, id.hexString)
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ object MessageDecrypter {
|
||||
// Get the sender's X25519 public key
|
||||
val senderX25519PublicKey = SodiumUtilities.toX25519(senderEdPublicKey) ?: throw Error.InvalidSignature
|
||||
|
||||
val id = SessionId(IdPrefix.STANDARD, senderX25519PublicKey)
|
||||
val id = AccountId(IdPrefix.STANDARD, senderX25519PublicKey)
|
||||
return Pair(plaintext, id.hexString)
|
||||
}
|
||||
}
|
@@ -19,7 +19,7 @@ object MessageEncrypter {
|
||||
* Encrypts `plaintext` using the Session protocol for `hexEncodedX25519PublicKey`.
|
||||
*
|
||||
* @param plaintext the plaintext to encrypt. Must already be padded.
|
||||
* @param recipientHexEncodedX25519PublicKey the X25519 public key to encrypt for. Could be the Session ID of a user, or the public key of a closed group.
|
||||
* @param recipientHexEncodedX25519PublicKey the X25519 public key to encrypt for. Could be the Account ID of a user, or the public key of a closed group.
|
||||
*
|
||||
* @return the encrypted message.
|
||||
*/
|
||||
|
@@ -13,7 +13,7 @@ import org.session.libsession.messaging.messages.control.SharedConfigurationMess
|
||||
import org.session.libsession.messaging.messages.control.TypingIndicator
|
||||
import org.session.libsession.messaging.messages.control.UnsendRequest
|
||||
import org.session.libsession.messaging.messages.visible.VisibleMessage
|
||||
import org.session.libsession.messaging.utilities.SessionId
|
||||
import org.session.libsession.messaging.utilities.AccountId
|
||||
import org.session.libsession.messaging.utilities.SodiumUtilities
|
||||
import org.session.libsession.snode.SnodeAPI
|
||||
import org.session.libsignal.crypto.PushTransportDetails
|
||||
@@ -147,7 +147,7 @@ object MessageReceiver {
|
||||
SharedConfigurationMessage.fromProto(proto) ?:
|
||||
VisibleMessage.fromProto(proto) ?: throw Error.UnknownMessage
|
||||
|
||||
val isUserBlindedSender = sender == openGroupPublicKey?.let { SodiumUtilities.blindedKeyPair(it, MessagingModuleConfiguration.shared.getUserED25519KeyPair()!!) }?.let { SessionId(IdPrefix.BLINDED, it.publicKey.asBytes).hexString }
|
||||
val isUserBlindedSender = sender == openGroupPublicKey?.let { SodiumUtilities.blindedKeyPair(it, MessagingModuleConfiguration.shared.getUserED25519KeyPair()!!) }?.let { AccountId(IdPrefix.BLINDED, it.publicKey.asBytes).hexString }
|
||||
val isUserSender = sender == userPublicKey
|
||||
|
||||
if (isUserSender || isUserBlindedSender) {
|
||||
|
@@ -24,7 +24,7 @@ import org.session.libsession.messaging.open_groups.OpenGroupApi
|
||||
import org.session.libsession.messaging.open_groups.OpenGroupApi.Capability
|
||||
import org.session.libsession.messaging.open_groups.OpenGroupMessage
|
||||
import org.session.libsession.messaging.utilities.MessageWrapper
|
||||
import org.session.libsession.messaging.utilities.SessionId
|
||||
import org.session.libsession.messaging.utilities.AccountId
|
||||
import org.session.libsession.messaging.utilities.SodiumUtilities
|
||||
import org.session.libsession.snode.RawResponsePromise
|
||||
import org.session.libsession.snode.SnodeAPI
|
||||
@@ -303,9 +303,9 @@ object MessageSender {
|
||||
else -> {}
|
||||
}
|
||||
val messageSender = if (serverCapabilities.contains(Capability.BLIND.name.lowercase()) && blindedPublicKey != null) {
|
||||
SessionId(IdPrefix.BLINDED, blindedPublicKey!!).hexString
|
||||
AccountId(IdPrefix.BLINDED, blindedPublicKey!!).hexString
|
||||
} else {
|
||||
SessionId(IdPrefix.UN_BLINDED, userEdKeyPair.publicKey.asBytes).hexString
|
||||
AccountId(IdPrefix.UN_BLINDED, userEdKeyPair.publicKey.asBytes).hexString
|
||||
}
|
||||
message.sender = messageSender
|
||||
// Set the failure handler (need it here already for precondition failure handling)
|
||||
|
@@ -29,7 +29,7 @@ import org.session.libsession.messaging.sending_receiving.link_preview.LinkPrevi
|
||||
import org.session.libsession.messaging.sending_receiving.notifications.PushRegistryV1
|
||||
import org.session.libsession.messaging.sending_receiving.pollers.ClosedGroupPollerV2
|
||||
import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel
|
||||
import org.session.libsession.messaging.utilities.SessionId
|
||||
import org.session.libsession.messaging.utilities.AccountId
|
||||
import org.session.libsession.messaging.utilities.SodiumUtilities
|
||||
import org.session.libsession.messaging.utilities.WebRtcUtils
|
||||
import org.session.libsession.snode.SnodeAPI
|
||||
@@ -307,7 +307,7 @@ fun MessageReceiver.handleVisibleMessage(
|
||||
val userBlindedKey = openGroupID?.let {
|
||||
val openGroup = storage.getOpenGroup(threadID) ?: return@let null
|
||||
val blindedKey = SodiumUtilities.blindedKeyPair(openGroup.publicKey, MessagingModuleConfiguration.shared.getUserED25519KeyPair()!!) ?: return@let null
|
||||
SessionId(
|
||||
AccountId(
|
||||
IdPrefix.BLINDED, blindedKey.publicKey.asBytes
|
||||
).hexString
|
||||
}
|
||||
@@ -440,7 +440,7 @@ fun MessageReceiver.handleOpenGroupReactions(
|
||||
val openGroup = storage.getOpenGroup(threadId)
|
||||
val blindedPublicKey = openGroup?.publicKey?.let { serverPublicKey ->
|
||||
SodiumUtilities.blindedKeyPair(serverPublicKey, MessagingModuleConfiguration.shared.getUserED25519KeyPair()!!)
|
||||
?.let { SessionId(IdPrefix.BLINDED, it.publicKey.asBytes).hexString }
|
||||
?.let { AccountId(IdPrefix.BLINDED, it.publicKey.asBytes).hexString }
|
||||
}
|
||||
for ((emoji, reaction) in reactions) {
|
||||
val pendingUserReaction = OpenGroupApi.pendingReactions
|
||||
|
@@ -90,7 +90,7 @@ interface Response {
|
||||
|
||||
@Serializable
|
||||
data class PushNotificationMetadata(
|
||||
/** Account ID (such as Session ID or closed group ID) where the message arrived **/
|
||||
/** Account ID (such as Account ID or closed group ID) where the message arrived **/
|
||||
@SerialName("@")
|
||||
val account: String,
|
||||
|
||||
|
@@ -161,14 +161,14 @@ object SodiumUtilities {
|
||||
|
||||
/* This method should be used to check if a users standard sessionId matches a blinded one */
|
||||
fun sessionId(
|
||||
standardSessionId: String,
|
||||
blindedSessionId: String,
|
||||
standardAccountId: String,
|
||||
blindedAccountId: String,
|
||||
serverPublicKey: String
|
||||
): Boolean {
|
||||
// Only support generating blinded keys for standard session ids
|
||||
val sessionId = SessionId(standardSessionId)
|
||||
val sessionId = AccountId(standardAccountId)
|
||||
if (sessionId.prefix != IdPrefix.STANDARD) return false
|
||||
val blindedId = SessionId(blindedSessionId)
|
||||
val blindedId = AccountId(blindedAccountId)
|
||||
if (blindedId.prefix != IdPrefix.BLINDED) return false
|
||||
val k = generateBlindingFactor(serverPublicKey) ?: return false
|
||||
|
||||
@@ -182,8 +182,8 @@ object SodiumUtilities {
|
||||
// For the negative, what we're going to get out of the above is simply the negative of pk1, so flip the sign bit to get pk2
|
||||
// pk2 = pk1[0:31] + bytes([pk1[31] ^ 0b1000_0000])
|
||||
val pk2 = pk1.take(31).toByteArray() + listOf(pk1.last().xor(128.toByte())).toByteArray()
|
||||
return SessionId(IdPrefix.BLINDED, pk1).publicKey == blindedId.publicKey ||
|
||||
SessionId(IdPrefix.BLINDED, pk2).publicKey == blindedId.publicKey
|
||||
return AccountId(IdPrefix.BLINDED, pk1).publicKey == blindedId.publicKey ||
|
||||
AccountId(IdPrefix.BLINDED, pk2).publicKey == blindedId.publicKey
|
||||
}
|
||||
|
||||
fun encrypt(message: ByteArray, secretKey: ByteArray, nonce: ByteArray, additionalData: ByteArray? = null): ByteArray? {
|
||||
@@ -232,7 +232,7 @@ object SodiumUtilities {
|
||||
|
||||
}
|
||||
|
||||
class SessionId {
|
||||
class AccountId {
|
||||
var prefix: IdPrefix?
|
||||
var publicKey: String
|
||||
|
||||
|
@@ -20,7 +20,7 @@ import org.session.libsession.utilities.truncateIdForDisplay
|
||||
object UpdateMessageBuilder {
|
||||
val storage = MessagingModuleConfiguration.shared.storage
|
||||
|
||||
private fun getSenderName(senderId: String) = storage.getContactWithSessionID(senderId)
|
||||
private fun getSenderName(senderId: String) = storage.getContactWithAccountID(senderId)
|
||||
?.displayName(Contact.ContactContext.REGULAR)
|
||||
?: truncateIdForDisplay(senderId)
|
||||
|
||||
@@ -106,6 +106,6 @@ object UpdateMessageBuilder {
|
||||
CALL_OUTGOING -> R.string.MessageRecord_called_s
|
||||
CALL_MISSED, CALL_FIRST_MISSED -> R.string.MessageRecord_missed_call_from
|
||||
}.let {
|
||||
context.getString(it, storage.getContactWithSessionID(sender)?.displayName(Contact.ContactContext.REGULAR) ?: sender)
|
||||
context.getString(it, storage.getContactWithAccountID(sender)?.displayName(Contact.ContactContext.REGULAR) ?: sender)
|
||||
}
|
||||
}
|
||||
|
@@ -220,11 +220,11 @@ object SnodeAPI {
|
||||
}
|
||||
|
||||
// Public API
|
||||
fun getSessionID(onsName: String): Promise<String, Exception> {
|
||||
fun getAccountID(onsName: String): Promise<String, Exception> {
|
||||
val deferred = deferred<String, Exception>()
|
||||
val promise = deferred.promise
|
||||
val validationCount = 3
|
||||
val sessionIDByteCount = 33
|
||||
val accountIDByteCount = 33
|
||||
// Hash the ONS name using BLAKE2b
|
||||
val onsName = onsName.toLowerCase(Locale.US)
|
||||
val nameAsData = onsName.toByteArray()
|
||||
@@ -234,7 +234,7 @@ object SnodeAPI {
|
||||
return promise
|
||||
}
|
||||
val base64EncodedNameHash = Base64.encodeBytes(nameHash)
|
||||
// Ask 3 different snodes for the Session ID associated with the given name hash
|
||||
// Ask 3 different snodes for the Account ID associated with the given name hash
|
||||
val parameters = mapOf(
|
||||
"endpoint" to "ons_resolve",
|
||||
"params" to mapOf( "type" to 0, "name_hash" to base64EncodedNameHash )
|
||||
@@ -247,7 +247,7 @@ object SnodeAPI {
|
||||
}
|
||||
}
|
||||
all(promises).success { results ->
|
||||
val sessionIDs = mutableListOf<String>()
|
||||
val accountIDs = mutableListOf<String>()
|
||||
for (json in results) {
|
||||
val intermediate = json["result"] as? Map<*, *>
|
||||
val hexEncodedCiphertext = intermediate?.get("encrypted_value") as? String
|
||||
@@ -259,18 +259,18 @@ object SnodeAPI {
|
||||
val salt = ByteArray(PwHash.SALTBYTES)
|
||||
val key: ByteArray
|
||||
val nonce = ByteArray(SecretBox.NONCEBYTES)
|
||||
val sessionIDAsData = ByteArray(sessionIDByteCount)
|
||||
val accountIDAsData = ByteArray(accountIDByteCount)
|
||||
try {
|
||||
key = Key.fromHexString(sodium.cryptoPwHash(onsName, SecretBox.KEYBYTES, salt, PwHash.OPSLIMIT_MODERATE, PwHash.MEMLIMIT_MODERATE, PwHash.Alg.PWHASH_ALG_ARGON2ID13)).asBytes
|
||||
} catch (e: SodiumException) {
|
||||
deferred.reject(Error.HashingFailed)
|
||||
return@success
|
||||
}
|
||||
if (!sodium.cryptoSecretBoxOpenEasy(sessionIDAsData, ciphertext, ciphertext.size.toLong(), nonce, key)) {
|
||||
if (!sodium.cryptoSecretBoxOpenEasy(accountIDAsData, ciphertext, ciphertext.size.toLong(), nonce, key)) {
|
||||
deferred.reject(Error.DecryptionFailed)
|
||||
return@success
|
||||
}
|
||||
sessionIDs.add(Hex.toStringCondensed(sessionIDAsData))
|
||||
accountIDs.add(Hex.toStringCondensed(accountIDAsData))
|
||||
} else {
|
||||
val hexEncodedNonce = intermediate["nonce"] as? String
|
||||
if (hexEncodedNonce == null) {
|
||||
@@ -283,20 +283,20 @@ object SnodeAPI {
|
||||
deferred.reject(Error.HashingFailed)
|
||||
return@success
|
||||
}
|
||||
val sessionIDAsData = ByteArray(sessionIDByteCount)
|
||||
if (!sodium.cryptoAeadXChaCha20Poly1305IetfDecrypt(sessionIDAsData, null, null, ciphertext, ciphertext.size.toLong(), null, 0, nonce, key)) {
|
||||
val accountIDAsData = ByteArray(accountIDByteCount)
|
||||
if (!sodium.cryptoAeadXChaCha20Poly1305IetfDecrypt(accountIDAsData, null, null, ciphertext, ciphertext.size.toLong(), null, 0, nonce, key)) {
|
||||
deferred.reject(Error.DecryptionFailed)
|
||||
return@success
|
||||
}
|
||||
sessionIDs.add(Hex.toStringCondensed(sessionIDAsData))
|
||||
accountIDs.add(Hex.toStringCondensed(accountIDAsData))
|
||||
}
|
||||
} else {
|
||||
deferred.reject(Error.Generic)
|
||||
return@success
|
||||
}
|
||||
}
|
||||
if (sessionIDs.size == validationCount && sessionIDs.toSet().size == 1) {
|
||||
deferred.resolve(sessionIDs.first())
|
||||
if (accountIDs.size == validationCount && accountIDs.toSet().size == 1) {
|
||||
deferred.resolve(accountIDs.first())
|
||||
} else {
|
||||
deferred.reject(Error.ValidationFailed)
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package org.session.libsession.utilities
|
||||
|
||||
import org.session.libsession.messaging.open_groups.OpenGroup
|
||||
import org.session.libsession.messaging.utilities.SessionId
|
||||
import org.session.libsession.messaging.utilities.AccountId
|
||||
import org.session.libsignal.messages.SignalServiceGroup
|
||||
import org.session.libsignal.utilities.Hex
|
||||
import java.io.IOException
|
||||
@@ -17,7 +17,7 @@ object GroupUtil {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getEncodedOpenGroupInboxID(openGroup: OpenGroup, sessionId: SessionId): Address {
|
||||
fun getEncodedOpenGroupInboxID(openGroup: OpenGroup, sessionId: AccountId): Address {
|
||||
val openGroupInboxId =
|
||||
"${openGroup.server}!${openGroup.publicKey}!${sessionId.hexString}".toByteArray()
|
||||
return getEncodedOpenGroupInboxID(openGroupInboxId)
|
||||
@@ -60,7 +60,7 @@ object GroupUtil {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getDecodedOpenGroupInboxSessionId(groupID: String): String {
|
||||
fun getDecodedOpenGroupInboxAccountId(groupID: String): String {
|
||||
val decodedGroupId = getDecodedGroupID(groupID)
|
||||
if (decodedGroupId.split("!").count() > 2) {
|
||||
return decodedGroupId.split("!", limit = 3)[2]
|
||||
@@ -112,7 +112,7 @@ object GroupUtil {
|
||||
Hex.toStringCondensed(getDecodedGroupIDAsData(getDecodedGroupID(groupID)))
|
||||
|
||||
@JvmStatic
|
||||
fun addressToGroupSessionId(address: Address): String =
|
||||
fun addressToGroupAccountId(address: Address): String =
|
||||
doubleDecodeGroupId(address.toGroupString())
|
||||
|
||||
fun createConfigMemberMap(
|
||||
|
@@ -317,7 +317,7 @@ public class Recipient implements RecipientModifiedListener {
|
||||
|
||||
public synchronized @Nullable String getName() {
|
||||
StorageProtocol storage = MessagingModuleConfiguration.getShared().getStorage();
|
||||
String sessionID = this.address.toString();
|
||||
String accountID = this.address.toString();
|
||||
if (isGroupRecipient()) {
|
||||
if (this.name == null) {
|
||||
List<String> names = new LinkedList<>();
|
||||
@@ -329,12 +329,12 @@ public class Recipient implements RecipientModifiedListener {
|
||||
return this.name;
|
||||
}
|
||||
} else if (isOpenGroupInboxRecipient()){
|
||||
String inboxID = GroupUtil.getDecodedOpenGroupInboxSessionId(sessionID);
|
||||
Contact contact = storage.getContactWithSessionID(inboxID);
|
||||
if (contact == null) { return sessionID; }
|
||||
String inboxID = GroupUtil.getDecodedOpenGroupInboxAccountId(accountID);
|
||||
Contact contact = storage.getContactWithAccountID(inboxID);
|
||||
if (contact == null) { return accountID; }
|
||||
return contact.displayName(Contact.ContactContext.REGULAR);
|
||||
} else {
|
||||
Contact contact = storage.getContactWithSessionID(sessionID);
|
||||
Contact contact = storage.getContactWithAccountID(accountID);
|
||||
if (contact == null) { return null; }
|
||||
return contact.displayName(Contact.ContactContext.REGULAR);
|
||||
}
|
||||
|
Reference in New Issue
Block a user