Brings the creation of Zap Polls back.
This commit is contained in:
+7
-7
@@ -27,19 +27,19 @@ import com.vitorpamplona.quartz.experimental.zapPolls.tags.MinimumTag
|
||||
import com.vitorpamplona.quartz.experimental.zapPolls.tags.PollOptionTag
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
|
||||
fun TagArrayBuilder<PollNoteEvent>.consensusThreshold(percentage: Double) = addUnique(ConsensusThresholdTag.assemble(percentage))
|
||||
fun TagArrayBuilder<ZapPollEvent>.consensusThreshold(percentage: Double) = addUnique(ConsensusThresholdTag.assemble(percentage))
|
||||
|
||||
fun TagArrayBuilder<PollNoteEvent>.minAmount(value: Long) = addUnique(MinimumTag.assemble(value))
|
||||
fun TagArrayBuilder<ZapPollEvent>.minAmount(value: Long) = addUnique(MinimumTag.assemble(value))
|
||||
|
||||
fun TagArrayBuilder<PollNoteEvent>.maxAmount(value: Long) = addUnique(MaximumTag.assemble(value))
|
||||
fun TagArrayBuilder<ZapPollEvent>.maxAmount(value: Long) = addUnique(MaximumTag.assemble(value))
|
||||
|
||||
fun TagArrayBuilder<PollNoteEvent>.closedAt(timestamp: Long) = addUnique(ClosedAtTag.assemble(timestamp))
|
||||
fun TagArrayBuilder<ZapPollEvent>.closedAt(timestamp: Long) = addUnique(ClosedAtTag.assemble(timestamp))
|
||||
|
||||
fun TagArrayBuilder<PollNoteEvent>.pollOption(
|
||||
fun TagArrayBuilder<ZapPollEvent>.pollOption(
|
||||
index: Int,
|
||||
description: String,
|
||||
) = add(PollOptionTag.assemble(index, description))
|
||||
|
||||
fun TagArrayBuilder<PollNoteEvent>.pollOptions(options: Map<Int, String>) = addAll(options.map { PollOptionTag.assemble(it.key, it.value) })
|
||||
fun TagArrayBuilder<ZapPollEvent>.pollOptions(options: Map<Int, String>) = addAll(options.map { PollOptionTag.assemble(it.key, it.value) })
|
||||
|
||||
fun TagArrayBuilder<PollNoteEvent>.pollOptions(options: List<PollOptionTag>) = addAll(options.map { it.toTagArray() })
|
||||
fun TagArrayBuilder<ZapPollEvent>.pollOptions(options: List<PollOptionTag>) = addAll(options.map { it.toTagArray() })
|
||||
|
||||
+4
-4
@@ -51,7 +51,7 @@ import com.vitorpamplona.quartz.nip50Search.SearchableEvent
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
|
||||
@Immutable
|
||||
class PollNoteEvent(
|
||||
class ZapPollEvent(
|
||||
id: HexKey,
|
||||
pubKey: HexKey,
|
||||
createdAt: Long,
|
||||
@@ -131,9 +131,9 @@ class PollNoteEvent(
|
||||
post: String,
|
||||
options: List<PollOptionTag>,
|
||||
createdAt: Long = TimeUtils.now(),
|
||||
initializer: TagArrayBuilder<PollNoteEvent>.() -> Unit = {},
|
||||
): EventTemplate<PollNoteEvent> {
|
||||
val tags = TagArrayBuilder<PollNoteEvent>()
|
||||
initializer: TagArrayBuilder<ZapPollEvent>.() -> Unit = {},
|
||||
): EventTemplate<ZapPollEvent> {
|
||||
val tags = TagArrayBuilder<ZapPollEvent>()
|
||||
tags.pollOptions(options)
|
||||
tags.alt(ALT_DESCRIPTION)
|
||||
tags.apply(initializer)
|
||||
@@ -38,7 +38,7 @@ import com.vitorpamplona.quartz.experimental.profileGallery.ProfileGalleryEntryE
|
||||
import com.vitorpamplona.quartz.experimental.publicMessages.PublicMessageEvent
|
||||
import com.vitorpamplona.quartz.experimental.relationshipStatus.ContactCardEvent
|
||||
import com.vitorpamplona.quartz.experimental.trustedAssertions.list.TrustProviderListEvent
|
||||
import com.vitorpamplona.quartz.experimental.zapPolls.PollNoteEvent
|
||||
import com.vitorpamplona.quartz.experimental.zapPolls.ZapPollEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
|
||||
@@ -282,7 +282,7 @@ class EventFactory {
|
||||
PeopleListEvent.KIND -> PeopleListEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
PictureEvent.KIND -> PictureEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
PinListEvent.KIND -> PinListEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
PollNoteEvent.KIND -> PollNoteEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
ZapPollEvent.KIND -> ZapPollEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
PollEvent.KIND -> PollEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
PollResponseEvent.KIND -> PollResponseEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
PrivateDmEvent.KIND -> PrivateDmEvent(id, pubKey, createdAt, tags, content, sig)
|
||||
|
||||
Reference in New Issue
Block a user