Sync profile related events
This commit is contained in:
1 parent
f92ece5b66
commit
74e9004474
3 files changed
+35
-7
No files matched your search
+17
-1
@@ -15,6 +15,13 @@ import co.touchlab.kermit.Logger
|
|||||||
import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
|
import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.events.taggedEvents
|
import com.vitorpamplona.quartz.nip01Core.tags.events.taggedEvents
|
||||||
import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUsers
|
import com.vitorpamplona.quartz.nip01Core.tags.people.taggedUsers
|
||||||
|
import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||||
import kotlin.time.Clock
|
import kotlin.time.Clock
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
@@ -129,7 +136,16 @@ abstract class NostrDao(
|
|||||||
synchronizationFilters = arrayOf(
|
synchronizationFilters = arrayOf(
|
||||||
SynchronizationFilter(
|
SynchronizationFilter(
|
||||||
authors = arrayOf(nostrEvent.pubKey),
|
authors = arrayOf(nostrEvent.pubKey),
|
||||||
kinds = arrayOf(MetadataEvent.KIND)
|
kinds = arrayOf(
|
||||||
|
MetadataEvent.KIND,
|
||||||
|
ContactListEvent.KIND,
|
||||||
|
AdvertisedRelayListEvent.KIND,
|
||||||
|
ChatMessageRelayListEvent.KIND,
|
||||||
|
SearchRelayListEvent.KIND,
|
||||||
|
IndexerRelayListEvent.KIND,
|
||||||
|
ChannelListEvent.KIND,
|
||||||
|
RelayFeedsListEvent.KIND
|
||||||
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
relayURL = synchronizationRelayURL
|
relayURL = synchronizationRelayURL
|
||||||
|
|||||||
-4
@@ -92,10 +92,6 @@ data class NostrEvent(
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isProfileCreationEvent(): Boolean {
|
|
||||||
return kind == MetadataEvent.KIND && unsignedNostrEventId != null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun toPost(): Post? = try {
|
fun toPost(): Post? = try {
|
||||||
if (kind == TextNoteEvent.KIND) {
|
if (kind == TextNoteEvent.KIND) {
|
||||||
val textNote = EventFactory.create<TextNoteEvent>(
|
val textNote = EventFactory.create<TextNoteEvent>(
|
||||||
|
|||||||
+18
-2
@@ -13,6 +13,13 @@ import androidx.lifecycle.viewmodel.viewModelFactory
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import co.touchlab.kermit.Logger
|
import co.touchlab.kermit.Logger
|
||||||
import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
|
import com.vitorpamplona.quartz.nip01Core.metadata.MetadataEvent
|
||||||
|
import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip17Dm.settings.ChatMessageRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip28PublicChat.list.ChannelListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.IndexerRelayListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip51Lists.relayLists.RelayFeedsListEvent
|
||||||
|
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.IO
|
import kotlinx.coroutines.IO
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@@ -52,13 +59,22 @@ class UnqueuedProfileSynchronizationViewModel(
|
|||||||
delay(2_000)
|
delay(2_000)
|
||||||
|
|
||||||
nostrRepository.queueSynchronizeNostrEvent(
|
nostrRepository.queueSynchronizeNostrEvent(
|
||||||
Relays.eventPublishRelaySet.take(1).map { normalizedRelayUrl -> // TODO: Sync from all relays instead of 1
|
Relays.eventPublishRelaySet.map { normalizedRelayUrl ->
|
||||||
SynchronizeNostrEventRequest(
|
SynchronizeNostrEventRequest(
|
||||||
purpose = "sign-in",
|
purpose = "sign-in",
|
||||||
synchronizationFilters = arrayOf(
|
synchronizationFilters = arrayOf(
|
||||||
SynchronizationFilter(
|
SynchronizationFilter(
|
||||||
authors = arrayOf(profilePublicKey),
|
authors = arrayOf(profilePublicKey),
|
||||||
kinds = arrayOf(MetadataEvent.KIND)
|
kinds = arrayOf(
|
||||||
|
MetadataEvent.KIND,
|
||||||
|
ContactListEvent.KIND,
|
||||||
|
AdvertisedRelayListEvent.KIND,
|
||||||
|
ChatMessageRelayListEvent.KIND,
|
||||||
|
SearchRelayListEvent.KIND,
|
||||||
|
IndexerRelayListEvent.KIND,
|
||||||
|
ChannelListEvent.KIND,
|
||||||
|
RelayFeedsListEvent.KIND
|
||||||
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
unsignedNostrEventId = unsignedNostrEventId,
|
unsignedNostrEventId = unsignedNostrEventId,
|
||||||
|
|||||||
Reference in new issue
Block a user