Refactor the relay list for chat message event kind

This commit is contained in:
Vitor Pamplona
2024-05-14 16:34:32 -04:00
parent fad4248539
commit f8afb4b783
4 changed files with 14 additions and 9 deletions
@@ -21,12 +21,13 @@
package com.vitorpamplona.quartz.events
import androidx.compose.runtime.Immutable
import com.vitorpamplona.quartz.encoders.ATag
import com.vitorpamplona.quartz.encoders.HexKey
import com.vitorpamplona.quartz.signers.NostrSigner
import com.vitorpamplona.quartz.utils.TimeUtils
@Immutable
class DirectMessageRelayListEvent(
class ChatMessageRelayListEvent(
id: HexKey,
pubKey: HexKey,
createdAt: Long,
@@ -50,11 +51,15 @@ class DirectMessageRelayListEvent(
const val KIND = 10050
const val FIXED_D_TAG = ""
fun createAddressTag(pubKey: HexKey): String {
return ATag.assembleATag(KIND, pubKey, FIXED_D_TAG)
}
fun create(
relays: List<String>,
signer: NostrSigner,
createdAt: Long = TimeUtils.now(),
onReady: (DirectMessageRelayListEvent) -> Unit,
onReady: (ChatMessageRelayListEvent) -> Unit,
) {
val tags =
relays.map {
@@ -71,6 +71,7 @@ class EventFactory {
ChatMessageEvent(id, pubKey, createdAt, tags, content, sig)
}
}
ChatMessageRelayListEvent.KIND -> ChatMessageRelayListEvent(id, pubKey, createdAt, tags, content, sig)
ClassifiedsEvent.KIND -> ClassifiedsEvent(id, pubKey, createdAt, tags, content, sig)
CommunityDefinitionEvent.KIND ->
CommunityDefinitionEvent(id, pubKey, createdAt, tags, content, sig)
@@ -79,7 +80,6 @@ class EventFactory {
CommunityPostApprovalEvent(id, pubKey, createdAt, tags, content, sig)
ContactListEvent.KIND -> ContactListEvent(id, pubKey, createdAt, tags, content, sig)
DeletionEvent.KIND -> DeletionEvent(id, pubKey, createdAt, tags, content, sig)
DirectMessageRelayListEvent.KIND -> DirectMessageRelayListEvent(id, pubKey, createdAt, tags, content, sig)
DraftEvent.KIND -> DraftEvent(id, pubKey, createdAt, tags, content, sig)
EmojiPackEvent.KIND -> EmojiPackEvent(id, pubKey, createdAt, tags, content, sig)
EmojiPackSelectionEvent.KIND ->