@@ -22,7 +22,7 @@ data class ConsentListEntry(
22
22
val value : String ,
23
23
val entryType : EntryType ,
24
24
val consentType : ConsentState ,
25
- val createdAt : Date
25
+ val createdAt : Date ,
26
26
) {
27
27
enum class EntryType {
28
28
ADDRESS ,
@@ -33,15 +33,17 @@ data class ConsentListEntry(
33
33
fun address (
34
34
address : String ,
35
35
type : ConsentState = ConsentState .UNKNOWN ,
36
+ createdAt : Date = Date (),
36
37
): ConsentListEntry {
37
- return ConsentListEntry (address, EntryType .ADDRESS , type)
38
+ return ConsentListEntry (address, EntryType .ADDRESS , type, createdAt )
38
39
}
39
40
40
41
fun groupId (
41
42
groupId : ByteArray ,
42
43
type : ConsentState = ConsentState .UNKNOWN ,
44
+ createdAt : Date = Date (),
43
45
): ConsentListEntry {
44
- return ConsentListEntry (String (groupId), EntryType .GROUP_ID , type)
46
+ return ConsentListEntry (String (groupId), EntryType .GROUP_ID , type, createdAt )
45
47
}
46
48
}
47
49
@@ -69,9 +71,12 @@ class ConsentList(
69
71
val envelopes =
70
72
client.apiClient.envelopes(
71
73
Topic .preferenceList(identifier).description,
72
- Pagination (before = mostRecent, direction = MessageApiOuterClass .SortDirection .SORT_DIRECTION_ASCENDING ),
74
+ Pagination (
75
+ before = mostRecent,
76
+ direction = MessageApiOuterClass .SortDirection .SORT_DIRECTION_ASCENDING
77
+ ),
73
78
)
74
- val preferences: MutableList <PrivatePreferencesAction > = mutableListOf ()
79
+ val preferences: MutableList <Pair < PrivatePreferencesAction , Date > > = mutableListOf ()
75
80
for (envelope in envelopes) {
76
81
val payload =
77
82
uniffi.xmtpv3.userPreferencesDecrypt(
@@ -81,24 +86,26 @@ class ConsentList(
81
86
)
82
87
83
88
preferences.add(
84
- PrivatePreferencesAction .parseFrom(
85
- payload.toUByteArray().toByteArray(),
86
- ),
89
+ Pair (
90
+ PrivatePreferencesAction .parseFrom(
91
+ payload.toUByteArray().toByteArray(),
92
+ ), Date (envelope.timestampNs)
93
+ )
87
94
)
88
95
}
89
96
90
- preferences.iterator().forEach { preference ->
97
+ preferences.iterator().forEach { ( preference, date) ->
91
98
preference.allowAddress?.walletAddressesList?.forEach { address ->
92
- allow(address)
99
+ allow(address, date )
93
100
}
94
101
preference.denyAddress?.walletAddressesList?.forEach { address ->
95
- deny(address)
102
+ deny(address, date )
96
103
}
97
104
preference.allowGroup?.groupIdsList?.forEach { groupId ->
98
- allowGroup(groupId.toByteArray())
105
+ allowGroup(groupId.toByteArray(), date )
99
106
}
100
107
preference.denyGroup?.groupIdsList?.forEach { groupId ->
101
- denyGroup(groupId.toByteArray())
108
+ denyGroup(groupId.toByteArray(), date )
102
109
}
103
110
}
104
111
@@ -164,30 +171,30 @@ class ConsentList(
164
171
client.publish(listOf (envelope))
165
172
}
166
173
167
- fun allow (address : String ): ConsentListEntry {
168
- val entry = ConsentListEntry .address(address, ConsentState .ALLOWED )
169
- entries[ConsentListEntry .address(address) .key] = entry
174
+ fun allow (address : String , date : Date ): ConsentListEntry {
175
+ val entry = ConsentListEntry .address(address, ConsentState .ALLOWED , date )
176
+ entries[entry .key] = entry
170
177
171
178
return entry
172
179
}
173
180
174
- fun deny (address : String ): ConsentListEntry {
175
- val entry = ConsentListEntry .address(address, ConsentState .DENIED )
176
- entries[ConsentListEntry .address(address) .key] = entry
181
+ fun deny (address : String , date : Date ): ConsentListEntry {
182
+ val entry = ConsentListEntry .address(address, ConsentState .DENIED , date )
183
+ entries[entry .key] = entry
177
184
178
185
return entry
179
186
}
180
187
181
- fun allowGroup (groupId : ByteArray ): ConsentListEntry {
182
- val entry = ConsentListEntry .groupId(groupId, ConsentState .ALLOWED )
183
- entries[ConsentListEntry .groupId(groupId) .key] = entry
188
+ fun allowGroup (groupId : ByteArray , date : Date ): ConsentListEntry {
189
+ val entry = ConsentListEntry .groupId(groupId, ConsentState .ALLOWED , date )
190
+ entries[entry .key] = entry
184
191
185
192
return entry
186
193
}
187
194
188
- fun denyGroup (groupId : ByteArray ): ConsentListEntry {
189
- val entry = ConsentListEntry .groupId(groupId, ConsentState .DENIED )
190
- entries[ConsentListEntry .groupId(groupId) .key] = entry
195
+ fun denyGroup (groupId : ByteArray , date : Date ): ConsentListEntry {
196
+ val entry = ConsentListEntry .groupId(groupId, ConsentState .DENIED , date )
197
+ entries[entry .key] = entry
191
198
192
199
return entry
193
200
}
0 commit comments