Don't use DM kinds to get information about other logged-in accounts

pull/931/head
Vitor Pamplona 2024-06-20 09:47:11 -04:00
rodzic d33befe1ad
commit 3a4e2e9623
1 zmienionych plików z 18 dodań i 26 usunięć

Wyświetl plik

@ -27,6 +27,7 @@ import com.vitorpamplona.amethyst.service.relays.COMMON_FEED_TYPES
import com.vitorpamplona.amethyst.service.relays.Client import com.vitorpamplona.amethyst.service.relays.Client
import com.vitorpamplona.amethyst.service.relays.EOSEAccount import com.vitorpamplona.amethyst.service.relays.EOSEAccount
import com.vitorpamplona.amethyst.service.relays.EOSETime import com.vitorpamplona.amethyst.service.relays.EOSETime
import com.vitorpamplona.amethyst.service.relays.EVENT_FINDER_TYPES
import com.vitorpamplona.amethyst.service.relays.JsonFilter import com.vitorpamplona.amethyst.service.relays.JsonFilter
import com.vitorpamplona.amethyst.service.relays.Relay import com.vitorpamplona.amethyst.service.relays.Relay
import com.vitorpamplona.amethyst.service.relays.TypedFilter import com.vitorpamplona.amethyst.service.relays.TypedFilter
@ -76,8 +77,8 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
val latestEOSEs = EOSEAccount() val latestEOSEs = EOSEAccount()
val hasLoadedTheBasics = mutableMapOf<User, Boolean>() val hasLoadedTheBasics = mutableMapOf<User, Boolean>()
fun createAccountContactListFilter(): TypedFilter { fun createAccountContactListFilter(): TypedFilter =
return TypedFilter( TypedFilter(
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
filter = filter =
JsonFilter( JsonFilter(
@ -86,10 +87,9 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
limit = 1, limit = 1,
), ),
) )
}
fun createAccountMetadataFilter(): TypedFilter { fun createAccountMetadataFilter(): TypedFilter =
return TypedFilter( TypedFilter(
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
filter = filter =
JsonFilter( JsonFilter(
@ -98,10 +98,9 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
limit = 1, limit = 1,
), ),
) )
}
fun createAccountRelayListFilter(): TypedFilter { fun createAccountRelayListFilter(): TypedFilter =
return TypedFilter( TypedFilter(
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
filter = filter =
JsonFilter( JsonFilter(
@ -110,12 +109,11 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
limit = 10, limit = 10,
), ),
) )
}
fun createOtherAccountsBaseFilter(): TypedFilter? { fun createOtherAccountsBaseFilter(): TypedFilter? {
if (otherAccounts.isEmpty()) return null if (otherAccounts.isEmpty()) return null
return TypedFilter( return TypedFilter(
types = COMMON_FEED_TYPES, types = EVENT_FINDER_TYPES,
filter = filter =
JsonFilter( JsonFilter(
kinds = kinds =
@ -136,8 +134,8 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
) )
} }
fun createAccountSettingsFilter(): TypedFilter { fun createAccountSettingsFilter(): TypedFilter =
return TypedFilter( TypedFilter(
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
filter = filter =
JsonFilter( JsonFilter(
@ -146,10 +144,9 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
limit = 100, limit = 100,
), ),
) )
}
fun createAccountReportsFilter(): TypedFilter { fun createAccountReportsFilter(): TypedFilter =
return TypedFilter( TypedFilter(
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
filter = filter =
JsonFilter( JsonFilter(
@ -162,10 +159,9 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
?.relayList, ?.relayList,
), ),
) )
}
fun createAccountLastPostsListFilter(): TypedFilter { fun createAccountLastPostsListFilter(): TypedFilter =
return TypedFilter( TypedFilter(
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
filter = filter =
JsonFilter( JsonFilter(
@ -173,7 +169,6 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
limit = 400, limit = 400,
), ),
) )
}
fun createNotificationFilter(): TypedFilter { fun createNotificationFilter(): TypedFilter {
val since = val since =
@ -404,8 +399,8 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
} }
} }
override fun updateChannelFilters() { override fun updateChannelFilters() =
return if (hasLoadedTheBasics[account.userProfile()] != null) { if (hasLoadedTheBasics[account.userProfile()] != null) {
// gets everything about the user logged in // gets everything about the user logged in
accountChannel.typedFilters = accountChannel.typedFilters =
listOfNotNull( listOfNotNull(
@ -419,8 +414,7 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
createAccountSettingsFilter(), createAccountSettingsFilter(),
createAccountLastPostsListFilter(), createAccountLastPostsListFilter(),
createOtherAccountsBaseFilter(), createOtherAccountsBaseFilter(),
) ).ifEmpty { null }
.ifEmpty { null }
} else { } else {
// just the basics. // just the basics.
accountChannel.typedFilters = accountChannel.typedFilters =
@ -429,10 +423,8 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
createAccountContactListFilter(), createAccountContactListFilter(),
createAccountRelayListFilter(), createAccountRelayListFilter(),
createAccountSettingsFilter(), createAccountSettingsFilter(),
) ).ifEmpty { null }
.ifEmpty { null }
} }
}
override fun auth( override fun auth(
relay: Relay, relay: Relay,