mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 02:55:23 +00:00
Rename remaining session id refs
This commit is contained in:
parent
ce1790a895
commit
8245e4ffe5
@ -136,29 +136,29 @@ class SodiumUtilitiesTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sessionIdSuccess() {
|
||||
val result = SodiumUtilities.sessionId("05$publicKey", "15$blindedPublicKey", serverPublicKey)
|
||||
fun accountIdSuccess() {
|
||||
val result = SodiumUtilities.accountId("05$publicKey", "15$blindedPublicKey", serverPublicKey)
|
||||
|
||||
assertTrue(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sessionIdFailureInvalidAccountId() {
|
||||
val result = SodiumUtilities.sessionId("AB$publicKey", "15$blindedPublicKey", serverPublicKey)
|
||||
fun accountIdFailureInvalidAccountId() {
|
||||
val result = SodiumUtilities.accountId("AB$publicKey", "15$blindedPublicKey", serverPublicKey)
|
||||
|
||||
assertFalse(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sessionIdFailureInvalidBlindedId() {
|
||||
val result = SodiumUtilities.sessionId("05$publicKey", "AB$blindedPublicKey", serverPublicKey)
|
||||
fun accountIdFailureInvalidBlindedId() {
|
||||
val result = SodiumUtilities.accountId("05$publicKey", "AB$blindedPublicKey", serverPublicKey)
|
||||
|
||||
assertFalse(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sessionIdFailureBlindingFactor() {
|
||||
val result = SodiumUtilities.sessionId("05$publicKey", "15$blindedPublicKey", "Test")
|
||||
fun accountIdFailureBlindingFactor() {
|
||||
val result = SodiumUtilities.accountId("05$publicKey", "15$blindedPublicKey", "Test")
|
||||
|
||||
assertFalse(result)
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class NewMessageFragment : Fragment() {
|
||||
viewModel,
|
||||
onClose = { delegate.onDialogClosePressed() },
|
||||
onBack = { delegate.onDialogBackPressed() },
|
||||
onHelp = { requireContext().openUrl("https://sessionapp.zendesk.com/hc/en-us/articles/4439132747033-How-do-Session-ID-usernames-work") }
|
||||
onHelp = { requireContext().openUrl("https://sessionapp.zendesk.com/hc/en-us/articles/4439132747033-How-do-Account-ID-usernames-work") }
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -239,12 +239,12 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
intent.getParcelableExtra<Address>(ADDRESS)?.let { it ->
|
||||
threadId = threadDb.getThreadIdIfExistsFor(it.serialize())
|
||||
if (threadId == -1L) {
|
||||
val sessionId = AccountId(it.serialize())
|
||||
val accountId = AccountId(it.serialize())
|
||||
val openGroup = lokiThreadDb.getOpenGroupChat(intent.getLongExtra(FROM_GROUP_THREAD_ID, -1))
|
||||
val address = if (sessionId.prefix == IdPrefix.BLINDED && openGroup != null) {
|
||||
storage.getOrCreateBlindedIdMapping(sessionId.hexString, openGroup.server, openGroup.publicKey).sessionId?.let {
|
||||
val address = if (accountId.prefix == IdPrefix.BLINDED && openGroup != null) {
|
||||
storage.getOrCreateBlindedIdMapping(accountId.hexString, openGroup.server, openGroup.publicKey).accountId?.let {
|
||||
fromSerialized(it)
|
||||
} ?: GroupUtil.getEncodedOpenGroupInboxID(openGroup, sessionId)
|
||||
} ?: GroupUtil.getEncodedOpenGroupInboxID(openGroup, accountId)
|
||||
} else {
|
||||
it
|
||||
}
|
||||
@ -1131,8 +1131,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
}
|
||||
}
|
||||
|
||||
override fun copyAccountID(sessionId: String) {
|
||||
val clip = ClipData.newPlainText("Account ID", sessionId)
|
||||
override fun copyAccountID(accountId: String) {
|
||||
val clip = ClipData.newPlainText("Account ID", accountId)
|
||||
val manager = getSystemService(PassphraseRequiredActionBarActivity.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
manager.setPrimaryClip(clip)
|
||||
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
|
||||
|
@ -57,7 +57,7 @@ object ConversationMenuHelper {
|
||||
if (!isOpenGroup && (thread.hasApprovedMe() || thread.isClosedGroupRecipient || thread.isLocalNumber)) {
|
||||
inflater.inflate(R.menu.menu_conversation_expiration, menu)
|
||||
}
|
||||
// One-on-one chat menu allows copying the session id
|
||||
// One-on-one chat menu allows copying the account id
|
||||
if (thread.isContactRecipient) {
|
||||
inflater.inflate(R.menu.menu_conversation_copy_account_id, menu)
|
||||
}
|
||||
@ -325,7 +325,7 @@ object ConversationMenuHelper {
|
||||
interface ConversationMenuListener {
|
||||
fun block(deleteThread: Boolean = false)
|
||||
fun unblock()
|
||||
fun copyAccountID(sessionId: String)
|
||||
fun copyAccountID(accountId: String)
|
||||
fun copyOpenGroupUrl(thread: Recipient)
|
||||
fun showDisappearingMessages(thread: Recipient)
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ object MentionUtilities {
|
||||
}
|
||||
|
||||
private fun isYou(mentionedPublicKey: String, userPublicKey: String, openGroup: OpenGroup?): Boolean {
|
||||
val isUserBlindedPublicKey = openGroup?.let { SodiumUtilities.sessionId(userPublicKey, mentionedPublicKey, it.publicKey) } ?: false
|
||||
val isUserBlindedPublicKey = openGroup?.let { SodiumUtilities.accountId(userPublicKey, mentionedPublicKey, it.publicKey) } ?: false
|
||||
return mentionedPublicKey.equals(userPublicKey, ignoreCase = true) || isUserBlindedPublicKey
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ class BlindedIdMappingDatabase(context: Context, helper: SQLCipherOpenHelper) :
|
||||
private fun readBlindedIdMapping(cursor: Cursor): BlindedIdMapping {
|
||||
return BlindedIdMapping(
|
||||
blindedId = cursor.getString(cursor.getColumnIndexOrThrow(BLINDED_PK)),
|
||||
sessionId = cursor.getStringOrNull(cursor.getColumnIndexOrThrow(SESSION_PK)),
|
||||
accountId = cursor.getStringOrNull(cursor.getColumnIndexOrThrow(SESSION_PK)),
|
||||
serverUrl = cursor.getString(cursor.getColumnIndexOrThrow(SERVER_URL)),
|
||||
serverId = cursor.getString(cursor.getColumnIndexOrThrow(SERVER_PK)),
|
||||
)
|
||||
@ -58,7 +58,7 @@ class BlindedIdMappingDatabase(context: Context, helper: SQLCipherOpenHelper) :
|
||||
try {
|
||||
val values = ContentValues().apply {
|
||||
put(BLINDED_PK, blindedIdMapping.blindedId)
|
||||
put(SERVER_PK, blindedIdMapping.sessionId)
|
||||
put(SERVER_PK, blindedIdMapping.accountId)
|
||||
put(SERVER_URL, blindedIdMapping.serverUrl)
|
||||
put(SERVER_PK, blindedIdMapping.serverId)
|
||||
}
|
||||
|
@ -42,12 +42,12 @@ class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Da
|
||||
}
|
||||
}
|
||||
|
||||
fun getContacts(sessionIDs: Collection<String>): List<Contact> {
|
||||
fun getContacts(accountIDs: Collection<String>): List<Contact> {
|
||||
val database = databaseHelper.readableDatabase
|
||||
return database.getAll(
|
||||
sessionContactTable,
|
||||
"$accountID IN (SELECT value FROM json_each(?))",
|
||||
arrayOf(JSONArray(sessionIDs).toString())
|
||||
arrayOf(JSONArray(accountIDs).toString())
|
||||
) { cursor -> contactFromCursor(cursor) }
|
||||
}
|
||||
|
||||
@ -56,8 +56,7 @@ class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Da
|
||||
return database.getAll(sessionContactTable, null, null) { cursor ->
|
||||
contactFromCursor(cursor)
|
||||
}.filter { contact ->
|
||||
val sessionId = AccountId(contact.accountID)
|
||||
sessionId.prefix == IdPrefix.STANDARD
|
||||
contact.accountID.let(::AccountId).prefix == IdPrefix.STANDARD
|
||||
}.toSet()
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import java.security.MessageDigest
|
||||
import network.loki.messenger.libsession_util.ConfigBase
|
||||
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_HIDDEN
|
||||
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_PINNED
|
||||
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_VISIBLE
|
||||
import network.loki.messenger.libsession_util.Contacts
|
||||
import network.loki.messenger.libsession_util.ConversationVolatileConfig
|
||||
import network.loki.messenger.libsession_util.UserGroupsConfig
|
||||
@ -111,12 +112,12 @@ open class Storage(
|
||||
if (address.isGroup) {
|
||||
val groups = configFactory.userGroups ?: return
|
||||
if (address.isClosedGroup) {
|
||||
val sessionId = GroupUtil.doubleDecodeGroupId(address.serialize())
|
||||
val accountId = GroupUtil.doubleDecodeGroupId(address.serialize())
|
||||
val closedGroup = getGroup(address.toGroupString())
|
||||
if (closedGroup != null && closedGroup.isActive) {
|
||||
val legacyGroup = groups.getOrConstructLegacyGroupInfo(sessionId)
|
||||
val legacyGroup = groups.getOrConstructLegacyGroupInfo(accountId)
|
||||
groups.set(legacyGroup)
|
||||
val newVolatileParams = volatile.getOrConstructLegacyGroup(sessionId).copy(
|
||||
val newVolatileParams = volatile.getOrConstructLegacyGroup(accountId).copy(
|
||||
lastRead = SnodeAPI.nowWithOffset,
|
||||
)
|
||||
volatile.set(newVolatileParams)
|
||||
@ -132,11 +133,11 @@ open class Storage(
|
||||
if (getUserPublicKey() != address.serialize()) {
|
||||
val contacts = configFactory.contacts ?: return
|
||||
contacts.upsertContact(address.serialize()) {
|
||||
priority = ConfigBase.PRIORITY_VISIBLE
|
||||
priority = PRIORITY_VISIBLE
|
||||
}
|
||||
} else {
|
||||
val userProfile = configFactory.user ?: return
|
||||
userProfile.setNtsPriority(ConfigBase.PRIORITY_VISIBLE)
|
||||
userProfile.setNtsPriority(PRIORITY_VISIBLE)
|
||||
DatabaseComponent.get(context).threadDatabase().setHasSent(threadId, true)
|
||||
}
|
||||
val newVolatileParams = volatile.getOrConstructOneToOne(address.serialize())
|
||||
@ -149,9 +150,9 @@ open class Storage(
|
||||
if (address.isGroup) {
|
||||
val groups = configFactory.userGroups ?: return
|
||||
if (address.isClosedGroup) {
|
||||
val sessionId = GroupUtil.doubleDecodeGroupId(address.serialize())
|
||||
volatile.eraseLegacyClosedGroup(sessionId)
|
||||
groups.eraseLegacyGroup(sessionId)
|
||||
val accountId = GroupUtil.doubleDecodeGroupId(address.serialize())
|
||||
volatile.eraseLegacyClosedGroup(accountId)
|
||||
groups.eraseLegacyGroup(accountId)
|
||||
} else if (address.isCommunity) {
|
||||
// these should be removed in the group leave / handling new configs
|
||||
Log.w("Loki", "Thread delete called for open group address, expecting to be handled elsewhere")
|
||||
@ -265,10 +266,8 @@ open class Storage(
|
||||
}
|
||||
// otherwise recipient is one to one
|
||||
recipient.isContactRecipient -> {
|
||||
// don't process non-standard session IDs though
|
||||
val sessionId = AccountId(recipient.address.serialize())
|
||||
if (sessionId.prefix != IdPrefix.STANDARD) return
|
||||
|
||||
// don't process non-standard account IDs though
|
||||
if (AccountId(recipient.address.serialize()).prefix != IdPrefix.STANDARD) return
|
||||
config.getOrConstructOneToOne(recipient.address.serialize())
|
||||
}
|
||||
else -> throw NullPointerException("Weren't expecting to have a convo with address ${recipient.address.serialize()}")
|
||||
@ -299,8 +298,8 @@ open class Storage(
|
||||
var messageID: Long? = null
|
||||
val senderAddress = fromSerialized(message.sender!!)
|
||||
val isUserSender = (message.sender!! == getUserPublicKey())
|
||||
val isUserBlindedSender = message.threadID?.takeIf { it >= 0 }?.let { getOpenGroup(it)?.publicKey }
|
||||
?.let { SodiumUtilities.sessionId(getUserPublicKey()!!, message.sender!!, it) } ?: false
|
||||
val isUserBlindedSender = message.threadID?.takeIf { it >= 0 }?.let(::getOpenGroup)?.publicKey
|
||||
?.let { SodiumUtilities.accountId(getUserPublicKey()!!, message.sender!!, it) } ?: false
|
||||
val group: Optional<SignalServiceGroup> = when {
|
||||
openGroupID != null -> Optional.of(SignalServiceGroup(openGroupID.toByteArray(), SignalServiceGroup.GroupType.PUBLIC_CHAT))
|
||||
groupPublicKey != null -> {
|
||||
@ -540,7 +539,7 @@ open class Storage(
|
||||
val extracted = convos.all()
|
||||
for (conversation in extracted) {
|
||||
val threadId = when (conversation) {
|
||||
is Conversation.OneToOne -> getThreadIdFor(conversation.sessionId, null, null, createThread = false)
|
||||
is Conversation.OneToOne -> getThreadIdFor(conversation.accountId, null, null, createThread = false)
|
||||
is Conversation.LegacyGroup -> getThreadIdFor("", conversation.groupId,null, createThread = false)
|
||||
is Conversation.Community -> getThreadIdFor("",null, "${conversation.baseCommunityInfo.baseUrl.removeSuffix("/")}.${conversation.baseCommunityInfo.room}", createThread = false)
|
||||
}
|
||||
@ -571,7 +570,7 @@ open class Storage(
|
||||
val existingJoinUrls = existingCommunities.values.map { it.joinURL }
|
||||
|
||||
val existingClosedGroups = getAllGroups(includeInactive = true).filter { it.isClosedGroup }
|
||||
val lgcIds = lgc.map { it.sessionId }
|
||||
val lgcIds = lgc.map { it.accountId }
|
||||
val toDeleteClosedGroups = existingClosedGroups.filter { group ->
|
||||
GroupUtil.doubleDecodeGroupId(group.encodedId) !in lgcIds
|
||||
}
|
||||
@ -605,8 +604,8 @@ open class Storage(
|
||||
}
|
||||
|
||||
for (group in lgc) {
|
||||
val groupId = GroupUtil.doubleEncodeGroupID(group.sessionId)
|
||||
val existingGroup = existingClosedGroups.firstOrNull { GroupUtil.doubleDecodeGroupId(it.encodedId) == group.sessionId }
|
||||
val groupId = GroupUtil.doubleEncodeGroupID(group.accountId)
|
||||
val existingGroup = existingClosedGroups.firstOrNull { GroupUtil.doubleDecodeGroupId(it.encodedId) == group.accountId }
|
||||
val existingThread = existingGroup?.let { getThreadId(existingGroup.encodedId) }
|
||||
if (existingGroup != null) {
|
||||
if (group.priority == PRIORITY_HIDDEN && existingThread != null) {
|
||||
@ -625,19 +624,19 @@ open class Storage(
|
||||
createGroup(groupId, title, admins + members, null, null, admins, formationTimestamp)
|
||||
setProfileSharing(Address.fromSerialized(groupId), true)
|
||||
// Add the group to the user's set of public keys to poll for
|
||||
addClosedGroupPublicKey(group.sessionId)
|
||||
addClosedGroupPublicKey(group.accountId)
|
||||
// Store the encryption key pair
|
||||
val keyPair = ECKeyPair(DjbECPublicKey(group.encPubKey), DjbECPrivateKey(group.encSecKey))
|
||||
addClosedGroupEncryptionKeyPair(keyPair, group.sessionId, SnodeAPI.nowWithOffset)
|
||||
addClosedGroupEncryptionKeyPair(keyPair, group.accountId, SnodeAPI.nowWithOffset)
|
||||
// Notify the PN server
|
||||
PushRegistryV1.subscribeGroup(group.sessionId, publicKey = localUserPublicKey)
|
||||
PushRegistryV1.subscribeGroup(group.accountId, publicKey = localUserPublicKey)
|
||||
// Notify the user
|
||||
val threadID = getOrCreateThreadIdFor(Address.fromSerialized(groupId))
|
||||
threadDb.setDate(threadID, formationTimestamp)
|
||||
insertOutgoingInfoMessage(context, groupId, SignalServiceGroup.Type.CREATION, title, members.map { it.serialize() }, admins.map { it.serialize() }, threadID, formationTimestamp)
|
||||
// Don't create config group here, it's from a config update
|
||||
// Start polling
|
||||
ClosedGroupPollerV2.shared.startPolling(group.sessionId)
|
||||
ClosedGroupPollerV2.shared.startPolling(group.accountId)
|
||||
}
|
||||
getThreadId(Address.fromSerialized(groupId))?.let {
|
||||
setExpirationConfiguration(
|
||||
@ -938,10 +937,10 @@ open class Storage(
|
||||
groupVolatileConfig.lastRead = formationTimestamp
|
||||
volatiles.set(groupVolatileConfig)
|
||||
val groupInfo = GroupInfo.LegacyGroupInfo(
|
||||
sessionId = groupPublicKey,
|
||||
accountId = groupPublicKey,
|
||||
name = name,
|
||||
members = members,
|
||||
priority = ConfigBase.PRIORITY_VISIBLE,
|
||||
priority = PRIORITY_VISIBLE,
|
||||
encPubKey = (encryptionKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte
|
||||
encSecKey = encryptionKeyPair.privateKey.serialize(),
|
||||
disappearingTimer = expirationTimer.toLong(),
|
||||
@ -975,7 +974,7 @@ open class Storage(
|
||||
members = membersMap,
|
||||
encPubKey = (latestKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte
|
||||
encSecKey = latestKeyPair.privateKey.serialize(),
|
||||
priority = if (isPinned(threadID)) PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE,
|
||||
priority = if (isPinned(threadID)) PRIORITY_PINNED else PRIORITY_VISIBLE,
|
||||
disappearingTimer = getExpirationConfiguration(threadID)?.expiryMode?.expirySeconds ?: 0L,
|
||||
joinedAt = (existingGroup.formationTimestamp / 1000L)
|
||||
)
|
||||
@ -1209,7 +1208,7 @@ open class Storage(
|
||||
val mappingDb = DatabaseComponent.get(context).blindedIdMappingDatabase()
|
||||
val moreContacts = contacts.filter { contact ->
|
||||
val id = AccountId(contact.id)
|
||||
id.prefix?.isBlinded() == false || mappingDb.getBlindedIdMapping(contact.id).none { it.sessionId != null }
|
||||
id.prefix?.isBlinded() == false || mappingDb.getBlindedIdMapping(contact.id).none { it.accountId != null }
|
||||
}
|
||||
val profileManager = SSKEnvironment.shared.profileManager
|
||||
moreContacts.forEach { contact ->
|
||||
@ -1262,7 +1261,7 @@ open class Storage(
|
||||
val mappingDb = DatabaseComponent.get(context).blindedIdMappingDatabase()
|
||||
val moreContacts = contacts.filter { contact ->
|
||||
val id = AccountId(contact.publicKey)
|
||||
id.prefix != IdPrefix.BLINDED || mappingDb.getBlindedIdMapping(contact.publicKey).none { it.sessionId != null }
|
||||
id.prefix != IdPrefix.BLINDED || mappingDb.getBlindedIdMapping(contact.publicKey).none { it.accountId != null }
|
||||
}
|
||||
for (contact in moreContacts) {
|
||||
val address = fromSerialized(contact.publicKey)
|
||||
@ -1329,25 +1328,25 @@ open class Storage(
|
||||
val threadRecipient = getRecipientForThread(threadID) ?: return
|
||||
if (threadRecipient.isLocalNumber) {
|
||||
val user = configFactory.user ?: return
|
||||
user.setNtsPriority(if (isPinned) PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE)
|
||||
user.setNtsPriority(if (isPinned) PRIORITY_PINNED else PRIORITY_VISIBLE)
|
||||
} else if (threadRecipient.isContactRecipient) {
|
||||
val contacts = configFactory.contacts ?: return
|
||||
contacts.upsertContact(threadRecipient.address.serialize()) {
|
||||
priority = if (isPinned) PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE
|
||||
priority = if (isPinned) PRIORITY_PINNED else PRIORITY_VISIBLE
|
||||
}
|
||||
} else if (threadRecipient.isGroupRecipient) {
|
||||
val groups = configFactory.userGroups ?: return
|
||||
if (threadRecipient.isClosedGroupRecipient) {
|
||||
val sessionId = GroupUtil.doubleDecodeGroupId(threadRecipient.address.serialize())
|
||||
val newGroupInfo = groups.getOrConstructLegacyGroupInfo(sessionId).copy (
|
||||
priority = if (isPinned) PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE
|
||||
)
|
||||
groups.set(newGroupInfo)
|
||||
threadRecipient.address.serialize()
|
||||
.let(GroupUtil::doubleDecodeGroupId)
|
||||
.let(groups::getOrConstructLegacyGroupInfo)
|
||||
.copy (priority = if (isPinned) PRIORITY_PINNED else PRIORITY_VISIBLE)
|
||||
.let(groups::set)
|
||||
} else if (threadRecipient.isCommunityRecipient) {
|
||||
val openGroup = getOpenGroup(threadID) ?: return
|
||||
val (baseUrl, room, pubKeyHex) = BaseCommunityInfo.parseFullUrl(openGroup.joinURL) ?: return
|
||||
val newGroupInfo = groups.getOrConstructCommunityInfo(baseUrl, room, Hex.toStringCondensed(pubKeyHex)).copy (
|
||||
priority = if (isPinned) PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE
|
||||
priority = if (isPinned) PRIORITY_PINNED else PRIORITY_VISIBLE
|
||||
)
|
||||
groups.set(newGroupInfo)
|
||||
}
|
||||
@ -1505,10 +1504,10 @@ open class Storage(
|
||||
}
|
||||
}
|
||||
for (mapping in mappings) {
|
||||
if (!SodiumUtilities.sessionId(senderPublicKey, mapping.value.blindedId, mapping.value.serverId)) {
|
||||
if (!SodiumUtilities.accountId(senderPublicKey, mapping.value.blindedId, mapping.value.serverId)) {
|
||||
continue
|
||||
}
|
||||
mappingDb.addBlindedIdMapping(mapping.value.copy(sessionId = senderPublicKey))
|
||||
mappingDb.addBlindedIdMapping(mapping.value.copy(accountId = senderPublicKey))
|
||||
|
||||
val blindedThreadId = threadDB.getOrCreateThreadIdFor(Recipient.from(context, fromSerialized(mapping.key), false))
|
||||
mmsDb.updateThreadId(blindedThreadId, threadId)
|
||||
@ -1614,20 +1613,20 @@ open class Storage(
|
||||
): BlindedIdMapping {
|
||||
val db = DatabaseComponent.get(context).blindedIdMappingDatabase()
|
||||
val mapping = db.getBlindedIdMapping(blindedId).firstOrNull() ?: BlindedIdMapping(blindedId, null, server, serverPublicKey)
|
||||
if (mapping.sessionId != null) {
|
||||
if (mapping.accountId != null) {
|
||||
return mapping
|
||||
}
|
||||
getAllContacts().forEach { contact ->
|
||||
val sessionId = AccountId(contact.accountID)
|
||||
if (sessionId.prefix == IdPrefix.STANDARD && SodiumUtilities.sessionId(sessionId.hexString, blindedId, serverPublicKey)) {
|
||||
val contactMapping = mapping.copy(sessionId = sessionId.hexString)
|
||||
val accountId = AccountId(contact.accountID)
|
||||
if (accountId.prefix == IdPrefix.STANDARD && SodiumUtilities.accountId(accountId.hexString, blindedId, serverPublicKey)) {
|
||||
val contactMapping = mapping.copy(accountId = accountId.hexString)
|
||||
db.addBlindedIdMapping(contactMapping)
|
||||
return contactMapping
|
||||
}
|
||||
}
|
||||
db.getBlindedIdMappingsExceptFor(server).forEach {
|
||||
if (SodiumUtilities.sessionId(it.sessionId!!, blindedId, serverPublicKey)) {
|
||||
val otherMapping = mapping.copy(sessionId = it.sessionId)
|
||||
if (SodiumUtilities.accountId(it.accountId!!, blindedId, serverPublicKey)) {
|
||||
val otherMapping = mapping.copy(accountId = it.accountId)
|
||||
db.addBlindedIdMapping(otherMapping)
|
||||
return otherMapping
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class QRCodeActivity : PassphraseRequiredActionBarActivity() {
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun Tabs(sessionId: String, errors: Flow<String>, onScan: (String) -> Unit) {
|
||||
private fun Tabs(accountId: String, errors: Flow<String>, onScan: (String) -> Unit) {
|
||||
val pagerState = rememberPagerState { TITLES.size }
|
||||
|
||||
Column {
|
||||
@ -82,7 +82,7 @@ private fun Tabs(sessionId: String, errors: Flow<String>, onScan: (String) -> Un
|
||||
modifier = Modifier.weight(1f)
|
||||
) { page ->
|
||||
when (TITLES[page]) {
|
||||
R.string.view -> QrPage(sessionId)
|
||||
R.string.view -> QrPage(accountId)
|
||||
R.string.scan -> MaybeScanQrCode(errors, onScan = onScan)
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ class DefaultConversationRepository @Inject constructor(
|
||||
|
||||
override suspend fun banAndDeleteAll(threadId: Long, recipient: Recipient): ResultOf<Unit> =
|
||||
suspendCoroutine { continuation ->
|
||||
// Note: This sessionId could be the blinded Id
|
||||
// Note: This accountId could be the blinded Id
|
||||
val accountID = recipient.address.toString()
|
||||
val openGroup = lokiThreadDb.getOpenGroupChat(threadId)!!
|
||||
|
||||
|
@ -92,8 +92,8 @@ class ProfileManager(private val context: Context, private val configFactory: Co
|
||||
override fun contactUpdatedInternal(contact: Contact): String? {
|
||||
val contactConfig = configFactory.contacts ?: return null
|
||||
if (contact.accountID == TextSecurePreferences.getLocalNumber(context)) return null
|
||||
val sessionId = AccountId(contact.accountID)
|
||||
if (sessionId.prefix != IdPrefix.STANDARD) return null // only internally store standard session IDs
|
||||
val accountId = AccountId(contact.accountID)
|
||||
if (accountId.prefix != IdPrefix.STANDARD) return null // only internally store standard account IDs
|
||||
contactConfig.upsertContact(contact.accountID) {
|
||||
this.name = contact.name.orEmpty()
|
||||
this.nickname = contact.nickname.orEmpty()
|
||||
|
@ -205,7 +205,7 @@ object ConfigurationMessageUtilities {
|
||||
val admins = group.admins.map { it.serialize() to true }.toMap()
|
||||
val members = group.members.filterNot { it.serialize() !in admins.keys }.map { it.serialize() to false }.toMap()
|
||||
GroupInfo.LegacyGroupInfo(
|
||||
sessionId = groupPublicKey,
|
||||
accountId = groupPublicKey,
|
||||
name = group.title,
|
||||
members = admins + members,
|
||||
priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE,
|
||||
|
@ -566,7 +566,7 @@
|
||||
<string name="activity_create_private_chat_scan_qr_code_explanation">Scannen Sie den QR-Code eines Benutzers, um eine Session zu starten. QR-Codes finden Sie, indem Sie in den Einstellungen auf das QR-Code-Symbol tippen.</string>
|
||||
<string name="fragment_enter_public_key_edit_text_hint">Sitzungs-ID oder ONS-Name eingeben</string>
|
||||
<string name="fragment_enter_public_key_explanation">Benutzer können ihre Account ID freigeben, indem sie in ihren Einstellungen auf \"Account ID freigeben\" tippen oder ihren QR-Code freigeben.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Bitte überprüfe die Session-ID oder den ONS-Namen und versuche es erneut.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Bitte überprüfe die Account-ID oder den ONS-Namen und versuche es erneut.</string>
|
||||
<string name="fragment_scan_qr_code_camera_access_explanation">Session benötigt Kamerazugriff, um die QR-Codes scannen zu können.</string>
|
||||
<string name="fragment_scan_qr_code_grant_camera_access_button_title">Kamerazugriff gewähren</string>
|
||||
<string name="activity_create_closed_group_title">Neue geschlossene Gruppe</string>
|
||||
@ -638,7 +638,7 @@
|
||||
<string name="dialog_ui_mode_option_day">Tag</string>
|
||||
<string name="dialog_ui_mode_option_night">Nacht</string>
|
||||
<string name="dialog_ui_mode_option_system_default">Systemstandard</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Session-ID kopieren</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Account-ID kopieren</string>
|
||||
<string name="attachment">Anhang</string>
|
||||
<string name="attachment_type_voice_message">Sprachnachricht</string>
|
||||
<string name="details">Details</string>
|
||||
|
@ -566,7 +566,7 @@
|
||||
<string name="activity_create_private_chat_scan_qr_code_explanation">Scannen Sie den QR-Code eines Benutzers, um eine Session zu starten. QR-Codes finden Sie, indem Sie in den Einstellungen auf das QR-Code-Symbol tippen.</string>
|
||||
<string name="fragment_enter_public_key_edit_text_hint">Sitzungs-ID oder ONS-Name eingeben</string>
|
||||
<string name="fragment_enter_public_key_explanation">Benutzer können ihre Account ID freigeben, indem sie in ihren Einstellungen auf \"Account ID freigeben\" tippen oder ihren QR-Code freigeben.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Bitte überprüfe die Session-ID oder den ONS-Namen und versuche es erneut.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Bitte überprüfe die Account-ID oder den ONS-Namen und versuche es erneut.</string>
|
||||
<string name="fragment_scan_qr_code_camera_access_explanation">Session benötigt Kamerazugriff, um die QR-Codes scannen zu können.</string>
|
||||
<string name="fragment_scan_qr_code_grant_camera_access_button_title">Kamerazugriff gewähren</string>
|
||||
<string name="activity_create_closed_group_title">Neue geschlossene Gruppe</string>
|
||||
@ -638,7 +638,7 @@
|
||||
<string name="dialog_ui_mode_option_day">Tag</string>
|
||||
<string name="dialog_ui_mode_option_night">Nacht</string>
|
||||
<string name="dialog_ui_mode_option_system_default">Systemstandard</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Session-ID kopieren</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Account-ID kopieren</string>
|
||||
<string name="attachment">Anhang</string>
|
||||
<string name="attachment_type_voice_message">Sprachnachricht</string>
|
||||
<string name="details">Details</string>
|
||||
|
@ -551,7 +551,7 @@ nøkkelutvekslingsmelding.</string>
|
||||
<string name="activity_home_delete_conversation_dialog_message">Er du sikker på at du vil slette denne samtalen?</string>
|
||||
<string name="activity_home_conversation_deleted_message">Samtalen slettet</string>
|
||||
<string name="view_seed_reminder_subtitle_1">Sikre kontoen din ved å lagre din gjenopprettingsfrase</string>
|
||||
<string name="view_seed_reminder_subtitle_2">Trykk og hold inne de overflødige ordene for å hente gjenopprettingsfrasen din, og lagre den trygt å sikre din Session-ID.</string>
|
||||
<string name="view_seed_reminder_subtitle_2">Trykk og hold inne de overflødige ordene for å hente gjenopprettingsfrasen din, og lagre den trygt å sikre din Account-ID.</string>
|
||||
<string name="view_seed_reminder_subtitle_3">Pass på å lagre gjenopprettingsfrasen på et sikkert sted</string>
|
||||
<string name="activity_path_title">Bane</string>
|
||||
<string name="activity_path_explanation">Session skjuler din IP ved å laste ned meldingene dine gjennom flere Service Noder i Sessions desentraliserte nettverk. Disse er landene som koblingen din for øyeblikket blir kontaktet gjennom:</string>
|
||||
@ -565,9 +565,9 @@ nøkkelutvekslingsmelding.</string>
|
||||
<string name="activity_create_private_chat_enter_account_id_tab_title">Skriv inn Account ID</string>
|
||||
<string name="activity_create_private_chat_scan_qr_code_tab_title">Skann QR-kode</string>
|
||||
<string name="activity_create_private_chat_scan_qr_code_explanation">Skann en brukers QR-kode for å starte en økt. QR-koder finnes ved å trykke på QR-koden i kontoinnstillingene.</string>
|
||||
<string name="fragment_enter_public_key_edit_text_hint">Angi Session-ID eller ONS-navn</string>
|
||||
<string name="fragment_enter_public_key_explanation">Brukere kan dele sin Session-ID ved å gå inn i sine kontoinnstillinger og trykke på \"Del Session-ID\", eller ved å dele sin QR-kode.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Vennligst sjekk Session-ID\'en eller ONS-navnet og prøv igjen.</string>
|
||||
<string name="fragment_enter_public_key_edit_text_hint">Angi Account-ID eller ONS-navn</string>
|
||||
<string name="fragment_enter_public_key_explanation">Brukere kan dele sin Account-ID ved å gå inn i sine kontoinnstillinger og trykke på \"Del Account-ID\", eller ved å dele sin QR-kode.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Vennligst sjekk Account-ID\'en eller ONS-navnet og prøv igjen.</string>
|
||||
<string name="fragment_scan_qr_code_camera_access_explanation">Session trenger kameratilgang for å skanne QR-koder</string>
|
||||
<string name="fragment_scan_qr_code_grant_camera_access_button_title">Gi kameratilgang</string>
|
||||
<string name="activity_create_closed_group_title">Ny lukket gruppe</string>
|
||||
@ -639,7 +639,7 @@ nøkkelutvekslingsmelding.</string>
|
||||
<string name="dialog_ui_mode_option_day">Dag</string>
|
||||
<string name="dialog_ui_mode_option_night">Natt</string>
|
||||
<string name="dialog_ui_mode_option_system_default">Systemstandard</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Kopier Session-ID</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Kopier Account-ID</string>
|
||||
<string name="attachment">Vedlegg</string>
|
||||
<string name="attachment_type_voice_message">Talemelding</string>
|
||||
<string name="details">Detaljer</string>
|
||||
|
@ -551,7 +551,7 @@ nøkkelutvekslingsmelding.</string>
|
||||
<string name="activity_home_delete_conversation_dialog_message">Er du sikker på at du vil slette denne samtalen?</string>
|
||||
<string name="activity_home_conversation_deleted_message">Samtalen slettet</string>
|
||||
<string name="view_seed_reminder_subtitle_1">Sikre kontoen din ved å lagre din gjenopprettingsfrase</string>
|
||||
<string name="view_seed_reminder_subtitle_2">Trykk og hold inne de overflødige ordene for å hente gjenopprettingsfrasen din, og lagre den trygt å sikre din Session-ID.</string>
|
||||
<string name="view_seed_reminder_subtitle_2">Trykk og hold inne de overflødige ordene for å hente gjenopprettingsfrasen din, og lagre den trygt å sikre din Account-ID.</string>
|
||||
<string name="view_seed_reminder_subtitle_3">Pass på å lagre gjenopprettingsfrasen på et sikkert sted</string>
|
||||
<string name="activity_path_title">Bane</string>
|
||||
<string name="activity_path_explanation">Session skjuler din IP ved å laste ned meldingene dine gjennom flere Service Noder i Sessions desentraliserte nettverk. Disse er landene som koblingen din for øyeblikket blir kontaktet gjennom:</string>
|
||||
@ -565,9 +565,9 @@ nøkkelutvekslingsmelding.</string>
|
||||
<string name="activity_create_private_chat_enter_account_id_tab_title">Skriv inn Account ID</string>
|
||||
<string name="activity_create_private_chat_scan_qr_code_tab_title">Skann QR-kode</string>
|
||||
<string name="activity_create_private_chat_scan_qr_code_explanation">Skann en brukers QR-kode for å starte en økt. QR-koder finnes ved å trykke på QR-koden i kontoinnstillingene.</string>
|
||||
<string name="fragment_enter_public_key_edit_text_hint">Angi Session-ID eller ONS-navn</string>
|
||||
<string name="fragment_enter_public_key_explanation">Brukere kan dele sin Session-ID ved å gå inn i sine kontoinnstillinger og trykke på \"Del Session-ID\", eller ved å dele sin QR-kode.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Vennligst sjekk Session-ID\'en eller ONS-navnet og prøv igjen.</string>
|
||||
<string name="fragment_enter_public_key_edit_text_hint">Angi Account-ID eller ONS-navn</string>
|
||||
<string name="fragment_enter_public_key_explanation">Brukere kan dele sin Account-ID ved å gå inn i sine kontoinnstillinger og trykke på \"Del Account-ID\", eller ved å dele sin QR-kode.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Vennligst sjekk Account-ID\'en eller ONS-navnet og prøv igjen.</string>
|
||||
<string name="fragment_scan_qr_code_camera_access_explanation">Session trenger kameratilgang for å skanne QR-koder</string>
|
||||
<string name="fragment_scan_qr_code_grant_camera_access_button_title">Gi kameratilgang</string>
|
||||
<string name="activity_create_closed_group_title">Ny lukket gruppe</string>
|
||||
@ -639,7 +639,7 @@ nøkkelutvekslingsmelding.</string>
|
||||
<string name="dialog_ui_mode_option_day">Dag</string>
|
||||
<string name="dialog_ui_mode_option_night">Natt</string>
|
||||
<string name="dialog_ui_mode_option_system_default">Systemstandard</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Kopier Session-ID</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Kopier Account-ID</string>
|
||||
<string name="attachment">Vedlegg</string>
|
||||
<string name="attachment_type_voice_message">Talemelding</string>
|
||||
<string name="details">Detaljer</string>
|
||||
|
@ -567,7 +567,7 @@
|
||||
<string name="activity_create_private_chat_scan_qr_code_tab_title">Scan QR-code</string>
|
||||
<string name="activity_create_private_chat_scan_qr_code_explanation">Scan de QR-code van een gebruiker om een sessie te starten. QR-codes kunnen worden gevonden door op het QR-icoon in de accountinstellingen te tikken.</string>
|
||||
<string name="fragment_enter_public_key_edit_text_hint">Voer uw Account ID of ONS naam in</string>
|
||||
<string name="fragment_enter_public_key_explanation">Gebruikers kunnen hun Session-ID delen door naar hun accountinstellingen te gaan en op \"Deel Session-ID\" te tikken, of door hun QR-code te delen.</string>
|
||||
<string name="fragment_enter_public_key_explanation">Gebruikers kunnen hun Account-ID delen door naar hun accountinstellingen te gaan en op \"Deel Account-ID\" te tikken, of door hun QR-code te delen.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Controleer de sessie-ID of ONS naam en probeer het opnieuw.</string>
|
||||
<string name="fragment_scan_qr_code_camera_access_explanation">Sessie heeft cameratoegang nodig om QR-codes te scannen</string>
|
||||
<string name="fragment_scan_qr_code_grant_camera_access_button_title">Toegang tot camera verlenen</string>
|
||||
|
@ -567,7 +567,7 @@
|
||||
<string name="activity_create_private_chat_scan_qr_code_tab_title">Scan QR-code</string>
|
||||
<string name="activity_create_private_chat_scan_qr_code_explanation">Scan de QR-code van een gebruiker om een sessie te starten. QR-codes kunnen worden gevonden door op het QR-icoon in de accountinstellingen te tikken.</string>
|
||||
<string name="fragment_enter_public_key_edit_text_hint">Voer uw Account ID of ONS naam in</string>
|
||||
<string name="fragment_enter_public_key_explanation">Gebruikers kunnen hun Session-ID delen door naar hun accountinstellingen te gaan en op \"Deel Session-ID\" te tikken, of door hun QR-code te delen.</string>
|
||||
<string name="fragment_enter_public_key_explanation">Gebruikers kunnen hun Account-ID delen door naar hun accountinstellingen te gaan en op \"Deel Account-ID\" te tikken, of door hun QR-code te delen.</string>
|
||||
<string name="fragment_enter_public_key_error_message">Controleer de sessie-ID of ONS naam en probeer het opnieuw.</string>
|
||||
<string name="fragment_scan_qr_code_camera_access_explanation">Sessie heeft cameratoegang nodig om QR-codes te scannen</string>
|
||||
<string name="fragment_scan_qr_code_grant_camera_access_button_title">Toegang tot camera verlenen</string>
|
||||
|
@ -551,7 +551,7 @@ för nyckelutbyte!</string>
|
||||
<string name="activity_home_delete_conversation_dialog_message">Är du säker på att du vill ta bort denna konversation?</string>
|
||||
<string name="activity_home_conversation_deleted_message">Konversationen har raderats</string>
|
||||
<string name="view_seed_reminder_subtitle_1">Säkra ditt konto genom att spara din återställningsfras</string>
|
||||
<string name="view_seed_reminder_subtitle_2">Tryck på och håll ned de dolda orden för att avslöja din återställningsfras och lagra dem på ett säkert sätt för att säkra ditt Session-ID.</string>
|
||||
<string name="view_seed_reminder_subtitle_2">Tryck på och håll ned de dolda orden för att avslöja din återställningsfras och lagra dem på ett säkert sätt för att säkra ditt Account-ID.</string>
|
||||
<string name="view_seed_reminder_subtitle_3">Se till att spara din återställningsfras på en säker plats</string>
|
||||
<string name="activity_path_title">Sökväg</string>
|
||||
<string name="activity_path_explanation">Session döljer din IP-adress genom att dirigera dina meddelanden genom flera Tjänstnoder i Sessions decentraliserade nätverk. Detta är de länder som din anslutning för närvarande går igenom:</string>
|
||||
@ -639,7 +639,7 @@ för nyckelutbyte!</string>
|
||||
<string name="dialog_ui_mode_option_day">Dag</string>
|
||||
<string name="dialog_ui_mode_option_night">Natt</string>
|
||||
<string name="dialog_ui_mode_option_system_default">Systemets inställning</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Kopiera Session-ID</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Kopiera Account-ID</string>
|
||||
<string name="attachment">Bilaga</string>
|
||||
<string name="attachment_type_voice_message">Röstmeddelande</string>
|
||||
<string name="details">Detaljer</string>
|
||||
|
@ -551,7 +551,7 @@ för nyckelutbyte!</string>
|
||||
<string name="activity_home_delete_conversation_dialog_message">Är du säker på att du vill ta bort denna konversation?</string>
|
||||
<string name="activity_home_conversation_deleted_message">Konversationen har raderats</string>
|
||||
<string name="view_seed_reminder_subtitle_1">Säkra ditt konto genom att spara din återställningsfras</string>
|
||||
<string name="view_seed_reminder_subtitle_2">Tryck på och håll ned de dolda orden för att avslöja din återställningsfras och lagra dem på ett säkert sätt för att säkra ditt Session-ID.</string>
|
||||
<string name="view_seed_reminder_subtitle_2">Tryck på och håll ned de dolda orden för att avslöja din återställningsfras och lagra dem på ett säkert sätt för att säkra ditt Account-ID.</string>
|
||||
<string name="view_seed_reminder_subtitle_3">Se till att spara din återställningsfras på en säker plats</string>
|
||||
<string name="activity_path_title">Sökväg</string>
|
||||
<string name="activity_path_explanation">Session döljer din IP-adress genom att dirigera dina meddelanden genom flera Tjänstnoder i Sessions decentraliserade nätverk. Detta är de länder som din anslutning för närvarande går igenom:</string>
|
||||
@ -639,7 +639,7 @@ för nyckelutbyte!</string>
|
||||
<string name="dialog_ui_mode_option_day">Dag</string>
|
||||
<string name="dialog_ui_mode_option_night">Natt</string>
|
||||
<string name="dialog_ui_mode_option_system_default">Systemets inställning</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Kopiera Session-ID</string>
|
||||
<string name="activity_conversation_menu_copy_account_id">Kopiera Account-ID</string>
|
||||
<string name="attachment">Bilaga</string>
|
||||
<string name="attachment_type_voice_message">Röstmeddelande</string>
|
||||
<string name="details">Detaljer</string>
|
||||
|
@ -368,7 +368,7 @@ class InstrumentedTests {
|
||||
assertEquals(2, convos.sizeOneToOnes())
|
||||
|
||||
val numErased = convos.eraseAll { convo ->
|
||||
convo is Conversation.OneToOne && convo.sessionId == definitelyRealId
|
||||
convo is Conversation.OneToOne && convo.accountId == definitelyRealId
|
||||
}
|
||||
assertEquals(1, numErased)
|
||||
assertEquals(1, convos.sizeOneToOnes())
|
||||
@ -453,7 +453,7 @@ class InstrumentedTests {
|
||||
|
||||
val c = convos.getOrConstructOneToOne(definitelyRealId)
|
||||
|
||||
assertEquals(definitelyRealId, c.sessionId)
|
||||
assertEquals(definitelyRealId, c.accountId)
|
||||
assertEquals(0, c.lastRead)
|
||||
|
||||
assertFalse(convos.needsPush())
|
||||
@ -504,7 +504,7 @@ class InstrumentedTests {
|
||||
|
||||
val x1 = convos2.getOneToOne(definitelyRealId)!!
|
||||
assertEquals(nowMs, x1.lastRead)
|
||||
assertEquals(definitelyRealId, x1.sessionId)
|
||||
assertEquals(definitelyRealId, x1.accountId)
|
||||
assertEquals(false, x1.unread)
|
||||
|
||||
val x2 = convos2.getCommunity("http://EXAMPLE.org:5678", "sudokuRoom")!!
|
||||
@ -548,7 +548,7 @@ class InstrumentedTests {
|
||||
val allConvos = conv.all()
|
||||
for (convo in allConvos) {
|
||||
when (convo) {
|
||||
is Conversation.OneToOne -> seen.add("1-to-1: ${convo.sessionId}")
|
||||
is Conversation.OneToOne -> seen.add("1-to-1: ${convo.accountId}")
|
||||
is Conversation.Community -> seen.add("og: ${convo.baseCommunityInfo.baseUrl}/r/${convo.baseCommunityInfo.room}")
|
||||
is Conversation.LegacyGroup -> seen.add("cl: ${convo.groupId}")
|
||||
}
|
||||
@ -569,7 +569,7 @@ class InstrumentedTests {
|
||||
|
||||
assertEquals(1, convos.allOneToOnes().size)
|
||||
assertEquals("051111111111111111111111111111111111111111111111111111111111111111",
|
||||
convos.allOneToOnes().map(Conversation.OneToOne::sessionId).first()
|
||||
convos.allOneToOnes().map(Conversation.OneToOne::accountId).first()
|
||||
)
|
||||
assertEquals(1, convos.allCommunities().size)
|
||||
assertEquals("http://example.org:5678",
|
||||
|
@ -5,15 +5,15 @@
|
||||
extern "C"
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_Contacts_get(JNIEnv *env, jobject thiz,
|
||||
jstring session_id) {
|
||||
jstring account_id) {
|
||||
// If an exception is thrown, return nullptr
|
||||
return jni_utils::run_catching_cxx_exception_or<jobject>(
|
||||
[=]() -> jobject {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
auto contacts = ptrToContacts(env, thiz);
|
||||
auto session_id_chars = env->GetStringUTFChars(session_id, nullptr);
|
||||
auto contact = contacts->get(session_id_chars);
|
||||
env->ReleaseStringUTFChars(session_id, session_id_chars);
|
||||
auto account_id_chars = env->GetStringUTFChars(account_id, nullptr);
|
||||
auto contact = contacts->get(account_id_chars);
|
||||
env->ReleaseStringUTFChars(account_id, account_id_chars);
|
||||
if (!contact) return nullptr;
|
||||
jobject j_contact = serialize_contact(env, contact.value());
|
||||
return j_contact;
|
||||
@ -25,13 +25,13 @@ Java_network_loki_messenger_libsession_1util_Contacts_get(JNIEnv *env, jobject t
|
||||
extern "C"
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_Contacts_getOrConstruct(JNIEnv *env, jobject thiz,
|
||||
jstring session_id) {
|
||||
jstring account_id) {
|
||||
return jni_utils::run_catching_cxx_exception_or_throws<jobject>(env, [=] {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
auto contacts = ptrToContacts(env, thiz);
|
||||
auto session_id_chars = env->GetStringUTFChars(session_id, nullptr);
|
||||
auto contact = contacts->get_or_construct(session_id_chars);
|
||||
env->ReleaseStringUTFChars(session_id, session_id_chars);
|
||||
auto account_id_chars = env->GetStringUTFChars(account_id, nullptr);
|
||||
auto contact = contacts->get_or_construct(account_id_chars);
|
||||
env->ReleaseStringUTFChars(account_id, account_id_chars);
|
||||
return serialize_contact(env, contact);
|
||||
});
|
||||
}
|
||||
@ -51,14 +51,14 @@ Java_network_loki_messenger_libsession_1util_Contacts_set(JNIEnv *env, jobject t
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_Contacts_erase(JNIEnv *env, jobject thiz,
|
||||
jstring session_id) {
|
||||
jstring account_id) {
|
||||
return jni_utils::run_catching_cxx_exception_or_throws<jboolean>(env, [=] {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
auto contacts = ptrToContacts(env, thiz);
|
||||
auto session_id_chars = env->GetStringUTFChars(session_id, nullptr);
|
||||
auto account_id_chars = env->GetStringUTFChars(account_id, nullptr);
|
||||
|
||||
bool result = contacts->erase(session_id_chars);
|
||||
env->ReleaseStringUTFChars(session_id, session_id_chars);
|
||||
bool result = contacts->erase(account_id_chars);
|
||||
env->ReleaseStringUTFChars(account_id, account_id_chars);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ inline session::config::contact_info deserialize_contact(JNIEnv *env, jobject in
|
||||
"Lnetwork/loki/messenger/libsession_util/util/UserPic;");
|
||||
getPriority = env->GetFieldID(contactClass, "priority", "I");
|
||||
getExpiry = env->GetFieldID(contactClass, "expiryMode", "Lnetwork/loki/messenger/libsession_util/util/ExpiryMode;");
|
||||
jstring name, nickname, session_id;
|
||||
session_id = static_cast<jstring>(env->GetObjectField(info, getId));
|
||||
jstring name, nickname, account_id;
|
||||
account_id = static_cast<jstring>(env->GetObjectField(info, getId));
|
||||
name = static_cast<jstring>(env->GetObjectField(info, getName));
|
||||
nickname = static_cast<jstring>(env->GetObjectField(info, getNick));
|
||||
bool approved, approvedMe, blocked, hidden;
|
||||
@ -69,11 +69,11 @@ inline session::config::contact_info deserialize_contact(JNIEnv *env, jobject in
|
||||
key = util::ustring_from_bytes(env, deserialized_pic.second);
|
||||
}
|
||||
|
||||
auto session_id_bytes = env->GetStringUTFChars(session_id, nullptr);
|
||||
auto account_id_bytes = env->GetStringUTFChars(account_id, nullptr);
|
||||
auto name_bytes = name ? env->GetStringUTFChars(name, nullptr) : nullptr;
|
||||
auto nickname_bytes = nickname ? env->GetStringUTFChars(nickname, nullptr) : nullptr;
|
||||
|
||||
auto contact_info = conf->get_or_construct(session_id_bytes);
|
||||
auto contact_info = conf->get_or_construct(account_id_bytes);
|
||||
if (name_bytes) {
|
||||
contact_info.name = name_bytes;
|
||||
}
|
||||
@ -89,7 +89,7 @@ inline session::config::contact_info deserialize_contact(JNIEnv *env, jobject in
|
||||
contact_info.profile_picture = session::config::profile_pic();
|
||||
}
|
||||
|
||||
env->ReleaseStringUTFChars(session_id, session_id_bytes);
|
||||
env->ReleaseStringUTFChars(account_id, account_id_bytes);
|
||||
if (name_bytes) {
|
||||
env->ReleaseStringUTFChars(name, name_bytes);
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ inline session::config::ConvoInfoVolatile *ptrToConvoInfo(JNIEnv *env, jobject o
|
||||
inline jobject serialize_one_to_one(JNIEnv *env, session::config::convo::one_to_one one_to_one) {
|
||||
jclass clazz = env->FindClass("network/loki/messenger/libsession_util/util/Conversation$OneToOne");
|
||||
jmethodID constructor = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;JZ)V");
|
||||
auto session_id = env->NewStringUTF(one_to_one.session_id.data());
|
||||
auto account_id = env->NewStringUTF(one_to_one.session_id.data());
|
||||
auto last_read = one_to_one.last_read;
|
||||
auto unread = one_to_one.unread;
|
||||
jobject serialized = env->NewObject(clazz, constructor, session_id, last_read, unread);
|
||||
jobject serialized = env->NewObject(clazz, constructor, account_id, last_read, unread);
|
||||
return serialized;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ inline jobject serialize_any(JNIEnv *env, session::config::convo::any any) {
|
||||
|
||||
inline session::config::convo::one_to_one deserialize_one_to_one(JNIEnv *env, jobject info, session::config::ConvoInfoVolatile *conf) {
|
||||
auto clazz = env->FindClass("network/loki/messenger/libsession_util/util/Conversation$OneToOne");
|
||||
auto id_getter = env->GetFieldID(clazz, "sessionId", "Ljava/lang/String;");
|
||||
auto id_getter = env->GetFieldID(clazz, "accountId", "Ljava/lang/String;");
|
||||
auto last_read_getter = env->GetFieldID(clazz, "lastRead", "J");
|
||||
auto unread_getter = env->GetFieldID(clazz, "unread", "Z");
|
||||
jstring id = static_cast<jstring>(env->GetObjectField(info, id_getter));
|
||||
|
@ -74,16 +74,16 @@ extern "C"
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getLegacyGroupInfo(JNIEnv *env,
|
||||
jobject thiz,
|
||||
jstring session_id) {
|
||||
jstring account_id) {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
auto conf = ptrToUserGroups(env, thiz);
|
||||
auto id_bytes = env->GetStringUTFChars(session_id, nullptr);
|
||||
auto id_bytes = env->GetStringUTFChars(account_id, nullptr);
|
||||
auto legacy_group = conf->get_legacy_group(id_bytes);
|
||||
jobject return_group = nullptr;
|
||||
if (legacy_group) {
|
||||
return_group = serialize_legacy_group_info(env, *legacy_group);
|
||||
}
|
||||
env->ReleaseStringUTFChars(session_id, id_bytes);
|
||||
env->ReleaseStringUTFChars(account_id, id_bytes);
|
||||
return return_group;
|
||||
}
|
||||
|
||||
@ -108,12 +108,12 @@ Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getOrConstructComm
|
||||
extern "C"
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getOrConstructLegacyGroupInfo(
|
||||
JNIEnv *env, jobject thiz, jstring session_id) {
|
||||
JNIEnv *env, jobject thiz, jstring account_id) {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
auto conf = ptrToUserGroups(env, thiz);
|
||||
auto id_bytes = env->GetStringUTFChars(session_id, nullptr);
|
||||
auto id_bytes = env->GetStringUTFChars(account_id, nullptr);
|
||||
auto group = conf->get_or_construct_legacy_group(id_bytes);
|
||||
env->ReleaseStringUTFChars(session_id, id_bytes);
|
||||
env->ReleaseStringUTFChars(account_id, id_bytes);
|
||||
return serialize_legacy_group_info(env, group);
|
||||
}
|
||||
|
||||
@ -264,11 +264,11 @@ extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_eraseLegacyGroup(JNIEnv *env,
|
||||
jobject thiz,
|
||||
jstring session_id) {
|
||||
jstring account_id) {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
auto conf = ptrToUserGroups(env, thiz);
|
||||
auto session_id_bytes = env->GetStringUTFChars(session_id, nullptr);
|
||||
bool return_bool = conf->erase_legacy_group(session_id_bytes);
|
||||
env->ReleaseStringUTFChars(session_id, session_id_bytes);
|
||||
auto account_id_bytes = env->GetStringUTFChars(account_id, nullptr);
|
||||
bool return_bool = conf->erase_legacy_group(account_id_bytes);
|
||||
env->ReleaseStringUTFChars(account_id, account_id_bytes);
|
||||
return return_bool;
|
||||
}
|
@ -44,7 +44,7 @@ inline void deserialize_members_into(JNIEnv *env, jobject members_map, session::
|
||||
|
||||
inline session::config::legacy_group_info deserialize_legacy_group_info(JNIEnv *env, jobject info, session::config::UserGroups* conf) {
|
||||
auto clazz = env->FindClass("network/loki/messenger/libsession_util/util/GroupInfo$LegacyGroupInfo");
|
||||
auto id_field = env->GetFieldID(clazz, "sessionId", "Ljava/lang/String;");
|
||||
auto id_field = env->GetFieldID(clazz, "accountId", "Ljava/lang/String;");
|
||||
auto name_field = env->GetFieldID(clazz, "name", "Ljava/lang/String;");
|
||||
auto members_field = env->GetFieldID(clazz, "members", "Ljava/util/Map;");
|
||||
auto enc_pub_key_field = env->GetFieldID(clazz, "encPubKey", "[B");
|
||||
@ -104,16 +104,16 @@ inline jobject serialize_members(JNIEnv *env, std::map<std::string, bool> member
|
||||
|
||||
jobject new_map = env->NewObject(map_class, map_constructor);
|
||||
for (auto it = members_map.begin(); it != members_map.end(); it++) {
|
||||
auto session_id = env->NewStringUTF(it->first.data());
|
||||
auto account_id = env->NewStringUTF(it->first.data());
|
||||
bool is_admin = it->second;
|
||||
auto jbool = env->NewObject(boxed_bool, new_bool, is_admin);
|
||||
env->CallObjectMethod(new_map, insert, session_id, jbool);
|
||||
env->CallObjectMethod(new_map, insert, account_id, jbool);
|
||||
}
|
||||
return new_map;
|
||||
}
|
||||
|
||||
inline jobject serialize_legacy_group_info(JNIEnv *env, session::config::legacy_group_info info) {
|
||||
jstring session_id = env->NewStringUTF(info.session_id.data());
|
||||
jstring account_id = env->NewStringUTF(info.session_id.data());
|
||||
jstring name = env->NewStringUTF(info.name.data());
|
||||
jobject members = serialize_members(env, info.members());
|
||||
jbyteArray enc_pubkey = util::bytes_from_ustring(env, info.enc_pubkey);
|
||||
@ -123,7 +123,7 @@ inline jobject serialize_legacy_group_info(JNIEnv *env, session::config::legacy_
|
||||
|
||||
jclass legacy_group_class = env->FindClass("network/loki/messenger/libsession_util/util/GroupInfo$LegacyGroupInfo");
|
||||
jmethodID constructor = env->GetMethodID(legacy_group_class, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;[B[BIJJ)V");
|
||||
jobject serialized = env->NewObject(legacy_group_class, constructor, session_id, name, members, enc_pubkey, enc_seckey, priority, (jlong) info.disappearing_timer.count(), joined_at);
|
||||
jobject serialized = env->NewObject(legacy_group_class, constructor, account_id, name, members, enc_pubkey, enc_seckey, priority, (jlong) info.disappearing_timer.count(), joined_at);
|
||||
return serialized;
|
||||
}
|
||||
|
||||
|
@ -61,49 +61,41 @@ class Contacts(pointer: Long) : ConfigBase(pointer) {
|
||||
external fun newInstance(ed25519SecretKey: ByteArray, initialDump: ByteArray): Contacts
|
||||
}
|
||||
|
||||
external fun get(sessionId: String): Contact?
|
||||
external fun getOrConstruct(sessionId: String): Contact
|
||||
external fun get(accountId: String): Contact?
|
||||
external fun getOrConstruct(accountId: String): Contact
|
||||
external fun all(): List<Contact>
|
||||
external fun set(contact: Contact)
|
||||
external fun erase(sessionId: String): Boolean
|
||||
external fun erase(accountId: String): Boolean
|
||||
|
||||
/**
|
||||
* Similar to [updateIfExists], but will create the underlying contact if it doesn't exist before passing to [updateFunction]
|
||||
*/
|
||||
fun upsertContact(sessionId: String, updateFunction: Contact.()->Unit = {}) {
|
||||
if (sessionId.startsWith(IdPrefix.BLINDED.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with a blinded ID prefix")
|
||||
return
|
||||
} else if (sessionId.startsWith(IdPrefix.UN_BLINDED.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix")
|
||||
return
|
||||
} else if (sessionId.startsWith(IdPrefix.BLINDEDV2.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with a blindedv2 ID prefix")
|
||||
return
|
||||
fun upsertContact(accountId: String, updateFunction: Contact.()->Unit = {}) {
|
||||
when {
|
||||
accountId.startsWith(IdPrefix.BLINDED.value) -> Log.w("Loki", "Trying to create a contact with a blinded ID prefix")
|
||||
accountId.startsWith(IdPrefix.UN_BLINDED.value) -> Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix")
|
||||
accountId.startsWith(IdPrefix.BLINDEDV2.value) -> Log.w("Loki", "Trying to create a contact with a blindedv2 ID prefix")
|
||||
else -> getOrConstruct(accountId).let {
|
||||
updateFunction(it)
|
||||
set(it)
|
||||
}
|
||||
}
|
||||
val contact = getOrConstruct(sessionId)
|
||||
updateFunction(contact)
|
||||
set(contact)
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the contact by sessionId with a given [updateFunction], and applies to the underlying config.
|
||||
* Updates the contact by accountId with a given [updateFunction], and applies to the underlying config.
|
||||
* the [updateFunction] doesn't run if there is no contact
|
||||
*/
|
||||
fun updateIfExists(sessionId: String, updateFunction: Contact.()->Unit) {
|
||||
if (sessionId.startsWith(IdPrefix.BLINDED.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with a blinded ID prefix")
|
||||
return
|
||||
} else if (sessionId.startsWith(IdPrefix.UN_BLINDED.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix")
|
||||
return
|
||||
} else if (sessionId.startsWith(IdPrefix.BLINDEDV2.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with a blindedv2 ID prefix")
|
||||
return
|
||||
private fun updateIfExists(accountId: String, updateFunction: Contact.()->Unit) {
|
||||
when {
|
||||
accountId.startsWith(IdPrefix.BLINDED.value) -> Log.w("Loki", "Trying to create a contact with a blinded ID prefix")
|
||||
accountId.startsWith(IdPrefix.UN_BLINDED.value) -> Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix")
|
||||
accountId.startsWith(IdPrefix.BLINDEDV2.value) -> Log.w("Loki", "Trying to create a contact with a blindedv2 ID prefix")
|
||||
else -> get(accountId)?.let {
|
||||
updateFunction(it)
|
||||
set(it)
|
||||
}
|
||||
}
|
||||
val contact = get(sessionId) ?: return
|
||||
updateFunction(contact)
|
||||
set(contact)
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,14 +176,14 @@ class UserGroupsConfig(pointer: Long): ConfigBase(pointer) {
|
||||
}
|
||||
|
||||
external fun getCommunityInfo(baseUrl: String, room: String): GroupInfo.CommunityGroupInfo?
|
||||
external fun getLegacyGroupInfo(sessionId: String): GroupInfo.LegacyGroupInfo?
|
||||
external fun getLegacyGroupInfo(accountId: String): GroupInfo.LegacyGroupInfo?
|
||||
external fun getOrConstructCommunityInfo(baseUrl: String, room: String, pubKeyHex: String): GroupInfo.CommunityGroupInfo
|
||||
external fun getOrConstructLegacyGroupInfo(sessionId: String): GroupInfo.LegacyGroupInfo
|
||||
external fun getOrConstructLegacyGroupInfo(accountId: String): GroupInfo.LegacyGroupInfo
|
||||
external fun set(groupInfo: GroupInfo)
|
||||
external fun erase(communityInfo: GroupInfo)
|
||||
external fun eraseCommunity(baseCommunityInfo: BaseCommunityInfo): Boolean
|
||||
external fun eraseCommunity(server: String, room: String): Boolean
|
||||
external fun eraseLegacyGroup(sessionId: String): Boolean
|
||||
external fun eraseLegacyGroup(accountId: String): Boolean
|
||||
external fun sizeCommunityInfo(): Int
|
||||
external fun sizeLegacyGroupInfo(): Int
|
||||
external fun size(): Int
|
||||
|
@ -6,7 +6,7 @@ sealed class Conversation {
|
||||
abstract var unread: Boolean
|
||||
|
||||
data class OneToOne(
|
||||
val sessionId: String,
|
||||
val accountId: String,
|
||||
override var lastRead: Long,
|
||||
override var unread: Boolean
|
||||
): Conversation()
|
||||
|
@ -5,7 +5,7 @@ sealed class GroupInfo {
|
||||
data class CommunityGroupInfo(val community: BaseCommunityInfo, val priority: Int) : GroupInfo()
|
||||
|
||||
data class LegacyGroupInfo(
|
||||
val sessionId: String,
|
||||
val accountId: String,
|
||||
val name: String,
|
||||
val members: Map<String, Boolean>,
|
||||
val encPubKey: ByteArray,
|
||||
@ -25,7 +25,7 @@ sealed class GroupInfo {
|
||||
|
||||
other as LegacyGroupInfo
|
||||
|
||||
if (sessionId != other.sessionId) return false
|
||||
if (accountId != other.accountId) return false
|
||||
if (name != other.name) return false
|
||||
if (members != other.members) return false
|
||||
if (!encPubKey.contentEquals(other.encPubKey)) return false
|
||||
@ -38,7 +38,7 @@ sealed class GroupInfo {
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = sessionId.hashCode()
|
||||
var result = accountId.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
result = 31 * result + members.hashCode()
|
||||
result = 31 * result + encPubKey.contentHashCode()
|
||||
|
@ -2,7 +2,7 @@ package org.session.libsession.messaging
|
||||
|
||||
data class BlindedIdMapping(
|
||||
val blindedId: String,
|
||||
val sessionId: String?,
|
||||
val accountId: String?,
|
||||
val serverUrl: String,
|
||||
val serverId: String
|
||||
)
|
@ -30,8 +30,8 @@ sealed class Endpoint(val value: String) {
|
||||
data class RoomMessagesSince(val roomToken: String, val seqNo: Long) :
|
||||
Endpoint("room/$roomToken/messages/since/$seqNo")
|
||||
|
||||
data class RoomDeleteMessages(val roomToken: String, val sessionId: String) :
|
||||
Endpoint("room/$roomToken/all/$sessionId")
|
||||
data class RoomDeleteMessages(val roomToken: String, val accountId: String) :
|
||||
Endpoint("room/$roomToken/all/$accountId")
|
||||
|
||||
data class Reactors(val roomToken: String, val messageId: Long, val emoji: String):
|
||||
Endpoint("room/$roomToken/reactors/$messageId/$emoji")
|
||||
@ -67,15 +67,15 @@ sealed class Endpoint(val value: String) {
|
||||
|
||||
object Inbox : Endpoint("inbox")
|
||||
data class InboxSince(val id: Long) : Endpoint("inbox/since/$id")
|
||||
data class InboxFor(val sessionId: String) : Endpoint("inbox/$sessionId")
|
||||
data class InboxFor(val accountId: String) : Endpoint("inbox/$accountId")
|
||||
|
||||
object Outbox : Endpoint("outbox")
|
||||
data class OutboxSince(val id: Long) : Endpoint("outbox/since/$id")
|
||||
|
||||
// Users
|
||||
|
||||
data class UserBan(val sessionId: String) : Endpoint("user/$sessionId/ban")
|
||||
data class UserUnban(val sessionId: String) : Endpoint("user/$sessionId/unban")
|
||||
data class UserModerator(val sessionId: String) : Endpoint("user/$sessionId/moderator")
|
||||
data class UserBan(val accountId: String) : Endpoint("user/$accountId/ban")
|
||||
data class UserUnban(val accountId: String) : Endpoint("user/$accountId/unban")
|
||||
data class UserModerator(val accountId: String) : Endpoint("user/$accountId/moderator")
|
||||
|
||||
}
|
||||
|
@ -6,18 +6,13 @@ import com.fasterxml.jackson.core.type.TypeReference
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory
|
||||
import com.goterl.lazysodium.LazySodiumAndroid
|
||||
import com.goterl.lazysodium.SodiumAndroid
|
||||
import com.goterl.lazysodium.interfaces.GenericHash
|
||||
import com.goterl.lazysodium.interfaces.Sign
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import nl.komponents.kovenant.Promise
|
||||
import nl.komponents.kovenant.functional.map
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Headers.Companion.toHeaders
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.RequestBody
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
@ -203,7 +198,7 @@ object OpenGroupApi {
|
||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
||||
data class Message(
|
||||
val id : Long = 0,
|
||||
val sessionId: String = "",
|
||||
val accountId: String = "",
|
||||
val posted: Double = 0.0,
|
||||
val edited: Long = 0,
|
||||
val seqno: Long = 0,
|
||||
|
@ -13,9 +13,9 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class SubscriptionRequest(
|
||||
/** the 33-byte account being subscribed to; typically a session ID */
|
||||
/** the 33-byte account being subscribed to; typically an account ID */
|
||||
val pubkey: String,
|
||||
/** when the pubkey starts with 05 (i.e. a session ID) this is the ed25519 32-byte pubkey associated with the session ID */
|
||||
/** when the pubkey starts with 05 (i.e. an account ID) this is the ed25519 32-byte pubkey associated with the account ID */
|
||||
val session_ed25519: String?,
|
||||
/** 32-byte swarm authentication subkey; omitted (or null) when not using subkey auth (new closed groups) */
|
||||
val subkey_tag: String? = null,
|
||||
@ -38,9 +38,9 @@ data class SubscriptionRequest(
|
||||
|
||||
@Serializable
|
||||
data class UnsubscriptionRequest(
|
||||
/** the 33-byte account being subscribed to; typically a session ID */
|
||||
/** the 33-byte account being subscribed to; typically a account ID */
|
||||
val pubkey: String,
|
||||
/** when the pubkey starts with 05 (i.e. a session ID) this is the ed25519 32-byte pubkey associated with the session ID */
|
||||
/** when the pubkey starts with 05 (i.e. an account ID) this is the ed25519 32-byte pubkey associated with the account ID */
|
||||
val session_ed25519: String?,
|
||||
/** 32-byte swarm authentication subkey; omitted (or null) when not using subkey auth (new closed groups) */
|
||||
val subkey_tag: String? = null,
|
||||
|
@ -222,7 +222,7 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
||||
handleNewMessages(server, roomToken, additions.map {
|
||||
OpenGroupMessage(
|
||||
serverID = it.id,
|
||||
sender = it.sessionId,
|
||||
sender = it.accountId,
|
||||
sentTimestamp = (it.posted * 1000).toLong(),
|
||||
base64EncodedData = it.data,
|
||||
base64EncodedSignature = it.signature,
|
||||
@ -272,7 +272,7 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
||||
serverPublicKey,
|
||||
true
|
||||
)
|
||||
val syncTarget = mapping.sessionId ?: it.recipient
|
||||
val syncTarget = mapping.accountId ?: it.recipient
|
||||
if (message is VisibleMessage) {
|
||||
message.syncTarget = syncTarget
|
||||
} else if (message is ExpirationTimerUpdate) {
|
||||
|
@ -159,22 +159,22 @@ object SodiumUtilities {
|
||||
} else null
|
||||
}
|
||||
|
||||
/* This method should be used to check if a users standard sessionId matches a blinded one */
|
||||
fun sessionId(
|
||||
/* This method should be used to check if a users standard accountId matches a blinded one */
|
||||
fun accountId(
|
||||
standardAccountId: String,
|
||||
blindedAccountId: String,
|
||||
serverPublicKey: String
|
||||
): Boolean {
|
||||
// Only support generating blinded keys for standard session ids
|
||||
val sessionId = AccountId(standardAccountId)
|
||||
if (sessionId.prefix != IdPrefix.STANDARD) return false
|
||||
// Only support generating blinded keys for standard account ids
|
||||
val accountId = AccountId(standardAccountId)
|
||||
if (accountId.prefix != IdPrefix.STANDARD) return false
|
||||
val blindedId = AccountId(blindedAccountId)
|
||||
if (blindedId.prefix != IdPrefix.BLINDED) return false
|
||||
val k = generateBlindingFactor(serverPublicKey) ?: return false
|
||||
|
||||
// From the session id (ignoring 05 prefix) we have two possible ed25519 pubkeys;
|
||||
// From the account id (ignoring 05 prefix) we have two possible ed25519 pubkeys;
|
||||
// the first is the positive (which is what Signal's XEd25519 conversion always uses)
|
||||
val xEd25519Key = curve.convertToEd25519PublicKey(Key.fromHexString(sessionId.publicKey).asBytes)
|
||||
val xEd25519Key = curve.convertToEd25519PublicKey(Key.fromHexString(accountId.publicKey).asBytes)
|
||||
|
||||
// Blind the positive public key
|
||||
val pk1 = combineKeys(k, xEd25519Key) ?: return false
|
||||
|
@ -17,9 +17,9 @@ object GroupUtil {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getEncodedOpenGroupInboxID(openGroup: OpenGroup, sessionId: AccountId): Address {
|
||||
fun getEncodedOpenGroupInboxID(openGroup: OpenGroup, accountId: AccountId): Address {
|
||||
val openGroupInboxId =
|
||||
"${openGroup.server}!${openGroup.publicKey}!${sessionId.hexString}".toByteArray()
|
||||
"${openGroup.server}!${openGroup.publicKey}!${accountId.hexString}".toByteArray()
|
||||
return getEncodedOpenGroupInboxID(openGroupInboxId)
|
||||
}
|
||||
|
||||
|
@ -511,11 +511,11 @@ public class Recipient implements RecipientModifiedListener {
|
||||
public synchronized String toShortString() {
|
||||
String name = getName();
|
||||
if (name != null) return name;
|
||||
String sessionId = address.serialize();
|
||||
if (sessionId.length() < 4) return sessionId; // so substrings don't throw out of bounds exceptions
|
||||
String accountId = address.serialize();
|
||||
if (accountId.length() < 4) return accountId; // so substrings don't throw out of bounds exceptions
|
||||
int takeAmount = 4;
|
||||
String start = sessionId.substring(0, takeAmount);
|
||||
String end = sessionId.substring(sessionId.length()-takeAmount);
|
||||
String start = accountId.substring(0, takeAmount);
|
||||
String end = accountId.substring(accountId.length()-takeAmount);
|
||||
return start+"..."+end;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user