mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-11 00:15:08 +02:00
Update NIP90ContentDiscoveryFilter.kt
This commit is contained in:
@@ -56,21 +56,25 @@ open class NIP90ContentDiscoveryFilter(
|
|||||||
noteEvent is NIP90ContentDiscoveryResponseEvent && it.event?.pubKey() == dvmkey && it.event?.isTaggedUser(account.keyPair.pubKey.toHexKey()) == true // && params.match(noteEvent)
|
noteEvent is NIP90ContentDiscoveryResponseEvent && it.event?.pubKey() == dvmkey && it.event?.isTaggedUser(account.keyPair.pubKey.toHexKey()) == true // && params.match(noteEvent)
|
||||||
}
|
}
|
||||||
var sorted = sort(notes)
|
var sorted = sort(notes)
|
||||||
var note = sorted.first()
|
if (sorted.isNotEmpty()) {
|
||||||
|
var note = sorted.first()
|
||||||
|
|
||||||
var eventContent = note.event?.content()
|
var eventContent = note.event?.content()
|
||||||
|
|
||||||
var collection: Set<Note> = setOf()
|
var collection: Set<Note> = setOf()
|
||||||
val mapper = jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
val mapper = jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
var json = mapper.readValue(eventContent, Array::class.java)
|
var json = mapper.readValue(eventContent, Array::class.java)
|
||||||
for (element in json) {
|
for (element in json) {
|
||||||
// var test = mapper.readValue(element.toString(), Array::class.java)
|
// var test = mapper.readValue(element.toString(), Array::class.java)
|
||||||
// TODO. This is ugly. how to Kotlin?
|
// TODO. This is ugly. how to Kotlin?
|
||||||
var id = element.toString().trimStart('[').trimStart('e').trimStart(',').trimEnd(']').trimStart().trimEnd()
|
var id = element.toString().trimStart('[').trimStart('e').trimStart(',').trimEnd(']').trimStart().trimEnd()
|
||||||
collection + id
|
collection + id
|
||||||
|
}
|
||||||
|
|
||||||
|
return sort(collection)
|
||||||
|
} else {
|
||||||
|
return sort(notes)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sort(collection)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyFilter(collection: Set<Note>): Set<Note> {
|
override fun applyFilter(collection: Set<Note>): Set<Note> {
|
||||||
@@ -98,25 +102,29 @@ open class NIP90ContentDiscoveryFilter(
|
|||||||
// TODO. We want to parse the content of the latest event to ids and get the nodes from these ids
|
// TODO. We want to parse the content of the latest event to ids and get the nodes from these ids
|
||||||
|
|
||||||
/* var sorted = sort(notes)
|
/* var sorted = sort(notes)
|
||||||
var note = sorted.first()
|
if (sorted.isNotEmpty()) {
|
||||||
|
var note = sorted.first()
|
||||||
|
|
||||||
var eventContent = note.event?.content()
|
var eventContent = note.event?.content()
|
||||||
|
|
||||||
val collection: Set<Note> = setOf()
|
val collection: Set<Note> = setOf()
|
||||||
val mapper = jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
val mapper = jacksonObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||||
var json = mapper.readValue(eventContent, Array::class.java)
|
var json = mapper.readValue(eventContent, Array::class.java)
|
||||||
for (element in json) {
|
for (element in json) {
|
||||||
// var test = mapper.readValue(element.toString(), Array::class.java)
|
// var test = mapper.readValue(element.toString(), Array::class.java)
|
||||||
// TODO. This is ugly. how to Kotlin?
|
// TODO. This is ugly. how to Kotlin?
|
||||||
var id = element.toString().trimStart('[').trimStart('e').trimStart(',').trimEnd(']').trimStart().trimEnd()
|
var id = element.toString().trimStart('[').trimStart('e').trimStart(',').trimEnd(']').trimStart().trimEnd()
|
||||||
|
|
||||||
var note = LocalCache.getNoteIfExists(id)
|
var note = LocalCache.getNoteIfExists(id)
|
||||||
if (note != null) {
|
if (note != null) {
|
||||||
collection + note
|
collection + note
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return collection
|
||||||
|
} else {
|
||||||
|
return notes
|
||||||
}
|
}
|
||||||
|
|
||||||
return collection
|
|
||||||
*/
|
*/
|
||||||
return notes
|
return notes
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user