File tree 2 files changed +17
-3
lines changed
androidTest/java/org/xmtp/android/library
main/java/org/xmtp/android/library
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -723,6 +723,12 @@ class ConversationTest {
723
723
assertTrue(isAllowed)
724
724
assertTrue(bobClient.contacts.isAllowed(alice.walletAddress))
725
725
726
+ bobClient.contacts.block(listOf (alice.walletAddress))
727
+ bobClient.contacts.refreshConsentList()
728
+
729
+ val isBlocked = bobConversation.consentState() == ConsentState .BLOCKED
730
+ assertTrue(isBlocked)
731
+
726
732
val aliceConversation = aliceClient.conversations.list()[0 ]
727
733
val isUnknown = aliceConversation.consentState() == ConsentState .UNKNOWN
728
734
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ enum class ConsentState {
14
14
BLOCKED ,
15
15
UNKNOWN
16
16
}
17
+
17
18
data class ConsentListEntry (
18
19
val value : String ,
19
20
val entryType : EntryType ,
@@ -67,23 +68,30 @@ class ConsentList(val client: Client) {
67
68
)
68
69
}
69
70
70
- preferences.iterator().forEach { preference ->
71
+ preferences.reversed(). iterator().forEach { preference ->
71
72
preference.allow?.walletAddressesList?.forEach { address ->
72
73
consentList.allow(address)
73
74
}
74
75
preference.block?.walletAddressesList?.forEach { address ->
75
76
consentList.block(address)
76
77
}
77
78
}
79
+
78
80
return consentList
79
81
}
80
82
81
83
@OptIn(ExperimentalUnsignedTypes ::class )
82
84
fun publish (entry : ConsentListEntry ) {
83
85
val payload = PrivatePreferencesAction .newBuilder().also {
84
86
when (entry.consentType) {
85
- ConsentState .ALLOWED -> it.setAllow(PrivatePreferencesAction .Allow .newBuilder().addWalletAddresses(entry.value))
86
- ConsentState .BLOCKED -> it.setBlock(PrivatePreferencesAction .Block .newBuilder().addWalletAddresses(entry.value))
87
+ ConsentState .ALLOWED -> it.setAllow(
88
+ PrivatePreferencesAction .Allow .newBuilder().addWalletAddresses(entry.value)
89
+ )
90
+
91
+ ConsentState .BLOCKED -> it.setBlock(
92
+ PrivatePreferencesAction .Block .newBuilder().addWalletAddresses(entry.value)
93
+ )
94
+
87
95
ConsentState .UNKNOWN -> it.clearMessageType()
88
96
}
89
97
}.build()
You can’t perform that action at this time.
0 commit comments