Skip to content

Commit

Permalink
make the consent list return an entry
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 7, 2023
1 parent 335711e commit e245081
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions library/src/main/java/org/xmtp/android/library/Contacts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ data class ConsentListEntry(
}

class ConsentList(val client: Client) {
val entries: MutableMap<String, ConsentState> = mutableMapOf()
val entries: MutableMap<String, ConsentListEntry> = mutableMapOf()
private val publicKey =
client.privateKeyBundleV1.identityKey.publicKey.secp256K1Uncompressed.bytes
private val privateKey = client.privateKeyBundleV1.identityKey.secp256K1.bytes
Expand Down Expand Up @@ -117,21 +117,23 @@ class ConsentList(val client: Client) {
}

fun allow(address: String): ConsentListEntry {
entries[ConsentListEntry.address(address).key] = ConsentState.ALLOWED
val entry = ConsentListEntry.address(address, ConsentState.ALLOWED)
entries[ConsentListEntry.address(address).key] = entry

return ConsentListEntry.address(address, ConsentState.ALLOWED)
return entry
}

fun deny(address: String): ConsentListEntry {
entries[ConsentListEntry.address(address).key] = ConsentState.DENIED
val entry = ConsentListEntry.address(address, ConsentState.DENIED)
entries[ConsentListEntry.address(address).key] = entry

return ConsentListEntry.address(address, ConsentState.DENIED)
return entry
}

fun state(address: String): ConsentState {
val state = entries[ConsentListEntry.address(address).key]
val entry = entries[ConsentListEntry.address(address).key]

return state ?: ConsentState.UNKNOWN
return entry?.consentType ?: ConsentState.UNKNOWN
}
}

Expand Down

0 comments on commit e245081

Please sign in to comment.