Trimming User Metadata fields to avoid crashes when using them

This commit is contained in:
Vitor Pamplona 2023-02-18 14:05:46 -05:00
parent 4f53a74004
commit b60d7ff857
3 changed files with 13 additions and 13 deletions

View File

@ -49,17 +49,17 @@ class NewUserMetadataViewModel: ViewModel() {
} else {
ObjectMapper().createObjectNode()
}
currentJson.put("name", userName.value)
currentJson.put("username", userName.value)
currentJson.put("display_name", displayName.value)
currentJson.put("displayName", displayName.value)
currentJson.put("picture", picture.value)
currentJson.put("banner", banner.value)
currentJson.put("website", website.value)
currentJson.put("about", about.value)
currentJson.put("nip05", nip05.value)
currentJson.put("lud16", lnAddress.value)
currentJson.put("lud06", lnURL.value)
currentJson.put("name", userName.value.trim())
currentJson.put("username", userName.value.trim())
currentJson.put("display_name", displayName.value.trim())
currentJson.put("displayName", displayName.value.trim())
currentJson.put("picture", picture.value.trim())
currentJson.put("banner", banner.value.trim())
currentJson.put("website", website.value.trim())
currentJson.put("about", about.value.trim())
currentJson.put("nip05", nip05.value.trim())
currentJson.put("lud16", lnAddress.value.trim())
currentJson.put("lud06", lnURL.value.trim())
val writer = StringWriter()
ObjectMapper().writeValue(writer, currentJson)

View File

@ -25,7 +25,7 @@ class AccountViewModel(private val account: Account): ViewModel() {
}
fun zap(note: Note, amount: Long, message: String, context: Context, onError: (String) -> Unit) {
val lud16 = note.author?.info?.lud16
val lud16 = note.author?.info?.lud16?.trim()
if (lud16.isNullOrBlank()) {
onError("User does not have a lightning address setup to receive sats")

View File

@ -378,7 +378,7 @@ private fun DrawAdditionalInfo(baseUser: User, account: Account) {
var ZapExpanded by remember { mutableStateOf(false) }
val lud16 = user.info.lud16
val lud16 = user.info.lud16?.trim()
if (!lud16.isNullOrEmpty()) {
Row(verticalAlignment = Alignment.CenterVertically) {