@@ -109,63 +109,62 @@ class ConsentList(
109
109
}
110
110
111
111
suspend fun publish (entries : List <ConsentListEntry >) {
112
- val envelopes = entries.map { entry ->
113
- val payload =
114
- PrivatePreferencesAction .newBuilder().also {
115
- when (entry.entryType) {
116
- ConsentListEntry .EntryType .ADDRESS -> {
117
- when (entry.consentType) {
118
- ConsentState .ALLOWED ->
119
- it.setAllowAddress(
120
- PrivatePreferencesAction .AllowAddress .newBuilder()
121
- .addWalletAddresses(entry.value),
122
- )
123
-
124
- ConsentState .DENIED ->
125
- it.setDenyAddress(
126
- PrivatePreferencesAction .DenyAddress .newBuilder()
127
- .addWalletAddresses(entry.value),
128
- )
129
-
130
- ConsentState .UNKNOWN -> it.clearMessageType()
131
- }
112
+ val payload = PrivatePreferencesAction .newBuilder().also {
113
+ entries.forEach { entry ->
114
+ when (entry.entryType) {
115
+ ConsentListEntry .EntryType .ADDRESS -> {
116
+ when (entry.consentType) {
117
+ ConsentState .ALLOWED ->
118
+ it.setAllowAddress(
119
+ PrivatePreferencesAction .AllowAddress .newBuilder()
120
+ .addWalletAddresses(entry.value),
121
+ )
122
+
123
+ ConsentState .DENIED ->
124
+ it.setDenyAddress(
125
+ PrivatePreferencesAction .DenyAddress .newBuilder()
126
+ .addWalletAddresses(entry.value),
127
+ )
128
+
129
+ ConsentState .UNKNOWN -> it.clearMessageType()
132
130
}
131
+ }
133
132
134
- ConsentListEntry .EntryType .GROUP_ID -> {
135
- when (entry.consentType) {
136
- ConsentState .ALLOWED ->
137
- it.setAllowGroup(
138
- PrivatePreferencesAction .AllowGroup .newBuilder()
139
- .addGroupIds(entry.value.toByteStringUtf8()),
140
- )
141
-
142
- ConsentState .DENIED ->
143
- it.setDenyGroup(
144
- PrivatePreferencesAction .DenyGroup .newBuilder()
145
- .addGroupIds(entry.value.toByteStringUtf8()),
146
- )
147
-
148
- ConsentState .UNKNOWN -> it.clearMessageType()
149
- }
133
+ ConsentListEntry .EntryType .GROUP_ID -> {
134
+ when (entry.consentType) {
135
+ ConsentState .ALLOWED ->
136
+ it.setAllowGroup(
137
+ PrivatePreferencesAction .AllowGroup .newBuilder()
138
+ .addGroupIds(entry.value.toByteStringUtf8()),
139
+ )
140
+
141
+ ConsentState .DENIED ->
142
+ it.setDenyGroup(
143
+ PrivatePreferencesAction .DenyGroup .newBuilder()
144
+ .addGroupIds(entry.value.toByteStringUtf8()),
145
+ )
146
+
147
+ ConsentState .UNKNOWN -> it.clearMessageType()
150
148
}
151
149
}
152
- }.build()
153
-
154
- val message =
155
- uniffi.xmtpv3.userPreferencesEncrypt(
156
- publicKey.toByteArray(),
157
- privateKey.toByteArray(),
158
- payload.toByteArray(),
159
- )
150
+ }
151
+ }
152
+ }.build()
160
153
161
- EnvelopeBuilder .buildFromTopic(
162
- Topic .preferenceList(identifier),
163
- Date (),
164
- ByteArray (message.size) { message[it] },
154
+ val message =
155
+ uniffi.xmtpv3.userPreferencesEncrypt(
156
+ publicKey.toByteArray(),
157
+ privateKey.toByteArray(),
158
+ payload.toByteArray(),
165
159
)
166
- }
167
160
168
- client.publish(envelopes)
161
+ val envelope = EnvelopeBuilder .buildFromTopic(
162
+ Topic .preferenceList(identifier),
163
+ Date (),
164
+ ByteArray (message.size) { message[it] },
165
+ )
166
+
167
+ client.publish(listOf (envelope))
169
168
}
170
169
171
170
fun allow (address : String ): ConsentListEntry {
0 commit comments