From 971c92b27a210c4cbebd1d1a5f23c7e06b0cd1c9 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Mon, 5 Aug 2024 16:57:21 -0400 Subject: [PATCH] Adds extension possibility to Quartz's event factory --- .../com/vitorpamplona/quartz/events/EventFactory.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/events/EventFactory.kt b/quartz/src/main/java/com/vitorpamplona/quartz/events/EventFactory.kt index 288ae12e1..74f47a286 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/events/EventFactory.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/events/EventFactory.kt @@ -24,6 +24,11 @@ import com.vitorpamplona.quartz.encoders.toHexKey class EventFactory { companion object { + val additionalFactories = + mutableMapOf( + WikiNoteEvent.KIND to ::WikiNoteEvent, + ) + fun create( id: String, pubKey: String, @@ -141,7 +146,13 @@ class EventFactory { VideoVerticalEvent.KIND -> VideoVerticalEvent(id, pubKey, createdAt, tags, content, sig) VideoViewEvent.KIND -> VideoViewEvent(id, pubKey, createdAt, tags, content, sig) WikiNoteEvent.KIND -> WikiNoteEvent(id, pubKey, createdAt, tags, content, sig) - else -> Event(id, pubKey, createdAt, kind, tags, content, sig) + else -> { + additionalFactories[kind]?.let { + return it(id, pubKey, createdAt, tags, content, sig) + } + + Event(id, pubKey, createdAt, kind, tags, content, sig) + } } } }