kopia lustrzana https://github.com/vitorpamplona/amethyst
31 wiersze
1014 B
Kotlin
31 wiersze
1014 B
Kotlin
package com.vitorpamplona.amethyst.service.model
|
|
|
|
import com.vitorpamplona.amethyst.model.HexKey
|
|
import com.vitorpamplona.amethyst.model.toHexKey
|
|
import nostr.postr.Utils
|
|
import java.util.Date
|
|
|
|
class DeletionEvent(
|
|
id: HexKey,
|
|
pubKey: HexKey,
|
|
createdAt: Long,
|
|
tags: List<List<String>>,
|
|
content: String,
|
|
sig: HexKey
|
|
) : Event(id, pubKey, createdAt, kind, tags, content, sig) {
|
|
fun deleteEvents() = tags.map { it[1] }
|
|
|
|
companion object {
|
|
const val kind = 5
|
|
|
|
fun create(deleteEvents: List<String>, privateKey: ByteArray, createdAt: Long = Date().time / 1000): DeletionEvent {
|
|
val content = ""
|
|
val pubKey = Utils.pubkeyCreate(privateKey).toHexKey()
|
|
val tags = deleteEvents.map { listOf("e", it) }
|
|
val id = generateId(pubKey, createdAt, kind, tags, content)
|
|
val sig = Utils.sign(id, privateKey)
|
|
return DeletionEvent(id.toHexKey(), pubKey, createdAt, tags, content, sig.toHexKey())
|
|
}
|
|
}
|
|
}
|