mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-12 03:07:42 +00:00
Rename remaining session id refs
This commit is contained in:
@@ -2,7 +2,7 @@ package org.session.libsession.messaging
|
||||
|
||||
data class BlindedIdMapping(
|
||||
val blindedId: String,
|
||||
val sessionId: String?,
|
||||
val accountId: String?,
|
||||
val serverUrl: String,
|
||||
val serverId: String
|
||||
)
|
@@ -30,8 +30,8 @@ sealed class Endpoint(val value: String) {
|
||||
data class RoomMessagesSince(val roomToken: String, val seqNo: Long) :
|
||||
Endpoint("room/$roomToken/messages/since/$seqNo")
|
||||
|
||||
data class RoomDeleteMessages(val roomToken: String, val sessionId: String) :
|
||||
Endpoint("room/$roomToken/all/$sessionId")
|
||||
data class RoomDeleteMessages(val roomToken: String, val accountId: String) :
|
||||
Endpoint("room/$roomToken/all/$accountId")
|
||||
|
||||
data class Reactors(val roomToken: String, val messageId: Long, val emoji: String):
|
||||
Endpoint("room/$roomToken/reactors/$messageId/$emoji")
|
||||
@@ -67,15 +67,15 @@ sealed class Endpoint(val value: String) {
|
||||
|
||||
object Inbox : Endpoint("inbox")
|
||||
data class InboxSince(val id: Long) : Endpoint("inbox/since/$id")
|
||||
data class InboxFor(val sessionId: String) : Endpoint("inbox/$sessionId")
|
||||
data class InboxFor(val accountId: String) : Endpoint("inbox/$accountId")
|
||||
|
||||
object Outbox : Endpoint("outbox")
|
||||
data class OutboxSince(val id: Long) : Endpoint("outbox/since/$id")
|
||||
|
||||
// Users
|
||||
|
||||
data class UserBan(val sessionId: String) : Endpoint("user/$sessionId/ban")
|
||||
data class UserUnban(val sessionId: String) : Endpoint("user/$sessionId/unban")
|
||||
data class UserModerator(val sessionId: String) : Endpoint("user/$sessionId/moderator")
|
||||
data class UserBan(val accountId: String) : Endpoint("user/$accountId/ban")
|
||||
data class UserUnban(val accountId: String) : Endpoint("user/$accountId/unban")
|
||||
data class UserModerator(val accountId: String) : Endpoint("user/$accountId/moderator")
|
||||
|
||||
}
|
||||
|
@@ -6,18 +6,13 @@ import com.fasterxml.jackson.core.type.TypeReference
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory
|
||||
import com.goterl.lazysodium.LazySodiumAndroid
|
||||
import com.goterl.lazysodium.SodiumAndroid
|
||||
import com.goterl.lazysodium.interfaces.GenericHash
|
||||
import com.goterl.lazysodium.interfaces.Sign
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import nl.komponents.kovenant.Promise
|
||||
import nl.komponents.kovenant.functional.map
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Headers.Companion.toHeaders
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.RequestBody
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
@@ -203,7 +198,7 @@ object OpenGroupApi {
|
||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
||||
data class Message(
|
||||
val id : Long = 0,
|
||||
val sessionId: String = "",
|
||||
val accountId: String = "",
|
||||
val posted: Double = 0.0,
|
||||
val edited: Long = 0,
|
||||
val seqno: Long = 0,
|
||||
|
@@ -13,9 +13,9 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class SubscriptionRequest(
|
||||
/** the 33-byte account being subscribed to; typically a session ID */
|
||||
/** the 33-byte account being subscribed to; typically an account ID */
|
||||
val pubkey: String,
|
||||
/** when the pubkey starts with 05 (i.e. a session ID) this is the ed25519 32-byte pubkey associated with the session ID */
|
||||
/** when the pubkey starts with 05 (i.e. an account ID) this is the ed25519 32-byte pubkey associated with the account ID */
|
||||
val session_ed25519: String?,
|
||||
/** 32-byte swarm authentication subkey; omitted (or null) when not using subkey auth (new closed groups) */
|
||||
val subkey_tag: String? = null,
|
||||
@@ -38,9 +38,9 @@ data class SubscriptionRequest(
|
||||
|
||||
@Serializable
|
||||
data class UnsubscriptionRequest(
|
||||
/** the 33-byte account being subscribed to; typically a session ID */
|
||||
/** the 33-byte account being subscribed to; typically a account ID */
|
||||
val pubkey: String,
|
||||
/** when the pubkey starts with 05 (i.e. a session ID) this is the ed25519 32-byte pubkey associated with the session ID */
|
||||
/** when the pubkey starts with 05 (i.e. an account ID) this is the ed25519 32-byte pubkey associated with the account ID */
|
||||
val session_ed25519: String?,
|
||||
/** 32-byte swarm authentication subkey; omitted (or null) when not using subkey auth (new closed groups) */
|
||||
val subkey_tag: String? = null,
|
||||
|
@@ -222,7 +222,7 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
||||
handleNewMessages(server, roomToken, additions.map {
|
||||
OpenGroupMessage(
|
||||
serverID = it.id,
|
||||
sender = it.sessionId,
|
||||
sender = it.accountId,
|
||||
sentTimestamp = (it.posted * 1000).toLong(),
|
||||
base64EncodedData = it.data,
|
||||
base64EncodedSignature = it.signature,
|
||||
@@ -272,7 +272,7 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
||||
serverPublicKey,
|
||||
true
|
||||
)
|
||||
val syncTarget = mapping.sessionId ?: it.recipient
|
||||
val syncTarget = mapping.accountId ?: it.recipient
|
||||
if (message is VisibleMessage) {
|
||||
message.syncTarget = syncTarget
|
||||
} else if (message is ExpirationTimerUpdate) {
|
||||
|
@@ -159,22 +159,22 @@ object SodiumUtilities {
|
||||
} else null
|
||||
}
|
||||
|
||||
/* This method should be used to check if a users standard sessionId matches a blinded one */
|
||||
fun sessionId(
|
||||
/* This method should be used to check if a users standard accountId matches a blinded one */
|
||||
fun accountId(
|
||||
standardAccountId: String,
|
||||
blindedAccountId: String,
|
||||
serverPublicKey: String
|
||||
): Boolean {
|
||||
// Only support generating blinded keys for standard session ids
|
||||
val sessionId = AccountId(standardAccountId)
|
||||
if (sessionId.prefix != IdPrefix.STANDARD) return false
|
||||
// Only support generating blinded keys for standard account ids
|
||||
val accountId = AccountId(standardAccountId)
|
||||
if (accountId.prefix != IdPrefix.STANDARD) return false
|
||||
val blindedId = AccountId(blindedAccountId)
|
||||
if (blindedId.prefix != IdPrefix.BLINDED) return false
|
||||
val k = generateBlindingFactor(serverPublicKey) ?: return false
|
||||
|
||||
// From the session id (ignoring 05 prefix) we have two possible ed25519 pubkeys;
|
||||
// From the account id (ignoring 05 prefix) we have two possible ed25519 pubkeys;
|
||||
// the first is the positive (which is what Signal's XEd25519 conversion always uses)
|
||||
val xEd25519Key = curve.convertToEd25519PublicKey(Key.fromHexString(sessionId.publicKey).asBytes)
|
||||
val xEd25519Key = curve.convertToEd25519PublicKey(Key.fromHexString(accountId.publicKey).asBytes)
|
||||
|
||||
// Blind the positive public key
|
||||
val pk1 = combineKeys(k, xEd25519Key) ?: return false
|
||||
|
@@ -17,9 +17,9 @@ object GroupUtil {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getEncodedOpenGroupInboxID(openGroup: OpenGroup, sessionId: AccountId): Address {
|
||||
fun getEncodedOpenGroupInboxID(openGroup: OpenGroup, accountId: AccountId): Address {
|
||||
val openGroupInboxId =
|
||||
"${openGroup.server}!${openGroup.publicKey}!${sessionId.hexString}".toByteArray()
|
||||
"${openGroup.server}!${openGroup.publicKey}!${accountId.hexString}".toByteArray()
|
||||
return getEncodedOpenGroupInboxID(openGroupInboxId)
|
||||
}
|
||||
|
||||
|
@@ -511,11 +511,11 @@ public class Recipient implements RecipientModifiedListener {
|
||||
public synchronized String toShortString() {
|
||||
String name = getName();
|
||||
if (name != null) return name;
|
||||
String sessionId = address.serialize();
|
||||
if (sessionId.length() < 4) return sessionId; // so substrings don't throw out of bounds exceptions
|
||||
String accountId = address.serialize();
|
||||
if (accountId.length() < 4) return accountId; // so substrings don't throw out of bounds exceptions
|
||||
int takeAmount = 4;
|
||||
String start = sessionId.substring(0, takeAmount);
|
||||
String end = sessionId.substring(sessionId.length()-takeAmount);
|
||||
String start = accountId.substring(0, takeAmount);
|
||||
String end = accountId.substring(accountId.length()-takeAmount);
|
||||
return start+"..."+end;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user