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

@@ -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
)

View File

@@ -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")
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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;
}