clean up code in MetadataEvent.kt
update x drawable
This commit is contained in:
@@ -45,7 +45,7 @@ abstract class IdentityClaim(
|
||||
fun create(
|
||||
platformIdentity: String,
|
||||
proof: String,
|
||||
): IdentityClaim? {
|
||||
): IdentityClaim {
|
||||
val (platform, identity) = platformIdentity.split(':')
|
||||
|
||||
return when (platform.lowercase()) {
|
||||
@@ -166,7 +166,7 @@ class MetadataEvent(
|
||||
.filter { it.firstOrNull() == "i" }
|
||||
.mapNotNull {
|
||||
try {
|
||||
IdentityClaim.create(it.get(1), it.get(2))
|
||||
IdentityClaim.create(it[1], it[2])
|
||||
} catch (e: Exception) {
|
||||
Log.e("MetadataEvent", "Can't parse identity [${it.joinToString { "," }}]", e)
|
||||
null
|
||||
@@ -265,26 +265,5 @@ class MetadataEvent(
|
||||
currentJson.put(key, value.trim())
|
||||
}
|
||||
}
|
||||
|
||||
fun createFromScratch(
|
||||
newName: String,
|
||||
signer: NostrSigner,
|
||||
createdAt: Long = TimeUtils.now(),
|
||||
onReady: (MetadataEvent) -> Unit,
|
||||
) {
|
||||
val prop = ObjectMapper().createObjectNode()
|
||||
prop.put("name", newName.trim())
|
||||
|
||||
val writer = StringWriter()
|
||||
ObjectMapper().writeValue(writer, prop)
|
||||
|
||||
val tags = mutableListOf<Array<String>>()
|
||||
|
||||
tags.add(
|
||||
arrayOf("alt", "User profile for $newName"),
|
||||
)
|
||||
|
||||
signer.sign(createdAt, KIND, tags.toTypedArray(), writer.buffer.toString(), onReady)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user