Only download video, image and audio files in NIP-94

This commit is contained in:
Vitor Pamplona
2024-03-15 19:43:18 -04:00
parent 6bdf3e2625
commit 6edc634b82
4 changed files with 18 additions and 1 deletions
@@ -58,6 +58,12 @@ class FileHeaderEvent(
fun hasUrl() = tags.any { it.size > 1 && it[0] == URL }
fun isImageOrVideo(): Boolean {
val mimeType = mimeType() ?: return false
return mimeType.startsWith("image/") || mimeType.startsWith("video/")
}
companion object {
const val KIND = 1063
const val ALT_DESCRIPTION = "Verifiable file url"
@@ -54,6 +54,12 @@ class FileStorageHeaderEvent(
fun blurhash() = tags.firstOrNull { it.size > 1 && it[0] == BLUR_HASH }?.get(1)
fun isImageOrVideo(): Boolean {
val mimeType = mimeType() ?: return false
return mimeType.startsWith("image/") || mimeType.startsWith("video/")
}
companion object {
const val KIND = 1065
const val ALT_DESCRIPTION = "Descriptors for a binary file"