Simplifies the first call to Nostr relays
This commit is contained in:
@@ -6,6 +6,8 @@ import com.vitorpamplona.amethyst.model.Note
|
|||||||
import com.vitorpamplona.amethyst.model.UserState
|
import com.vitorpamplona.amethyst.model.UserState
|
||||||
import com.vitorpamplona.amethyst.service.model.RepostEvent
|
import com.vitorpamplona.amethyst.service.model.RepostEvent
|
||||||
import nostr.postr.JsonFilter
|
import nostr.postr.JsonFilter
|
||||||
|
import nostr.postr.events.ContactListEvent
|
||||||
|
import nostr.postr.events.MetadataEvent
|
||||||
import nostr.postr.events.TextNoteEvent
|
import nostr.postr.events.TextNoteEvent
|
||||||
import nostr.postr.toHex
|
import nostr.postr.toHex
|
||||||
|
|
||||||
@@ -30,6 +32,7 @@ object NostrAccountDataSource: NostrDataSource("AccountData") {
|
|||||||
|
|
||||||
fun createAccountFilter(): JsonFilter {
|
fun createAccountFilter(): JsonFilter {
|
||||||
return JsonFilter(
|
return JsonFilter(
|
||||||
|
kinds = listOf(MetadataEvent.kind, ContactListEvent.kind),
|
||||||
authors = listOf(account.userProfile().pubkeyHex),
|
authors = listOf(account.userProfile().pubkeyHex),
|
||||||
since = System.currentTimeMillis() / 1000 - (60 * 60 * 24 * 7), // 4 days
|
since = System.currentTimeMillis() / 1000 - (60 * 60 * 24 * 7), // 4 days
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -29,11 +29,13 @@ object NostrHomeDataSource: NostrDataSource("HomeFeed") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun createFollowAccountsFilter(): JsonFilter? {
|
fun createFollowAccountsFilter(): JsonFilter? {
|
||||||
val follows = account.userProfile().follows?.map {
|
val follows = listOf(account.userProfile().pubkeyHex.substring(0, 6)).plus(
|
||||||
|
account.userProfile().follows?.map {
|
||||||
it.pubkey.toHex().substring(0, 6)
|
it.pubkey.toHex().substring(0, 6)
|
||||||
}
|
} ?: emptyList()
|
||||||
|
)
|
||||||
|
|
||||||
if (follows == null || follows.isEmpty()) return null
|
if (follows.isEmpty()) return null
|
||||||
|
|
||||||
return JsonFilter(
|
return JsonFilter(
|
||||||
kinds = listOf(TextNoteEvent.kind, RepostEvent.kind),
|
kinds = listOf(TextNoteEvent.kind, RepostEvent.kind),
|
||||||
|
|||||||
Reference in New Issue
Block a user