Fixes failure to load long form content with d tags reserved url chars

This commit is contained in:
Vitor Pamplona
2023-10-06 16:27:40 -04:00
parent e04a35afed
commit 6748abbf70
2 changed files with 13 additions and 4 deletions
@@ -94,7 +94,15 @@ object LocalCache {
val noteEvent = note.event
return if (noteEvent is AddressableEvent) {
// upgrade to the latest
checkGetOrCreateAddressableNote(noteEvent.address().toTag())
val newNote = checkGetOrCreateAddressableNote(noteEvent.address().toTag())
if (newNote != null && noteEvent is Event && newNote.event == null) {
val author = note.author ?: getOrCreateUser(noteEvent.pubKey)
newNote.loadEvent(noteEvent as Event, author, emptyList())
note.moveAllReferencesTo(newNote)
}
newNote
} else {
note
}
@@ -212,6 +212,7 @@ import kotlinx.coroutines.launch
import java.io.File
import java.math.BigDecimal
import java.net.URL
import java.net.URLEncoder
import java.util.Locale
import kotlin.time.measureTimedValue
@@ -1276,16 +1277,16 @@ fun routeFor(note: Note, loggedIn: User): String? {
}
} else if (noteEvent is LiveActivitiesEvent || noteEvent is LiveActivitiesChatMessageEvent) {
note.channelHex()?.let {
return "Channel/$it"
return "Channel/${URLEncoder.encode(it, "utf-8")}"
}
} else if (noteEvent is ChatroomKeyable) {
val room = noteEvent.chatroomKey(loggedIn.pubkeyHex)
loggedIn.createChatroom(room)
return "Room/${room.hashCode()}"
} else if (noteEvent is CommunityDefinitionEvent) {
return "Community/${note.idHex}"
return "Community/${URLEncoder.encode(note.idHex, "utf-8")}"
} else {
return "Note/${note.idHex}"
return "Note/${URLEncoder.encode(note.idHex, "utf-8")}"
}
return null