Rename remaining session id refs

This commit is contained in:
bemusementpark 2024-07-17 12:32:15 +09:30
parent ce1790a895
commit 8245e4ffe5
37 changed files with 187 additions and 202 deletions

View File

@ -136,29 +136,29 @@ class SodiumUtilitiesTest {
} }
@Test @Test
fun sessionIdSuccess() { fun accountIdSuccess() {
val result = SodiumUtilities.sessionId("05$publicKey", "15$blindedPublicKey", serverPublicKey) val result = SodiumUtilities.accountId("05$publicKey", "15$blindedPublicKey", serverPublicKey)
assertTrue(result) assertTrue(result)
} }
@Test @Test
fun sessionIdFailureInvalidAccountId() { fun accountIdFailureInvalidAccountId() {
val result = SodiumUtilities.sessionId("AB$publicKey", "15$blindedPublicKey", serverPublicKey) val result = SodiumUtilities.accountId("AB$publicKey", "15$blindedPublicKey", serverPublicKey)
assertFalse(result) assertFalse(result)
} }
@Test @Test
fun sessionIdFailureInvalidBlindedId() { fun accountIdFailureInvalidBlindedId() {
val result = SodiumUtilities.sessionId("05$publicKey", "AB$blindedPublicKey", serverPublicKey) val result = SodiumUtilities.accountId("05$publicKey", "AB$blindedPublicKey", serverPublicKey)
assertFalse(result) assertFalse(result)
} }
@Test @Test
fun sessionIdFailureBlindingFactor() { fun accountIdFailureBlindingFactor() {
val result = SodiumUtilities.sessionId("05$publicKey", "15$blindedPublicKey", "Test") val result = SodiumUtilities.accountId("05$publicKey", "15$blindedPublicKey", "Test")
assertFalse(result) assertFalse(result)
} }

View File

@ -45,7 +45,7 @@ class NewMessageFragment : Fragment() {
viewModel, viewModel,
onClose = { delegate.onDialogClosePressed() }, onClose = { delegate.onDialogClosePressed() },
onBack = { delegate.onDialogBackPressed() }, 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") }
) )
} }

View File

@ -239,12 +239,12 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
intent.getParcelableExtra<Address>(ADDRESS)?.let { it -> intent.getParcelableExtra<Address>(ADDRESS)?.let { it ->
threadId = threadDb.getThreadIdIfExistsFor(it.serialize()) threadId = threadDb.getThreadIdIfExistsFor(it.serialize())
if (threadId == -1L) { 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 openGroup = lokiThreadDb.getOpenGroupChat(intent.getLongExtra(FROM_GROUP_THREAD_ID, -1))
val address = if (sessionId.prefix == IdPrefix.BLINDED && openGroup != null) { val address = if (accountId.prefix == IdPrefix.BLINDED && openGroup != null) {
storage.getOrCreateBlindedIdMapping(sessionId.hexString, openGroup.server, openGroup.publicKey).sessionId?.let { storage.getOrCreateBlindedIdMapping(accountId.hexString, openGroup.server, openGroup.publicKey).accountId?.let {
fromSerialized(it) fromSerialized(it)
} ?: GroupUtil.getEncodedOpenGroupInboxID(openGroup, sessionId) } ?: GroupUtil.getEncodedOpenGroupInboxID(openGroup, accountId)
} else { } else {
it it
} }
@ -1131,8 +1131,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
} }
} }
override fun copyAccountID(sessionId: String) { override fun copyAccountID(accountId: String) {
val clip = ClipData.newPlainText("Account ID", sessionId) val clip = ClipData.newPlainText("Account ID", accountId)
val manager = getSystemService(PassphraseRequiredActionBarActivity.CLIPBOARD_SERVICE) as ClipboardManager val manager = getSystemService(PassphraseRequiredActionBarActivity.CLIPBOARD_SERVICE) as ClipboardManager
manager.setPrimaryClip(clip) manager.setPrimaryClip(clip)
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show() Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()

View File

@ -57,7 +57,7 @@ object ConversationMenuHelper {
if (!isOpenGroup && (thread.hasApprovedMe() || thread.isClosedGroupRecipient || thread.isLocalNumber)) { if (!isOpenGroup && (thread.hasApprovedMe() || thread.isClosedGroupRecipient || thread.isLocalNumber)) {
inflater.inflate(R.menu.menu_conversation_expiration, menu) 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) { if (thread.isContactRecipient) {
inflater.inflate(R.menu.menu_conversation_copy_account_id, menu) inflater.inflate(R.menu.menu_conversation_copy_account_id, menu)
} }
@ -325,7 +325,7 @@ object ConversationMenuHelper {
interface ConversationMenuListener { interface ConversationMenuListener {
fun block(deleteThread: Boolean = false) fun block(deleteThread: Boolean = false)
fun unblock() fun unblock()
fun copyAccountID(sessionId: String) fun copyAccountID(accountId: String)
fun copyOpenGroupUrl(thread: Recipient) fun copyOpenGroupUrl(thread: Recipient)
fun showDisappearingMessages(thread: Recipient) fun showDisappearingMessages(thread: Recipient)
} }

View File

@ -157,7 +157,7 @@ object MentionUtilities {
} }
private fun isYou(mentionedPublicKey: String, userPublicKey: String, openGroup: OpenGroup?): Boolean { 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 return mentionedPublicKey.equals(userPublicKey, ignoreCase = true) || isUserBlindedPublicKey
} }
} }

View File

@ -31,7 +31,7 @@ class BlindedIdMappingDatabase(context: Context, helper: SQLCipherOpenHelper) :
private fun readBlindedIdMapping(cursor: Cursor): BlindedIdMapping { private fun readBlindedIdMapping(cursor: Cursor): BlindedIdMapping {
return BlindedIdMapping( return BlindedIdMapping(
blindedId = cursor.getString(cursor.getColumnIndexOrThrow(BLINDED_PK)), 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)), serverUrl = cursor.getString(cursor.getColumnIndexOrThrow(SERVER_URL)),
serverId = cursor.getString(cursor.getColumnIndexOrThrow(SERVER_PK)), serverId = cursor.getString(cursor.getColumnIndexOrThrow(SERVER_PK)),
) )
@ -58,7 +58,7 @@ class BlindedIdMappingDatabase(context: Context, helper: SQLCipherOpenHelper) :
try { try {
val values = ContentValues().apply { val values = ContentValues().apply {
put(BLINDED_PK, blindedIdMapping.blindedId) put(BLINDED_PK, blindedIdMapping.blindedId)
put(SERVER_PK, blindedIdMapping.sessionId) put(SERVER_PK, blindedIdMapping.accountId)
put(SERVER_URL, blindedIdMapping.serverUrl) put(SERVER_URL, blindedIdMapping.serverUrl)
put(SERVER_PK, blindedIdMapping.serverId) put(SERVER_PK, blindedIdMapping.serverId)
} }

View File

@ -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 val database = databaseHelper.readableDatabase
return database.getAll( return database.getAll(
sessionContactTable, sessionContactTable,
"$accountID IN (SELECT value FROM json_each(?))", "$accountID IN (SELECT value FROM json_each(?))",
arrayOf(JSONArray(sessionIDs).toString()) arrayOf(JSONArray(accountIDs).toString())
) { cursor -> contactFromCursor(cursor) } ) { cursor -> contactFromCursor(cursor) }
} }
@ -56,8 +56,7 @@ class SessionContactDatabase(context: Context, helper: SQLCipherOpenHelper) : Da
return database.getAll(sessionContactTable, null, null) { cursor -> return database.getAll(sessionContactTable, null, null) { cursor ->
contactFromCursor(cursor) contactFromCursor(cursor)
}.filter { contact -> }.filter { contact ->
val sessionId = AccountId(contact.accountID) contact.accountID.let(::AccountId).prefix == IdPrefix.STANDARD
sessionId.prefix == IdPrefix.STANDARD
}.toSet() }.toSet()
} }

