mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-30 00:40:49 +00:00
Fixes the crash when opening a malformed thread with a wrong root marker
This commit is contained in:
parent
dfdced3e8c
commit
954a9d66fb
@ -129,12 +129,14 @@ open class Note(val idHex: String) {
|
|||||||
return "/" + formattedDateTime(createdAt() ?: 0) + ";"
|
return "/" + formattedDateTime(createdAt() ?: 0) + ";"
|
||||||
}
|
}
|
||||||
|
|
||||||
val mySignature = replyTo
|
val mySignature = (
|
||||||
.filter { it in eventsToConsider } // This forces the signature to be based on a branch, avoiding two roots
|
replyTo
|
||||||
.map {
|
.filter { it in eventsToConsider } // This forces the signature to be based on a branch, avoiding two roots
|
||||||
cachedSignatures[it] ?: it.replyLevelSignature(eventsToConsider, cachedSignatures).apply { cachedSignatures.put(it, this) }
|
.map {
|
||||||
}
|
cachedSignatures[it] ?: it.replyLevelSignature(eventsToConsider, cachedSignatures).apply { cachedSignatures.put(it, this) }
|
||||||
.maxBy { it.length }.removeSuffix(";") + "/" + formattedDateTime(createdAt() ?: 0) + ";"
|
}
|
||||||
|
.maxByOrNull { it.length }?.removeSuffix(";") ?: ""
|
||||||
|
) + "/" + formattedDateTime(createdAt() ?: 0) + ";"
|
||||||
|
|
||||||
cachedSignatures[this] = mySignature
|
cachedSignatures[this] = mySignature
|
||||||
return mySignature
|
return mySignature
|
||||||
|
@ -15,7 +15,12 @@ class ThreadAssembler {
|
|||||||
testedNotes.add(note)
|
testedNotes.add(note)
|
||||||
|
|
||||||
val markedAsRoot = note.event?.tags()?.firstOrNull { it[0] == "e" && it.size > 3 && it[3] == "root" }?.getOrNull(1)
|
val markedAsRoot = note.event?.tags()?.firstOrNull { it[0] == "e" && it.size > 3 && it[3] == "root" }?.getOrNull(1)
|
||||||
if (markedAsRoot != null) return LocalCache.checkGetOrCreateNote(markedAsRoot)
|
if (markedAsRoot != null) {
|
||||||
|
// Check to ssee if there is an error in the tag and the root has replies
|
||||||
|
if (LocalCache.getNoteIfExists(markedAsRoot)?.replyTo?.isEmpty() == true) {
|
||||||
|
return LocalCache.checkGetOrCreateNote(markedAsRoot)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val hasNoReplyTo = note.replyTo?.firstOrNull { it.replyTo?.isEmpty() == true }
|
val hasNoReplyTo = note.replyTo?.firstOrNull { it.replyTo?.isEmpty() == true }
|
||||||
if (hasNoReplyTo != null) return hasNoReplyTo
|
if (hasNoReplyTo != null) return hasNoReplyTo
|
||||||
|
Loading…
Reference in New Issue
Block a user