Fix order of Events in DVM feeds
This commit is contained in:
@@ -25,6 +25,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import com.vitorpamplona.amethyst.model.Account
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.model.Note
|
||||
import com.vitorpamplona.quartz.encoders.toHexKey
|
||||
import com.vitorpamplona.quartz.events.MuteListEvent
|
||||
import com.vitorpamplona.quartz.events.NIP90ContentDiscoveryResponseEvent
|
||||
import com.vitorpamplona.quartz.events.PeopleListEvent
|
||||
@@ -63,14 +64,16 @@ open class NIP90ContentDiscoveryFilter(
|
||||
|
||||
var eventContent = note.event?.content()
|
||||
|
||||
var collection: HashSet<Note> = hashSetOf()
|
||||
var collection: MutableSet<Note> = mutableSetOf()
|
||||
val mapper = jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
var json = mapper.readValue(eventContent, Array::class.java)
|
||||
for (element in json) {
|
||||
// var test = mapper.readValue(element.toString(), Array::class.java)
|
||||
// TODO. This is ugly. how to Kotlin?
|
||||
|
||||
var id = element.toString().trimStart('[').trimStart('e').trimStart(',').trimEnd(']').trimStart().trimEnd()
|
||||
var note = LocalCache.checkGetOrCreateNote(id)
|
||||
|
||||
if (note != null) {
|
||||
collection.add(note)
|
||||
}
|
||||
@@ -78,7 +81,7 @@ open class NIP90ContentDiscoveryFilter(
|
||||
|
||||
return collection.toList()
|
||||
} else {
|
||||
return sort(notes)
|
||||
return listOf()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +115,7 @@ open class NIP90ContentDiscoveryFilter(
|
||||
var eventContent = note.event?.content()
|
||||
println(eventContent)
|
||||
|
||||
val collection: HashSet<Note> = hashSetOf()
|
||||
val collection: MutableSet<Note> = mutableSetOf()
|
||||
val mapper = jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
var json = mapper.readValue(eventContent, Array::class.java)
|
||||
for (element in json) {
|
||||
@@ -122,12 +125,13 @@ open class NIP90ContentDiscoveryFilter(
|
||||
|
||||
val note = LocalCache.checkGetOrCreateNote(id)
|
||||
if (note != null) {
|
||||
println(note.id().toHexKey())
|
||||
collection.add(note)
|
||||
}
|
||||
}
|
||||
return collection
|
||||
} else {
|
||||
return notes
|
||||
return hashSetOf()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user