View File

@ -6,6 +6,7 @@ import java.security.MessageDigest
import network.loki.messenger.libsession_util.ConfigBase 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_HIDDEN
import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_PINNED 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.Contacts
import network.loki.messenger.libsession_util.ConversationVolatileConfig import network.loki.messenger.libsession_util.ConversationVolatileConfig
import network.loki.messenger.libsession_util.UserGroupsConfig import network.loki.messenger.libsession_util.UserGroupsConfig
@ -111,12 +112,12 @@ open class Storage(
if (address.isGroup) { if (address.isGroup) {
val groups = configFactory.userGroups ?: return val groups = configFactory.userGroups ?: return
if (address.isClosedGroup) { if (address.isClosedGroup) {
val sessionId = GroupUtil.doubleDecodeGroupId(address.serialize()) val accountId = GroupUtil.doubleDecodeGroupId(address.serialize())
val closedGroup = getGroup(address.toGroupString()) val closedGroup = getGroup(address.toGroupString())
if (closedGroup != null && closedGroup.isActive) { if (closedGroup != null && closedGroup.isActive) {
val legacyGroup = groups.getOrConstructLegacyGroupInfo(sessionId) val legacyGroup = groups.getOrConstructLegacyGroupInfo(accountId)
groups.set(legacyGroup) groups.set(legacyGroup)
val newVolatileParams = volatile.getOrConstructLegacyGroup(sessionId).copy( val newVolatileParams = volatile.getOrConstructLegacyGroup(accountId).copy(
lastRead = SnodeAPI.nowWithOffset, lastRead = SnodeAPI.nowWithOffset,
) )
volatile.set(newVolatileParams) volatile.set(newVolatileParams)
@ -132,11 +133,11 @@ open class Storage(
if (getUserPublicKey() != address.serialize()) { if (getUserPublicKey() != address.serialize()) {
val contacts = configFactory.contacts ?: return val contacts = configFactory.contacts ?: return
contacts.upsertContact(address.serialize()) { contacts.upsertContact(address.serialize()) {
priority = ConfigBase.PRIORITY_VISIBLE priority = PRIORITY_VISIBLE
} }
} else { } else {
val userProfile = configFactory.user ?: return val userProfile = configFactory.user ?: return
userProfile.setNtsPriority(ConfigBase.PRIORITY_VISIBLE) userProfile.setNtsPriority(PRIORITY_VISIBLE)
DatabaseComponent.get(context).threadDatabase().setHasSent(threadId, true) DatabaseComponent.get(context).threadDatabase().setHasSent(threadId, true)
} }
val newVolatileParams = volatile.getOrConstructOneToOne(address.serialize()) val newVolatileParams = volatile.getOrConstructOneToOne(address.serialize())
@ -149,9 +150,9 @@ open class Storage(
if (address.isGroup) { if (address.isGroup) {
val groups = configFactory.userGroups ?: return val groups = configFactory.userGroups ?: return
if (address.isClosedGroup) { if (address.isClosedGroup) {
val sessionId = GroupUtil.doubleDecodeGroupId(address.serialize()) val accountId = GroupUtil.doubleDecodeGroupId(address.serialize())
volatile.eraseLegacyClosedGroup(sessionId) volatile.eraseLegacyClosedGroup(accountId)
groups.eraseLegacyGroup(sessionId) groups.eraseLegacyGroup(accountId)
} else if (address.isCommunity) { } else if (address.isCommunity) {
// these should be removed in the group leave / handling new configs // 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") 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 // otherwise recipient is one to one
recipient.isContactRecipient -> { recipient.isContactRecipient -> {
// don't process non-standard session IDs though // don't process non-standard account IDs though
val sessionId = AccountId(recipient.address.serialize()) if (AccountId(recipient.address.serialize()).prefix != IdPrefix.STANDARD) return
if (sessionId.prefix != IdPrefix.STANDARD) return
config.getOrConstructOneToOne(recipient.address.serialize()) config.getOrConstructOneToOne(recipient.address.serialize())
} }
else -> throw NullPointerException("Weren't expecting to have a convo with address ${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 var messageID: Long? = null
val senderAddress = fromSerialized(message.sender!!) val senderAddress = fromSerialized(message.sender!!)
val isUserSender = (message.sender!! == getUserPublicKey()) val isUserSender = (message.sender!! == getUserPublicKey())
val isUserBlindedSender = message.threadID?.takeIf { it >= 0 }?.let { getOpenGroup(it)?.publicKey } val isUserBlindedSender = message.threadID?.takeIf { it >= 0 }?.let(::getOpenGroup)?.publicKey
?.let { SodiumUtilities.sessionId(getUserPublicKey()!!, message.sender!!, it) } ?: false ?.let { SodiumUtilities.accountId(getUserPublicKey()!!, message.sender!!, it) } ?: false
val group: Optional<SignalServiceGroup> = when { val group: Optional<SignalServiceGroup> = when {
openGroupID != null -> Optional.of(SignalServiceGroup(openGroupID.toByteArray(), SignalServiceGroup.GroupType.PUBLIC_CHAT)) openGroupID != null -> Optional.of(SignalServiceGroup(openGroupID.toByteArray(), SignalServiceGroup.GroupType.PUBLIC_CHAT))
groupPublicKey != null -> { groupPublicKey != null -> {
@ -540,7 +539,7 @@ open class Storage(
val extracted = convos.all() val extracted = convos.all()
for (conversation in extracted) { for (conversation in extracted) {
val threadId = when (conversation) { 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.LegacyGroup -> getThreadIdFor("", conversation.groupId,null, createThread = false)
is Conversation.Community -> getThreadIdFor("",null, "${conversation.baseCommunityInfo.baseUrl.removeSuffix("/")}.${conversation.baseCommunityInfo.room}", 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 existingJoinUrls = existingCommunities.values.map { it.joinURL }
val existingClosedGroups = getAllGroups(includeInactive = true).filter { it.isClosedGroup } 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 -> val toDeleteClosedGroups = existingClosedGroups.filter { group ->
GroupUtil.doubleDecodeGroupId(group.encodedId) !in lgcIds GroupUtil.doubleDecodeGroupId(group.encodedId) !in lgcIds
} }
@ -605,8 +604,8 @@ open class Storage(
} }
for (group in lgc) { for (group in lgc) {
val groupId = GroupUtil.doubleEncodeGroupID(group.sessionId) val groupId = GroupUtil.doubleEncodeGroupID(group.accountId)
val existingGroup = existingClosedGroups.firstOrNull { GroupUtil.doubleDecodeGroupId(it.encodedId) == group.sessionId } val existingGroup = existingClosedGroups.firstOrNull { GroupUtil.doubleDecodeGroupId(it.encodedId) == group.accountId }
val existingThread = existingGroup?.let { getThreadId(existingGroup.encodedId) } val existingThread = existingGroup?.let { getThreadId(existingGroup.encodedId) }
if (existingGroup != null) { if (existingGroup != null) {
if (group.priority == PRIORITY_HIDDEN && existingThread != null) { if (group.priority == PRIORITY_HIDDEN && existingThread != null) {
@ -625,19 +624,19 @@ open class Storage(
createGroup(groupId, title, admins + members, null, null, admins, formationTimestamp) createGroup(groupId, title, admins + members, null, null, admins, formationTimestamp)
setProfileSharing(Address.fromSerialized(groupId), true) setProfileSharing(Address.fromSerialized(groupId), true)
// Add the group to the user's set of public keys to poll for // 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 // Store the encryption key pair
val keyPair = ECKeyPair(DjbECPublicKey(group.encPubKey), DjbECPrivateKey(group.encSecKey)) 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 // Notify the PN server
PushRegistryV1.subscribeGroup(group.sessionId, publicKey = localUserPublicKey) PushRegistryV1.subscribeGroup(group.accountId, publicKey = localUserPublicKey)
// Notify the user // Notify the user
val threadID = getOrCreateThreadIdFor(Address.fromSerialized(groupId)) val threadID = getOrCreateThreadIdFor(Address.fromSerialized(groupId))
threadDb.setDate(threadID, formationTimestamp) threadDb.setDate(threadID, formationTimestamp)
insertOutgoingInfoMessage(context, groupId, SignalServiceGroup.Type.CREATION, title, members.map { it.serialize() }, admins.map { it.serialize() }, 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 // Don't create config group here, it's from a config update
// Start polling // Start polling
ClosedGroupPollerV2.shared.startPolling(group.sessionId) ClosedGroupPollerV2.shared.startPolling(group.accountId)
} }
getThreadId(Address.fromSerialized(groupId))?.let { getThreadId(Address.fromSerialized(groupId))?.let {
setExpirationConfiguration( setExpirationConfiguration(
@ -938,10 +937,10 @@ open class Storage(
groupVolatileConfig.lastRead = formationTimestamp groupVolatileConfig.lastRead = formationTimestamp
volatiles.set(groupVolatileConfig) volatiles.set(groupVolatileConfig)
val groupInfo = GroupInfo.LegacyGroupInfo( val groupInfo = GroupInfo.LegacyGroupInfo(
sessionId = groupPublicKey, accountId = groupPublicKey,
name = name, name = name,
members = members, members = members,
priority = ConfigBase.PRIORITY_VISIBLE, priority = PRIORITY_VISIBLE,
encPubKey = (encryptionKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte encPubKey = (encryptionKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte
encSecKey = encryptionKeyPair.privateKey.serialize(), encSecKey = encryptionKeyPair.privateKey.serialize(),
disappearingTimer = expirationTimer.toLong(), disappearingTimer = expirationTimer.toLong(),
@ -975,7 +974,7 @@ open class Storage(
members = membersMap, members = membersMap,
encPubKey = (latestKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte encPubKey = (latestKeyPair.publicKey as DjbECPublicKey).publicKey, // 'serialize()' inserts an extra byte
encSecKey = latestKeyPair.privateKey.serialize(), 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, disappearingTimer = getExpirationConfiguration(threadID)?.expiryMode?.expirySeconds ?: 0L,
joinedAt = (existingGroup.formationTimestamp / 1000L) joinedAt = (existingGroup.formationTimestamp / 1000L)
) )
@ -1209,7 +1208,7 @@ open class Storage(
val mappingDb = DatabaseComponent.get(context).blindedIdMappingDatabase() val mappingDb = DatabaseComponent.get(context).blindedIdMappingDatabase()
val moreContacts = contacts.filter { contact -> val moreContacts = contacts.filter { contact ->
val id = AccountId(contact.id) 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 val profileManager = SSKEnvironment.shared.profileManager
moreContacts.forEach { contact -> moreContacts.forEach { contact ->
@ -1262,7 +1261,7 @@ open class Storage(
val mappingDb = DatabaseComponent.get(context).blindedIdMappingDatabase() val mappingDb = DatabaseComponent.get(context).blindedIdMappingDatabase()
val moreContacts = contacts.filter { contact -> val moreContacts = contacts.filter { contact ->
val id = AccountId(contact.publicKey) 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) { for (contact in moreContacts) {
val address = fromSerialized(contact.publicKey) val address = fromSerialized(contact.publicKey)
@ -1329,25 +1328,25 @@ open class Storage(
val threadRecipient = getRecipientForThread(threadID) ?: return val threadRecipient = getRecipientForThread(threadID) ?: return
if (threadRecipient.isLocalNumber) { if (threadRecipient.isLocalNumber) {
val user = configFactory.user ?: return 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) { } else if (threadRecipient.isContactRecipient) {
val contacts = configFactory.contacts ?: return val contacts = configFactory.contacts ?: return
contacts.upsertContact(threadRecipient.address.serialize()) { 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) { } else if (threadRecipient.isGroupRecipient) {
val groups = configFactory.userGroups ?: return val groups = configFactory.userGroups ?: return
if (threadRecipient.isClosedGroupRecipient) { if (threadRecipient.isClosedGroupRecipient) {
val sessionId = GroupUtil.doubleDecodeGroupId(threadRecipient.address.serialize()) threadRecipient.address.serialize()
val newGroupInfo = groups.getOrConstructLegacyGroupInfo(sessionId).copy ( .let(GroupUtil::doubleDecodeGroupId)
priority = if (isPinned) PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE .let(groups::getOrConstructLegacyGroupInfo)
) .copy (priority = if (isPinned) PRIORITY_PINNED else PRIORITY_VISIBLE)
groups.set(newGroupInfo) .let(groups::set)
} else if (threadRecipient.isCommunityRecipient) { } else if (threadRecipient.isCommunityRecipient) {
val openGroup = getOpenGroup(threadID) ?: return val openGroup = getOpenGroup(threadID) ?: return
val (baseUrl, room, pubKeyHex) = BaseCommunityInfo.parseFullUrl(openGroup.joinURL) ?: return val (baseUrl, room, pubKeyHex) = BaseCommunityInfo.parseFullUrl(openGroup.joinURL) ?: return
val newGroupInfo = groups.getOrConstructCommunityInfo(baseUrl, room, Hex.toStringCondensed(pubKeyHex)).copy ( 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) groups.set(newGroupInfo)
} }
@ -1505,10 +1504,10 @@ open class Storage(
} }
} }
for (mapping in mappings) { 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 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)) val blindedThreadId = threadDB.getOrCreateThreadIdFor(Recipient.from(context, fromSerialized(mapping.key), false))
mmsDb.updateThreadId(blindedThreadId, threadId) mmsDb.updateThreadId(blindedThreadId, threadId)
@ -1614,20 +1613,20 @@ open class Storage(
): BlindedIdMapping { ): BlindedIdMapping {
val db = DatabaseComponent.get(context).blindedIdMappingDatabase() val db = DatabaseComponent.get(context).blindedIdMappingDatabase()
val mapping = db.getBlindedIdMapping(blindedId).firstOrNull() ?: BlindedIdMapping(blindedId, null, server, serverPublicKey) val mapping = db.getBlindedIdMapping(blindedId).firstOrNull() ?: BlindedIdMapping(blindedId, null, server, serverPublicKey)
if (mapping.sessionId != null) { if (mapping.accountId != null) {
return mapping return mapping
} }
getAllContacts().forEach { contact -> getAllContacts().forEach { contact ->
val sessionId = AccountId(contact.accountID) val accountId = AccountId(contact.accountID)
if (sessionId.prefix == IdPrefix.STANDARD && SodiumUtilities.sessionId(sessionId.hexString, blindedId, serverPublicKey)) { if (accountId.prefix == IdPrefix.STANDARD && SodiumUtilities.accountId(accountId.hexString, blindedId, serverPublicKey)) {
val contactMapping = mapping.copy(sessionId = sessionId.hexString) val contactMapping = mapping.copy(accountId = accountId.hexString)
db.addBlindedIdMapping(contactMapping) db.addBlindedIdMapping(contactMapping)
return contactMapping return contactMapping
} }
} }
db.getBlindedIdMappingsExceptFor(server).forEach { db.getBlindedIdMappingsExceptFor(server).forEach {
if (SodiumUtilities.sessionId(it.sessionId!!, blindedId, serverPublicKey)) { if (SodiumUtilities.accountId(it.accountId!!, blindedId, serverPublicKey)) {
val otherMapping = mapping.copy(sessionId = it.sessionId) val otherMapping = mapping.copy(accountId = it.accountId)
db.addBlindedIdMapping(otherMapping) db.addBlindedIdMapping(otherMapping)
return otherMapping return otherMapping
} }

View File

@ -72,7 +72,7 @@ class QRCodeActivity : PassphraseRequiredActionBarActivity() {
@OptIn(ExperimentalFoundationApi::class) @OptIn(ExperimentalFoundationApi::class)
@Composable @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 } val pagerState = rememberPagerState { TITLES.size }
Column { Column {
@ -82,7 +82,7 @@ private fun Tabs(sessionId: String, errors: Flow<String>, onScan: (String) -> Un
modifier = Modifier.weight(1f) modifier = Modifier.weight(1f)
) { page -> ) { page ->
when (TITLES[page]) { when (TITLES[page]) {
R.string.view -> QrPage(sessionId) R.string.view -> QrPage(accountId)
R.string.scan -> MaybeScanQrCode(errors, onScan = onScan) R.string.scan -> MaybeScanQrCode(errors, onScan = onScan)
} }
} }

View File

@ -293,7 +293,7 @@ class DefaultConversationRepository @Inject constructor(
override suspend fun banAndDeleteAll(threadId: Long, recipient: Recipient): ResultOf<Unit> = override suspend fun banAndDeleteAll(threadId: Long, recipient: Recipient): ResultOf<Unit> =
suspendCoroutine { continuation -> suspendCoroutine { continuation ->
// Note: This sessionId could be the blinded Id // Note: This accountId could be the blinded Id
val accountID = recipient.address.toString() val accountID = recipient.address.toString()
val openGroup = lokiThreadDb.getOpenGroupChat(threadId)!! val openGroup = lokiThreadDb.getOpenGroupChat(threadId)!!

View File

@ -92,8 +92,8 @@ class ProfileManager(private val context: Context, private val configFactory: Co
override fun contactUpdatedInternal(contact: Contact): String? { override fun contactUpdatedInternal(contact: Contact): String? {
val contactConfig = configFactory.contacts ?: return null val contactConfig = configFactory.contacts ?: return null
if (contact.accountID == TextSecurePreferences.getLocalNumber(context)) return null if (contact.accountID == TextSecurePreferences.getLocalNumber(context)) return null
val sessionId = AccountId(contact.accountID) val accountId = AccountId(contact.accountID)
if (sessionId.prefix != IdPrefix.STANDARD) return null // only internally store standard session IDs if (accountId.prefix != IdPrefix.STANDARD) return null // only internally store standard account IDs
contactConfig.upsertContact(contact.accountID) { contactConfig.upsertContact(contact.accountID) {
this.name = contact.name.orEmpty() this.name = contact.name.orEmpty()
this.nickname = contact.nickname.orEmpty() this.nickname = contact.nickname.orEmpty()

View File

@ -205,7 +205,7 @@ object ConfigurationMessageUtilities {
val admins = group.admins.map { it.serialize() to true }.toMap() 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() val members = group.members.filterNot { it.serialize() !in admins.keys }.map { it.serialize() to false }.toMap()
GroupInfo.LegacyGroupInfo( GroupInfo.LegacyGroupInfo(
sessionId = groupPublicKey, accountId = groupPublicKey,
name = group.title, name = group.title,
members = admins + members, members = admins + members,
priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE, priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE,

View File

@ -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="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_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_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_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="fragment_scan_qr_code_grant_camera_access_button_title">Kamerazugriff gewähren</string>
<string name="activity_create_closed_group_title">Neue geschlossene Gruppe</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_day">Tag</string>
<string name="dialog_ui_mode_option_night">Nacht</string> <string name="dialog_ui_mode_option_night">Nacht</string>
<string name="dialog_ui_mode_option_system_default">Systemstandard</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">Anhang</string>
<string name="attachment_type_voice_message">Sprachnachricht</string> <string name="attachment_type_voice_message">Sprachnachricht</string>
<string name="details">Details</string> <string name="details">Details</string>

View File

@ -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="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_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_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_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="fragment_scan_qr_code_grant_camera_access_button_title">Kamerazugriff gewähren</string>
<string name="activity_create_closed_group_title">Neue geschlossene Gruppe</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_day">Tag</string>
<string name="dialog_ui_mode_option_night">Nacht</string> <string name="dialog_ui_mode_option_night">Nacht</string>
<string name="dialog_ui_mode_option_system_default">Systemstandard</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">Anhang</string>
<string name="attachment_type_voice_message">Sprachnachricht</string> <string name="attachment_type_voice_message">Sprachnachricht</string>
<string name="details">Details</string> <string name="details">Details</string>

View File

@ -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_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="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_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="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_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> <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_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_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="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_edit_text_hint">Angi Account-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_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 Session-ID\'en eller ONS-navnet og prøv igjen.</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_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="fragment_scan_qr_code_grant_camera_access_button_title">Gi kameratilgang</string>
<string name="activity_create_closed_group_title">Ny lukket gruppe</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_day">Dag</string>
<string name="dialog_ui_mode_option_night">Natt</string> <string name="dialog_ui_mode_option_night">Natt</string>
<string name="dialog_ui_mode_option_system_default">Systemstandard</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">Vedlegg</string>
<string name="attachment_type_voice_message">Talemelding</string> <string name="attachment_type_voice_message">Talemelding</string>
<string name="details">Detaljer</string> <string name="details">Detaljer</string>

View File

@ -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_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="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_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="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_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> <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_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_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="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_edit_text_hint">Angi Account-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_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 Session-ID\'en eller ONS-navnet og prøv igjen.</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_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="fragment_scan_qr_code_grant_camera_access_button_title">Gi kameratilgang</string>
<string name="activity_create_closed_group_title">Ny lukket gruppe</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_day">Dag</string>
<string name="dialog_ui_mode_option_night">Natt</string> <string name="dialog_ui_mode_option_night">Natt</string>
<string name="dialog_ui_mode_option_system_default">Systemstandard</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">Vedlegg</string>
<string name="attachment_type_voice_message">Talemelding</string> <string name="attachment_type_voice_message">Talemelding</string>
<string name="details">Detaljer</string> <string name="details">Detaljer</string>

View File

@ -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_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="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_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_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_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> <string name="fragment_scan_qr_code_grant_camera_access_button_title">Toegang tot camera verlenen</string>

View File

@ -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_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="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_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_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_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> <string name="fragment_scan_qr_code_grant_camera_access_button_title">Toegang tot camera verlenen</string>

View File

@ -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_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="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_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="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_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> <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_day">Dag</string>
<string name="dialog_ui_mode_option_night">Natt</string> <string name="dialog_ui_mode_option_night">Natt</string>
<string name="dialog_ui_mode_option_system_default">Systemets inställning</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">Bilaga</string>
<string name="attachment_type_voice_message">Röstmeddelande</string> <string name="attachment_type_voice_message">Röstmeddelande</string>
<string name="details">Detaljer</string> <string name="details">Detaljer</string>

View File

@ -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_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="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_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="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_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> <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_day">Dag</string>
<string name="dialog_ui_mode_option_night">Natt</string> <string name="dialog_ui_mode_option_night">Natt</string>
<string name="dialog_ui_mode_option_system_default">Systemets inställning</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">Bilaga</string>
<string name="attachment_type_voice_message">Röstmeddelande</string> <string name="attachment_type_voice_message">Röstmeddelande</string>
<string name="details">Detaljer</string> <string name="details">Detaljer</string>

View File

@ -368,7 +368,7 @@ class InstrumentedTests {
assertEquals(2, convos.sizeOneToOnes()) assertEquals(2, convos.sizeOneToOnes())
val numErased = convos.eraseAll { convo -> val numErased = convos.eraseAll { convo ->
convo is Conversation.OneToOne && convo.sessionId == definitelyRealId convo is Conversation.OneToOne && convo.accountId == definitelyRealId
} }
assertEquals(1, numErased) assertEquals(1, numErased)
assertEquals(1, convos.sizeOneToOnes()) assertEquals(1, convos.sizeOneToOnes())
@ -453,7 +453,7 @@ class InstrumentedTests {
val c = convos.getOrConstructOneToOne(definitelyRealId) val c = convos.getOrConstructOneToOne(definitelyRealId)
assertEquals(definitelyRealId, c.sessionId) assertEquals(definitelyRealId, c.accountId)
assertEquals(0, c.lastRead) assertEquals(0, c.lastRead)
assertFalse(convos.needsPush()) assertFalse(convos.needsPush())
@ -504,7 +504,7 @@ class InstrumentedTests {
val x1 = convos2.getOneToOne(definitelyRealId)!! val x1 = convos2.getOneToOne(definitelyRealId)!!
assertEquals(nowMs, x1.lastRead) assertEquals(nowMs, x1.lastRead)
assertEquals(definitelyRealId, x1.sessionId) assertEquals(definitelyRealId, x1.accountId)
assertEquals(false, x1.unread) assertEquals(false, x1.unread)
val x2 = convos2.getCommunity("http://EXAMPLE.org:5678", "sudokuRoom")!! val x2 = convos2.getCommunity("http://EXAMPLE.org:5678", "sudokuRoom")!!
@ -548,7 +548,7 @@ class InstrumentedTests {
val allConvos = conv.all() val allConvos = conv.all()
for (convo in allConvos) { for (convo in allConvos) {
when (convo) { 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.Community -> seen.add("og: ${convo.baseCommunityInfo.baseUrl}/r/${convo.baseCommunityInfo.room}")
is Conversation.LegacyGroup -> seen.add("cl: ${convo.groupId}") is Conversation.LegacyGroup -> seen.add("cl: ${convo.groupId}")
} }
@ -569,7 +569,7 @@ class InstrumentedTests {
assertEquals(1, convos.allOneToOnes().size) assertEquals(1, convos.allOneToOnes().size)
assertEquals("051111111111111111111111111111111111111111111111111111111111111111", assertEquals("051111111111111111111111111111111111111111111111111111111111111111",
convos.allOneToOnes().map(Conversation.OneToOne::sessionId).first() convos.allOneToOnes().map(Conversation.OneToOne::accountId).first()
) )
assertEquals(1, convos.allCommunities().size) assertEquals(1, convos.allCommunities().size)
assertEquals("http://example.org:5678", assertEquals("http://example.org:5678",

View File

@ -5,15 +5,15 @@
extern "C" extern "C"
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL
Java_network_loki_messenger_libsession_1util_Contacts_get(JNIEnv *env, jobject thiz, 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 // If an exception is thrown, return nullptr
return jni_utils::run_catching_cxx_exception_or<jobject>( return jni_utils::run_catching_cxx_exception_or<jobject>(
[=]() -> jobject { [=]() -> jobject {
std::lock_guard lock{util::util_mutex_}; std::lock_guard lock{util::util_mutex_};
auto contacts = ptrToContacts(env, thiz); auto contacts = ptrToContacts(env, thiz);
auto session_id_chars = env->GetStringUTFChars(session_id, nullptr); auto account_id_chars = env->GetStringUTFChars(account_id, nullptr);
auto contact = contacts->get(session_id_chars); auto contact = contacts->get(account_id_chars);
env->ReleaseStringUTFChars(session_id, session_id_chars); env->ReleaseStringUTFChars(account_id, account_id_chars);
if (!contact) return nullptr; if (!contact) return nullptr;
jobject j_contact = serialize_contact(env, contact.value()); jobject j_contact = serialize_contact(env, contact.value());
return j_contact; return j_contact;
@ -25,13 +25,13 @@ Java_network_loki_messenger_libsession_1util_Contacts_get(JNIEnv *env, jobject t
extern "C" extern "C"
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL
Java_network_loki_messenger_libsession_1util_Contacts_getOrConstruct(JNIEnv *env, jobject thiz, 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, [=] { return jni_utils::run_catching_cxx_exception_or_throws<jobject>(env, [=] {
std::lock_guard lock{util::util_mutex_}; std::lock_guard lock{util::util_mutex_};
auto contacts = ptrToContacts(env, thiz); auto contacts = ptrToContacts(env, thiz);
auto session_id_chars = env->GetStringUTFChars(session_id, nullptr); auto account_id_chars = env->GetStringUTFChars(account_id, nullptr);
auto contact = contacts->get_or_construct(session_id_chars); auto contact = contacts->get_or_construct(account_id_chars);
env->ReleaseStringUTFChars(session_id, session_id_chars); env->ReleaseStringUTFChars(account_id, account_id_chars);
return serialize_contact(env, contact); return serialize_contact(env, contact);
}); });
} }
@ -51,14 +51,14 @@ Java_network_loki_messenger_libsession_1util_Contacts_set(JNIEnv *env, jobject t
extern "C" extern "C"
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_network_loki_messenger_libsession_1util_Contacts_erase(JNIEnv *env, jobject thiz, 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, [=] { return jni_utils::run_catching_cxx_exception_or_throws<jboolean>(env, [=] {
std::lock_guard lock{util::util_mutex_}; std::lock_guard lock{util::util_mutex_};
auto contacts = ptrToContacts(env, thiz); 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); bool result = contacts->erase(account_id_chars);
env->ReleaseStringUTFChars(session_id, session_id_chars); env->ReleaseStringUTFChars(account_id, account_id_chars);
return result; return result;
}); });
} }

View File

@ -43,8 +43,8 @@ inline session::config::contact_info deserialize_contact(JNIEnv *env, jobject in
"Lnetwork/loki/messenger/libsession_util/util/UserPic;"); "Lnetwork/loki/messenger/libsession_util/util/UserPic;");
getPriority = env->GetFieldID(contactClass, "priority", "I"); getPriority = env->GetFieldID(contactClass, "priority", "I");
getExpiry = env->GetFieldID(contactClass, "expiryMode", "Lnetwork/loki/messenger/libsession_util/util/ExpiryMode;"); getExpiry = env->GetFieldID(contactClass, "expiryMode", "Lnetwork/loki/messenger/libsession_util/util/ExpiryMode;");
jstring name, nickname, session_id; jstring name, nickname, account_id;
session_id = static_cast<jstring>(env->GetObjectField(info, getId)); account_id = static_cast<jstring>(env->GetObjectField(info, getId));
name = static_cast<jstring>(env->GetObjectField(info, getName)); name = static_cast<jstring>(env->GetObjectField(info, getName));
nickname = static_cast<jstring>(env->GetObjectField(info, getNick)); nickname = static_cast<jstring>(env->GetObjectField(info, getNick));
bool approved, approvedMe, blocked, hidden; 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); 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 name_bytes = name ? env->GetStringUTFChars(name, nullptr) : nullptr;
auto nickname_bytes = nickname ? env->GetStringUTFChars(nickname, 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) { if (name_bytes) {
contact_info.name = 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(); 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) { if (name_bytes) {
env->ReleaseStringUTFChars(name, name_bytes); env->ReleaseStringUTFChars(name, name_bytes);
} }

View File

@ -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) { 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"); jclass clazz = env->FindClass("network/loki/messenger/libsession_util/util/Conversation$OneToOne");
jmethodID constructor = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;JZ)V"); 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 last_read = one_to_one.last_read;
auto unread = one_to_one.unread; 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; 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) { 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 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 last_read_getter = env->GetFieldID(clazz, "lastRead", "J");
auto unread_getter = env->GetFieldID(clazz, "unread", "Z"); auto unread_getter = env->GetFieldID(clazz, "unread", "Z");
jstring id = static_cast<jstring>(env->GetObjectField(info, id_getter)); jstring id = static_cast<jstring>(env->GetObjectField(info, id_getter));

View File

@ -74,16 +74,16 @@ extern "C"
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getLegacyGroupInfo(JNIEnv *env, Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getLegacyGroupInfo(JNIEnv *env,
jobject thiz, jobject thiz,
jstring session_id) { jstring account_id) {
std::lock_guard lock{util::util_mutex_}; std::lock_guard lock{util::util_mutex_};
auto conf = ptrToUserGroups(env, thiz); 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); auto legacy_group = conf->get_legacy_group(id_bytes);
jobject return_group = nullptr; jobject return_group = nullptr;
if (legacy_group) { if (legacy_group) {
return_group = serialize_legacy_group_info(env, *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; return return_group;
} }
@ -108,12 +108,12 @@ Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getOrConstructComm
extern "C" extern "C"
JNIEXPORT jobject JNICALL JNIEXPORT jobject JNICALL
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_getOrConstructLegacyGroupInfo( 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_}; std::lock_guard lock{util::util_mutex_};
auto conf = ptrToUserGroups(env, thiz); 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); 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); return serialize_legacy_group_info(env, group);
} }
@ -264,11 +264,11 @@ extern "C"
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_network_loki_messenger_libsession_1util_UserGroupsConfig_eraseLegacyGroup(JNIEnv *env, Java_network_loki_messenger_libsession_1util_UserGroupsConfig_eraseLegacyGroup(JNIEnv *env,
jobject thiz, jobject thiz,
jstring session_id) { jstring account_id) {
std::lock_guard lock{util::util_mutex_}; std::lock_guard lock{util::util_mutex_};
auto conf = ptrToUserGroups(env, thiz); auto conf = ptrToUserGroups(env, thiz);
auto session_id_bytes = env->GetStringUTFChars(session_id, nullptr); auto account_id_bytes = env->GetStringUTFChars(account_id, nullptr);
bool return_bool = conf->erase_legacy_group(session_id_bytes); bool return_bool = conf->erase_legacy_group(account_id_bytes);
env->ReleaseStringUTFChars(session_id, session_id_bytes); env->ReleaseStringUTFChars(account_id, account_id_bytes);
return return_bool; return return_bool;
} }

View File

@ -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) { 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 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 name_field = env->GetFieldID(clazz, "name", "Ljava/lang/String;");
auto members_field = env->GetFieldID(clazz, "members", "Ljava/util/Map;"); auto members_field = env->GetFieldID(clazz, "members", "Ljava/util/Map;");
auto enc_pub_key_field = env->GetFieldID(clazz, "encPubKey", "[B"); 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); jobject new_map = env->NewObject(map_class, map_constructor);
for (auto it = members_map.begin(); it != members_map.end(); it++) { 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; bool is_admin = it->second;
auto jbool = env->NewObject(boxed_bool, new_bool, is_admin); 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; return new_map;
} }
inline jobject serialize_legacy_group_info(JNIEnv *env, session::config::legacy_group_info info) { 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()); jstring name = env->NewStringUTF(info.name.data());
jobject members = serialize_members(env, info.members()); jobject members = serialize_members(env, info.members());
jbyteArray enc_pubkey = util::bytes_from_ustring(env, info.enc_pubkey); 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"); 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"); 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; return serialized;
} }

View File

@ -61,49 +61,41 @@ class Contacts(pointer: Long) : ConfigBase(pointer) {
external fun newInstance(ed25519SecretKey: ByteArray, initialDump: ByteArray): Contacts external fun newInstance(ed25519SecretKey: ByteArray, initialDump: ByteArray): Contacts
} }
external fun get(sessionId: String): Contact? external fun get(accountId: String): Contact?
external fun getOrConstruct(sessionId: String): Contact external fun getOrConstruct(accountId: String): Contact
external fun all(): List<Contact> external fun all(): List<Contact>
external fun set(contact: 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] * 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 = {}) { fun upsertContact(accountId: String, updateFunction: Contact.()->Unit = {}) {
if (sessionId.startsWith(IdPrefix.BLINDED.value)) { when {
Log.w("Loki", "Trying to create a contact with a blinded ID prefix") accountId.startsWith(IdPrefix.BLINDED.value) -> Log.w("Loki", "Trying to create a contact with a blinded ID prefix")
return accountId.startsWith(IdPrefix.UN_BLINDED.value) -> Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix")
} else if (sessionId.startsWith(IdPrefix.UN_BLINDED.value)) { accountId.startsWith(IdPrefix.BLINDEDV2.value) -> Log.w("Loki", "Trying to create a contact with a blindedv2 ID prefix")
Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix") else -> getOrConstruct(accountId).let {
return updateFunction(it)
} else if (sessionId.startsWith(IdPrefix.BLINDEDV2.value)) { set(it)
Log.w("Loki", "Trying to create a contact with a blindedv2 ID prefix") }
return
} }
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 * the [updateFunction] doesn't run if there is no contact
*/ */
fun updateIfExists(sessionId: String, updateFunction: Contact.()->Unit) { private fun updateIfExists(accountId: String, updateFunction: Contact.()->Unit) {
if (sessionId.startsWith(IdPrefix.BLINDED.value)) { when {
Log.w("Loki", "Trying to create a contact with a blinded ID prefix") accountId.startsWith(IdPrefix.BLINDED.value) -> Log.w("Loki", "Trying to create a contact with a blinded ID prefix")
return accountId.startsWith(IdPrefix.UN_BLINDED.value) -> Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix")
} else if (sessionId.startsWith(IdPrefix.UN_BLINDED.value)) { accountId.startsWith(IdPrefix.BLINDEDV2.value) -> Log.w("Loki", "Trying to create a contact with a blindedv2 ID prefix")
Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix") else -> get(accountId)?.let {
return updateFunction(it)
} else if (sessionId.startsWith(IdPrefix.BLINDEDV2.value)) { set(it)
Log.w("Loki", "Trying to create a contact with a blindedv2 ID prefix") }
return
} }
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 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 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 set(groupInfo: GroupInfo)
external fun erase(communityInfo: GroupInfo) external fun erase(communityInfo: GroupInfo)
external fun eraseCommunity(baseCommunityInfo: BaseCommunityInfo): Boolean external fun eraseCommunity(baseCommunityInfo: BaseCommunityInfo): Boolean
external fun eraseCommunity(server: String, room: String): 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 sizeCommunityInfo(): Int
external fun sizeLegacyGroupInfo(): Int external fun sizeLegacyGroupInfo(): Int
external fun size(): Int external fun size(): Int

View File

@ -6,7 +6,7 @@ sealed class Conversation {
abstract var unread: Boolean abstract var unread: Boolean
data class OneToOne( data class OneToOne(
val sessionId: String, val accountId: String,
override var lastRead: Long, override var lastRead: Long,
override var unread: Boolean override var unread: Boolean
): Conversation() ): Conversation()

View File

@ -5,7 +5,7 @@ sealed class GroupInfo {
data class CommunityGroupInfo(val community: BaseCommunityInfo, val priority: Int) : GroupInfo() data class CommunityGroupInfo(val community: BaseCommunityInfo, val priority: Int) : GroupInfo()
data class LegacyGroupInfo( data class LegacyGroupInfo(
val sessionId: String, val accountId: String,
val name: String, val name: String,
val members: Map<String, Boolean>, val members: Map<String, Boolean>,
val encPubKey: ByteArray, val encPubKey: ByteArray,
@ -25,7 +25,7 @@ sealed class GroupInfo {
other as LegacyGroupInfo other as LegacyGroupInfo
if (sessionId != other.sessionId) return false if (accountId != other.accountId) return false
if (name != other.name) return false if (name != other.name) return false
if (members != other.members) return false if (members != other.members) return false
if (!encPubKey.contentEquals(other.encPubKey)) return false if (!encPubKey.contentEquals(other.encPubKey)) return false
@ -38,7 +38,7 @@ sealed class GroupInfo {
} }
override fun hashCode(): Int { override fun hashCode(): Int {
var result = sessionId.hashCode() var result = accountId.hashCode()
result = 31 * result + name.hashCode() result = 31 * result + name.hashCode()
result = 31 * result + members.hashCode() result = 31 * result + members.hashCode()
result = 31 * result + encPubKey.contentHashCode() result = 31 * result + encPubKey.contentHashCode()

View File

@ -2,7 +2,7 @@ package org.session.libsession.messaging
data class BlindedIdMapping( data class BlindedIdMapping(
val blindedId: String, val blindedId: String,
val sessionId: String?, val accountId: String?,
val serverUrl: String, val serverUrl: String,
val serverId: String val serverId: String
) )

View File

@ -30,8 +30,8 @@ sealed class Endpoint(val value: String) {
data class RoomMessagesSince(val roomToken: String, val seqNo: Long) : data class RoomMessagesSince(val roomToken: String, val seqNo: Long) :
Endpoint("room/$roomToken/messages/since/$seqNo") Endpoint("room/$roomToken/messages/since/$seqNo")
data class RoomDeleteMessages(val roomToken: String, val sessionId: String) : data class RoomDeleteMessages(val roomToken: String, val accountId: String) :
Endpoint("room/$roomToken/all/$sessionId") Endpoint("room/$roomToken/all/$accountId")
data class Reactors(val roomToken: String, val messageId: Long, val emoji: String): data class Reactors(val roomToken: String, val messageId: Long, val emoji: String):
Endpoint("room/$roomToken/reactors/$messageId/$emoji") Endpoint("room/$roomToken/reactors/$messageId/$emoji")
@ -67,15 +67,15 @@ sealed class Endpoint(val value: String) {
object Inbox : Endpoint("inbox") object Inbox : Endpoint("inbox")
data class InboxSince(val id: Long) : Endpoint("inbox/since/$id") 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") object Outbox : Endpoint("outbox")
data class OutboxSince(val id: Long) : Endpoint("outbox/since/$id") data class OutboxSince(val id: Long) : Endpoint("outbox/since/$id")
// Users // Users
data class UserBan(val sessionId: String) : Endpoint("user/$sessionId/ban") data class UserBan(val accountId: String) : Endpoint("user/$accountId/ban")
data class UserUnban(val sessionId: String) : Endpoint("user/$sessionId/unban") data class UserUnban(val accountId: String) : Endpoint("user/$accountId/unban")
data class UserModerator(val sessionId: String) : Endpoint("user/$sessionId/moderator") data class UserModerator(val accountId: String) : Endpoint("user/$accountId/moderator")
} }

View File

@ -6,18 +6,13 @@ import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.PropertyNamingStrategy import com.fasterxml.jackson.databind.PropertyNamingStrategy
import com.fasterxml.jackson.databind.annotation.JsonNaming import com.fasterxml.jackson.databind.annotation.JsonNaming
import com.fasterxml.jackson.databind.type.TypeFactory 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.GenericHash
import com.goterl.lazysodium.interfaces.Sign import com.goterl.lazysodium.interfaces.Sign
import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableSharedFlow
import nl.komponents.kovenant.Promise import nl.komponents.kovenant.Promise
import nl.komponents.kovenant.functional.map import nl.komponents.kovenant.functional.map
import okhttp3.Headers
import okhttp3.Headers.Companion.toHeaders import okhttp3.Headers.Companion.toHeaders
import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody import okhttp3.RequestBody
import org.session.libsession.messaging.MessagingModuleConfiguration import org.session.libsession.messaging.MessagingModuleConfiguration
@ -203,7 +198,7 @@ object OpenGroupApi {
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class) @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
data class Message( data class Message(
val id : Long = 0, val id : Long = 0,
val sessionId: String = "", val accountId: String = "",
val posted: Double = 0.0, val posted: Double = 0.0,
val edited: Long = 0, val edited: Long = 0,
val seqno: Long = 0, val seqno: Long = 0,

View File

@ -13,9 +13,9 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class SubscriptionRequest( 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, 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?, val session_ed25519: String?,
/** 32-byte swarm authentication subkey; omitted (or null) when not using subkey auth (new closed groups) */ /** 32-byte swarm authentication subkey; omitted (or null) when not using subkey auth (new closed groups) */
val subkey_tag: String? = null, val subkey_tag: String? = null,
@ -38,9 +38,9 @@ data class SubscriptionRequest(
@Serializable @Serializable
data class UnsubscriptionRequest( 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, 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?, val session_ed25519: String?,
/** 32-byte swarm authentication subkey; omitted (or null) when not using subkey auth (new closed groups) */ /** 32-byte swarm authentication subkey; omitted (or null) when not using subkey auth (new closed groups) */
val subkey_tag: String? = null, val subkey_tag: String? = null,

View File

@ -222,7 +222,7 @@ class OpenGroupPoller(private val server: String, private val executorService: S
handleNewMessages(server, roomToken, additions.map { handleNewMessages(server, roomToken, additions.map {
OpenGroupMessage( OpenGroupMessage(
serverID = it.id, serverID = it.id,
sender = it.sessionId, sender = it.accountId,
sentTimestamp = (it.posted * 1000).toLong(), sentTimestamp = (it.posted * 1000).toLong(),
base64EncodedData = it.data, base64EncodedData = it.data,
base64EncodedSignature = it.signature, base64EncodedSignature = it.signature,
@ -272,7 +272,7 @@ class OpenGroupPoller(private val server: String, private val executorService: S
serverPublicKey, serverPublicKey,
true true
) )
val syncTarget = mapping.sessionId ?: it.recipient val syncTarget = mapping.accountId ?: it.recipient
if (message is VisibleMessage) { if (message is VisibleMessage) {
message.syncTarget = syncTarget message.syncTarget = syncTarget
} else if (message is ExpirationTimerUpdate) { } else if (message is ExpirationTimerUpdate) {

View File

@ -159,22 +159,22 @@ object SodiumUtilities {
} else null } else null
} }
/* This method should be used to check if a users standard sessionId matches a blinded one */ /* This method should be used to check if a users standard accountId matches a blinded one */
fun sessionId( fun accountId(
standardAccountId: String, standardAccountId: String,
blindedAccountId: String, blindedAccountId: String,
serverPublicKey: String serverPublicKey: String
): Boolean { ): Boolean {
// Only support generating blinded keys for standard session ids // Only support generating blinded keys for standard account ids
val sessionId = AccountId(standardAccountId) val accountId = AccountId(standardAccountId)
if (sessionId.prefix != IdPrefix.STANDARD) return false if (accountId.prefix != IdPrefix.STANDARD) return false
val blindedId = AccountId(blindedAccountId) val blindedId = AccountId(blindedAccountId)
if (blindedId.prefix != IdPrefix.BLINDED) return false if (blindedId.prefix != IdPrefix.BLINDED) return false
val k = generateBlindingFactor(serverPublicKey) ?: 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) // 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 // Blind the positive public key
val pk1 = combineKeys(k, xEd25519Key) ?: return false val pk1 = combineKeys(k, xEd25519Key) ?: return false

View File

@ -17,9 +17,9 @@ object GroupUtil {
} }
@JvmStatic @JvmStatic
fun getEncodedOpenGroupInboxID(openGroup: OpenGroup, sessionId: AccountId): Address { fun getEncodedOpenGroupInboxID(openGroup: OpenGroup, accountId: AccountId): Address {
val openGroupInboxId = val openGroupInboxId =
"${openGroup.server}!${openGroup.publicKey}!${sessionId.hexString}".toByteArray() "${openGroup.server}!${openGroup.publicKey}!${accountId.hexString}".toByteArray()
return getEncodedOpenGroupInboxID(openGroupInboxId) return getEncodedOpenGroupInboxID(openGroupInboxId)
} }

View File

@ -511,11 +511,11 @@ public class Recipient implements RecipientModifiedListener {
public synchronized String toShortString() { public synchronized String toShortString() {
String name = getName(); String name = getName();
if (name != null) return name; if (name != null) return name;
String sessionId = address.serialize(); String accountId = address.serialize();
if (sessionId.length() < 4) return sessionId; // so substrings don't throw out of bounds exceptions if (accountId.length() < 4) return accountId; // so substrings don't throw out of bounds exceptions
int takeAmount = 4; int takeAmount = 4;
String start = sessionId.substring(0, takeAmount); String start = accountId.substring(0, takeAmount);
String end = sessionId.substring(sessionId.length()-takeAmount); String end = accountId.substring(accountId.length()-takeAmount);
return start+"..."+end; return start+"..."+end;
} }