Simplifies the first call to Nostr relays

This commit is contained in:
Vitor Pamplona 2023-01-13 20:17:24 -05:00
parent 380c2e67cc
commit 66cfa9201c
2 changed files with 9 additions and 4 deletions

View File

@ -6,6 +6,8 @@ import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.model.UserState
import com.vitorpamplona.amethyst.service.model.RepostEvent
import nostr.postr.JsonFilter
import nostr.postr.events.ContactListEvent
import nostr.postr.events.MetadataEvent
import nostr.postr.events.TextNoteEvent
import nostr.postr.toHex
@ -30,6 +32,7 @@ object NostrAccountDataSource: NostrDataSource("AccountData") {
fun createAccountFilter(): JsonFilter {
return JsonFilter(
kinds = listOf(MetadataEvent.kind, ContactListEvent.kind),
authors = listOf(account.userProfile().pubkeyHex),
since = System.currentTimeMillis() / 1000 - (60 * 60 * 24 * 7), // 4 days
)

View File

@ -29,11 +29,13 @@ object NostrHomeDataSource: NostrDataSource("HomeFeed") {
}
fun createFollowAccountsFilter(): JsonFilter? {
val follows = account.userProfile().follows?.map {
it.pubkey.toHex().substring(0, 6)
}
val follows = listOf(account.userProfile().pubkeyHex.substring(0, 6)).plus(
account.userProfile().follows?.map {
it.pubkey.toHex().substring(0, 6)
} ?: emptyList()
)
if (follows == null || follows.isEmpty()) return null
if (follows.isEmpty()) return null
return JsonFilter(
kinds = listOf(TextNoteEvent.kind, RepostEvent.kind),