mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 22:53:11 +02:00
Migrates the pubkeyHex from keypair to the signer.
This commit is contained in:
@@ -431,7 +431,7 @@ class Account(
|
|||||||
emit(
|
emit(
|
||||||
LiveFollowLists(
|
LiveFollowLists(
|
||||||
verifiedFollowingUsers,
|
verifiedFollowingUsers,
|
||||||
verifiedFollowingUsers + keyPair.pubKeyHex,
|
verifiedFollowingUsers + signer.pubKey,
|
||||||
it.user.latestContactList
|
it.user.latestContactList
|
||||||
?.unverifiedFollowTagSet()
|
?.unverifiedFollowTagSet()
|
||||||
?.map { it.lowercase() }
|
?.map { it.lowercase() }
|
||||||
@@ -446,7 +446,7 @@ class Account(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val liveKind3Follows = liveKind3FollowsFlow.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex)))
|
val liveKind3Follows = liveKind3FollowsFlow.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey)))
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
private val liveHomeList: Flow<ListNameNotePair> =
|
private val liveHomeList: Flow<ListNameNotePair> =
|
||||||
@@ -477,11 +477,11 @@ class Account(
|
|||||||
} else if (peopleListFollows.listName == KIND3_FOLLOWS) {
|
} else if (peopleListFollows.listName == KIND3_FOLLOWS) {
|
||||||
emit(kind3Follows)
|
emit(kind3Follows)
|
||||||
} else if (peopleListFollows.event == null) {
|
} else if (peopleListFollows.event == null) {
|
||||||
emit(LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex)))
|
emit(LiveFollowLists(usersPlusMe = setOf(signer.pubKey)))
|
||||||
} else {
|
} else {
|
||||||
val result = waitToDecrypt(peopleListFollows.event)
|
val result = waitToDecrypt(peopleListFollows.event)
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
emit(LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex)))
|
emit(LiveFollowLists(usersPlusMe = setOf(signer.pubKey)))
|
||||||
} else {
|
} else {
|
||||||
emit(result)
|
emit(result)
|
||||||
}
|
}
|
||||||
@@ -493,7 +493,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val liveHomeFollowLists: StateFlow<LiveFollowLists?> by lazy {
|
val liveHomeFollowLists: StateFlow<LiveFollowLists?> by lazy {
|
||||||
liveHomeFollowListFlow.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex)))
|
liveHomeFollowListFlow.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -605,7 +605,7 @@ class Account(
|
|||||||
|
|
||||||
val liveNotificationFollowLists: StateFlow<LiveFollowLists?> by lazy {
|
val liveNotificationFollowLists: StateFlow<LiveFollowLists?> by lazy {
|
||||||
combinePeopleListFlows(liveKind3FollowsFlow, liveNotificationList)
|
combinePeopleListFlows(liveKind3FollowsFlow, liveNotificationList)
|
||||||
.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex)))
|
.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@@ -617,7 +617,7 @@ class Account(
|
|||||||
|
|
||||||
val liveStoriesFollowLists: StateFlow<LiveFollowLists?> by lazy {
|
val liveStoriesFollowLists: StateFlow<LiveFollowLists?> by lazy {
|
||||||
combinePeopleListFlows(liveKind3FollowsFlow, liveStoriesList)
|
combinePeopleListFlows(liveKind3FollowsFlow, liveStoriesList)
|
||||||
.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex)))
|
.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@@ -654,7 +654,7 @@ class Account(
|
|||||||
|
|
||||||
val liveDiscoveryFollowLists: StateFlow<LiveFollowLists?> by lazy {
|
val liveDiscoveryFollowLists: StateFlow<LiveFollowLists?> by lazy {
|
||||||
combinePeopleListFlows(liveKind3FollowsFlow, liveDiscoveryList)
|
combinePeopleListFlows(liveKind3FollowsFlow, liveDiscoveryList)
|
||||||
.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex)))
|
.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(signer.pubKey)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@@ -877,7 +877,7 @@ class Account(
|
|||||||
|
|
||||||
suspend fun countFollowersOf(pubkey: HexKey): Int = LocalCache.users.count { _, it -> it.latestContactList?.isTaggedUser(pubkey) ?: false }
|
suspend fun countFollowersOf(pubkey: HexKey): Int = LocalCache.users.count { _, it -> it.latestContactList?.isTaggedUser(pubkey) ?: false }
|
||||||
|
|
||||||
suspend fun followerCount(): Int = countFollowersOf(keyPair.pubKeyHex)
|
suspend fun followerCount(): Int = countFollowersOf(signer.pubKey)
|
||||||
|
|
||||||
fun sendNewUserMetadata(
|
fun sendNewUserMetadata(
|
||||||
name: String? = null,
|
name: String? = null,
|
||||||
@@ -3175,7 +3175,7 @@ class Account(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getAllPeopleLists(): List<AddressableNote> = getAllPeopleLists(keyPair.pubKeyHex)
|
fun getAllPeopleLists(): List<AddressableNote> = getAllPeopleLists(signer.pubKey)
|
||||||
|
|
||||||
fun getAllPeopleLists(pubkey: HexKey): List<AddressableNote> =
|
fun getAllPeopleLists(pubkey: HexKey): List<AddressableNote> =
|
||||||
LocalCache.addressables
|
LocalCache.addressables
|
||||||
|
@@ -804,7 +804,9 @@ class AccountViewModel(
|
|||||||
viewModelScope.launch(Dispatchers.IO) { account.hideWord(word) }
|
viewModelScope.launch(Dispatchers.IO) { account.hideWord(word) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isLoggedUser(user: User?): Boolean = account.userProfile().pubkeyHex == user?.pubkeyHex
|
fun isLoggedUser(pubkeyHex: HexKey?): Boolean = account.signer.pubKey == pubkeyHex
|
||||||
|
|
||||||
|
fun isLoggedUser(user: User?): Boolean = isLoggedUser(user?.pubkeyHex)
|
||||||
|
|
||||||
fun isFollowing(user: User?): Boolean {
|
fun isFollowing(user: User?): Boolean {
|
||||||
if (user == null) return false
|
if (user == null) return false
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.quartz.crypto
|
package com.vitorpamplona.quartz.crypto
|
||||||
|
|
||||||
import com.vitorpamplona.quartz.encoders.HexKey
|
|
||||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||||
|
|
||||||
class KeyPair(
|
class KeyPair(
|
||||||
@@ -30,7 +29,6 @@ class KeyPair(
|
|||||||
) {
|
) {
|
||||||
val privKey: ByteArray?
|
val privKey: ByteArray?
|
||||||
val pubKey: ByteArray
|
val pubKey: ByteArray
|
||||||
val pubKeyHex: HexKey
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (privKey == null) {
|
if (privKey == null) {
|
||||||
@@ -54,8 +52,6 @@ class KeyPair(
|
|||||||
this.pubKey = pubKey
|
this.pubKey = pubKey
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pubKeyHex = this.pubKey.toHexKey().intern()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String = "KeyPair(privateKey=${privKey?.toHexKey()}, publicKey=${pubKey.toHexKey()}"
|
override fun toString(): String = "KeyPair(privateKey=${privKey?.toHexKey()}, publicKey=${pubKey.toHexKey()}"
|
||||||
|
Reference in New Issue
Block a user