From b3e1b0603d2a99cfe7414d980ee6a3b89fa22aee Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 25 Nov 2024 14:25:16 -0800 Subject: [PATCH] rename consent list entry to consent record (#338) --- .../xmtp/android/library/ConversationsTest.kt | 4 ++-- .../java/org/xmtp/android/library/DmTest.kt | 4 ++-- .../org/xmtp/android/library/GroupTest.kt | 8 +++---- .../library/SmartContractWalletTest.kt | 8 +++---- .../android/library/PrivatePreferences.kt | 24 +++++++++---------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/library/src/androidTest/java/org/xmtp/android/library/ConversationsTest.kt b/library/src/androidTest/java/org/xmtp/android/library/ConversationsTest.kt index fabc31b1c..80c8d0f04 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/ConversationsTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/ConversationsTest.kt @@ -220,7 +220,7 @@ class ConversationsTest { assertEquals(ConsentState.DENIED, dm2.consentState()) alixClient2.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( dm2.id, EntryType.CONVERSATION_ID, ConsentState.ALLOWED @@ -272,7 +272,7 @@ class ConversationsTest { alixClient2.conversations.syncAllConversations() } val alix2Group = alixClient2.findGroup(alixGroup.id)!! - val consent = mutableListOf() + val consent = mutableListOf() val job = CoroutineScope(Dispatchers.IO).launch { try { alixClient.preferences.streamConsent() diff --git a/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt b/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt index 8a541ff1f..d1e51dd8e 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/DmTest.kt @@ -338,7 +338,7 @@ class DmTest { boClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( dm.id, EntryType.CONVERSATION_ID, ConsentState.DENIED @@ -353,7 +353,7 @@ class DmTest { boClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( dm.id, EntryType.CONVERSATION_ID, ConsentState.ALLOWED diff --git a/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt b/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt index 95ae9a273..e521d7b0c 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt @@ -738,7 +738,7 @@ class GroupTest { boClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( group.id, EntryType.CONVERSATION_ID, ConsentState.DENIED @@ -770,7 +770,7 @@ class GroupTest { ) boClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( alixClient.inboxId, EntryType.INBOX_ID, ConsentState.ALLOWED @@ -787,7 +787,7 @@ class GroupTest { boClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( alixClient.inboxId, EntryType.INBOX_ID, ConsentState.DENIED @@ -804,7 +804,7 @@ class GroupTest { boClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( alixClient.address, EntryType.ADDRESS, ConsentState.ALLOWED diff --git a/library/src/androidTest/java/org/xmtp/android/library/SmartContractWalletTest.kt b/library/src/androidTest/java/org/xmtp/android/library/SmartContractWalletTest.kt index b2bf9538c..821799fbb 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/SmartContractWalletTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/SmartContractWalletTest.kt @@ -219,7 +219,7 @@ class SmartContractWalletTest { davonSCWClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( davonGroup.id, EntryType.CONVERSATION_ID, ConsentState.DENIED @@ -258,7 +258,7 @@ class SmartContractWalletTest { ) davonSCWClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( boEOAClient.inboxId, EntryType.INBOX_ID, ConsentState.ALLOWED @@ -275,7 +275,7 @@ class SmartContractWalletTest { davonSCWClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( boEOAClient.inboxId, EntryType.INBOX_ID, ConsentState.DENIED @@ -292,7 +292,7 @@ class SmartContractWalletTest { davonSCWClient.preferences.setConsentState( listOf( - ConsentListEntry( + ConsentRecord( eriSCWClient.address, EntryType.ADDRESS, ConsentState.ALLOWED diff --git a/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt b/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt index ad01e0b09..ec39b334c 100644 --- a/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt +++ b/library/src/main/java/org/xmtp/android/library/PrivatePreferences.kt @@ -60,7 +60,7 @@ enum class EntryType { } } -data class ConsentListEntry( +data class ConsentRecord( val value: String, val entryType: EntryType, val consentType: ConsentState, @@ -69,22 +69,22 @@ data class ConsentListEntry( fun address( address: String, type: ConsentState = ConsentState.UNKNOWN, - ): ConsentListEntry { - return ConsentListEntry(address, EntryType.ADDRESS, type) + ): ConsentRecord { + return ConsentRecord(address, EntryType.ADDRESS, type) } fun conversationId( groupId: String, type: ConsentState = ConsentState.UNKNOWN, - ): ConsentListEntry { - return ConsentListEntry(groupId, EntryType.CONVERSATION_ID, type) + ): ConsentRecord { + return ConsentRecord(groupId, EntryType.CONVERSATION_ID, type) } fun inboxId( inboxId: String, type: ConsentState = ConsentState.UNKNOWN, - ): ConsentListEntry { - return ConsentListEntry(inboxId, EntryType.INBOX_ID, type) + ): ConsentRecord { + return ConsentRecord(inboxId, EntryType.INBOX_ID, type) } } @@ -100,7 +100,7 @@ data class PrivatePreferences( ffiClient.sendSyncRequest(FfiDeviceSyncKind.CONSENT) } - suspend fun streamConsent(): Flow = callbackFlow { + suspend fun streamConsent(): Flow = callbackFlow { val consentCallback = object : FfiConsentCallback { override fun onConsentUpdate(consent: List) { consent.iterator().forEach { @@ -118,11 +118,11 @@ data class PrivatePreferences( awaitClose { stream.end() } } - suspend fun setConsentState(entries: List) { + suspend fun setConsentState(entries: List) { ffiClient.setConsentStates(entries.map { it.toFfiConsent() }) } - private fun ConsentListEntry.toFfiConsent(): FfiConsent { + private fun ConsentRecord.toFfiConsent(): FfiConsent { return FfiConsent( EntryType.toFfiConsentEntityType(entryType), ConsentState.toFfiConsentState(consentType), @@ -130,8 +130,8 @@ data class PrivatePreferences( ) } - private fun FfiConsent.fromFfiConsent(): ConsentListEntry { - return ConsentListEntry( + private fun FfiConsent.fromFfiConsent(): ConsentRecord { + return ConsentRecord( entity, EntryType.fromFfiConsentEntityType(entityType), ConsentState.fromFfiConsentState(state),