Skip to content

Commit

Permalink
rename consent list entry to consent record
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 25, 2024
1 parent da59bca commit abef2f4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class ConversationsTest {
assertEquals(ConsentState.DENIED, dm2.consentState())
alixClient2.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
dm2.id,
EntryType.CONVERSATION_ID,
ConsentState.ALLOWED
Expand Down Expand Up @@ -272,7 +272,7 @@ class ConversationsTest {
alixClient2.conversations.syncAllConversations()
}
val alix2Group = alixClient2.findGroup(alixGroup.id)!!
val consent = mutableListOf<ConsentListEntry>()
val consent = mutableListOf<ConsentRecord>()
val job = CoroutineScope(Dispatchers.IO).launch {
try {
alixClient.preferences.streamConsent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class DmTest {

boClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
dm.id,
EntryType.CONVERSATION_ID,
ConsentState.DENIED
Expand All @@ -353,7 +353,7 @@ class DmTest {

boClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
dm.id,
EntryType.CONVERSATION_ID,
ConsentState.ALLOWED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ class GroupTest {

boClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
group.id,
EntryType.CONVERSATION_ID,
ConsentState.DENIED
Expand Down Expand Up @@ -770,7 +770,7 @@ class GroupTest {
)
boClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
alixClient.inboxId,
EntryType.INBOX_ID,
ConsentState.ALLOWED
Expand All @@ -787,7 +787,7 @@ class GroupTest {

boClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
alixClient.inboxId,
EntryType.INBOX_ID,
ConsentState.DENIED
Expand All @@ -804,7 +804,7 @@ class GroupTest {

boClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
alixClient.address,
EntryType.ADDRESS,
ConsentState.ALLOWED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class SmartContractWalletTest {

davonSCWClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
davonGroup.id,
EntryType.CONVERSATION_ID,
ConsentState.DENIED
Expand Down Expand Up @@ -258,7 +258,7 @@ class SmartContractWalletTest {
)
davonSCWClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
boEOAClient.inboxId,
EntryType.INBOX_ID,
ConsentState.ALLOWED
Expand All @@ -275,7 +275,7 @@ class SmartContractWalletTest {

davonSCWClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
boEOAClient.inboxId,
EntryType.INBOX_ID,
ConsentState.DENIED
Expand All @@ -292,7 +292,7 @@ class SmartContractWalletTest {

davonSCWClient.preferences.setConsentState(
listOf(
ConsentListEntry(
ConsentRecord(
eriSCWClient.address,
EntryType.ADDRESS,
ConsentState.ALLOWED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ enum class EntryType {
}
}

data class ConsentListEntry(
data class ConsentRecord(
val value: String,
val entryType: EntryType,
val consentType: ConsentState,
Expand All @@ -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)
}
}

Expand All @@ -100,7 +100,7 @@ data class PrivatePreferences(
ffiClient.sendSyncRequest(FfiDeviceSyncKind.CONSENT)
}

suspend fun streamConsent(): Flow<ConsentListEntry> = callbackFlow {
suspend fun streamConsent(): Flow<ConsentRecord> = callbackFlow {
val consentCallback = object : FfiConsentCallback {
override fun onConsentUpdate(consent: List<FfiConsent>) {
consent.iterator().forEach {
Expand All @@ -118,20 +118,20 @@ data class PrivatePreferences(
awaitClose { stream.end() }
}

suspend fun setConsentState(entries: List<ConsentListEntry>) {
suspend fun setConsentState(entries: List<ConsentRecord>) {
ffiClient.setConsentStates(entries.map { it.toFfiConsent() })
}

private fun ConsentListEntry.toFfiConsent(): FfiConsent {
private fun ConsentRecord.toFfiConsent(): FfiConsent {
return FfiConsent(
EntryType.toFfiConsentEntityType(entryType),
ConsentState.toFfiConsentState(consentType),
value
)
}

private fun FfiConsent.fromFfiConsent(): ConsentListEntry {
return ConsentListEntry(
private fun FfiConsent.fromFfiConsent(): ConsentRecord {
return ConsentRecord(
entity,
EntryType.fromFfiConsentEntityType(entityType),
ConsentState.fromFfiConsentState(state),
Expand Down

0 comments on commit abef2f4

Please sign in to comment.