From 5f0fd52f26e2a50f111146e6fcfb1be72225f874 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Mar 2026 12:17:03 +0000 Subject: [PATCH] refactor: remove nip88PollApps discovery package (out of scope) https://claude.ai/code/session_013r2LXj11SieWa5PaLesKfC --- .../DiscoverNIP89PollAppsFeedFilter.kt | 47 ---------- .../nip88PollApps/SubAssemblyHelper.kt | 45 --------- .../subassemblies/FilterPollAppsByAuthors.kt | 94 ------------------- .../subassemblies/FilterPollAppsByFollows.kt | 44 --------- .../subassemblies/FilterPollAppsGlobal.kt | 52 ---------- 5 files changed, 282 deletions(-) delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/DiscoverNIP89PollAppsFeedFilter.kt delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/SubAssemblyHelper.kt delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsByAuthors.kt delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsByFollows.kt delete mode 100644 amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsGlobal.kt diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/DiscoverNIP89PollAppsFeedFilter.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/DiscoverNIP89PollAppsFeedFilter.kt deleted file mode 100644 index 8ff75b3ec..000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/DiscoverNIP89PollAppsFeedFilter.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip88PollApps - -import com.vitorpamplona.amethyst.model.Account -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip90DVMs.DiscoverNIP89FeedFilter -import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent -import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent - -/** - * NIP-89 discovery feed filter for poll-supporting applications. - * - * Discovers [AppDefinitionEvent]s that declare support for [PollEvent.KIND] (1068), - * linking NIP-88 polls to NIP-89 app handler discovery. - */ -class DiscoverNIP89PollAppsFeedFilter( - account: Account, -) : DiscoverNIP89FeedFilter(account, PollEvent.KIND) { - override fun acceptApp( - noteEvent: AppDefinitionEvent, - relays: List, - ): Boolean { - val filterParams = buildFilterParams(account) - return filterParams.match(noteEvent, relays) && - noteEvent.includeKind(targetKind) && - noteEvent.createdAt > lastAnnounced - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/SubAssemblyHelper.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/SubAssemblyHelper.kt deleted file mode 100644 index 0f6c09efa..000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/SubAssemblyHelper.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip88PollApps - -import com.vitorpamplona.amethyst.model.topNavFeeds.IFeedTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip88PollApps.subassemblies.filterPollAppsByAuthors -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip88PollApps.subassemblies.filterPollAppsByFollows -import com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip88PollApps.subassemblies.filterPollAppsGlobal -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter - -fun makePollAppsFilter( - feedSettings: IFeedTopNavPerRelayFilterSet, - since: SincePerRelayMap?, - defaultSince: Long?, -): List = - when (feedSettings) { - is AllFollowsTopNavPerRelayFilterSet -> filterPollAppsByFollows(feedSettings, since, defaultSince) - is AuthorsTopNavPerRelayFilterSet -> filterPollAppsByAuthors(feedSettings, since, defaultSince) - is GlobalTopNavPerRelayFilterSet -> filterPollAppsGlobal(feedSettings, since, defaultSince) - is MutedAuthorsTopNavPerRelayFilterSet -> filterPollAppsByAuthors(feedSettings, since, defaultSince) - else -> emptyList() - } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsByAuthors.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsByAuthors.kt deleted file mode 100644 index 74b2bc553..000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsByAuthors.kt +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip88PollApps.subassemblies - -import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.author.AuthorsTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.model.topNavFeeds.noteBased.muted.MutedAuthorsTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.core.HexKey -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter -import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl -import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent -import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent - -fun filterPollAppsAuthors( - relay: NormalizedRelayUrl, - authors: Set, - since: Long? = null, -): List { - val authorList = authors.sorted() - return listOf( - RelayBasedFilter( - relay = relay, - filter = - Filter( - authors = authorList, - kinds = listOf(AppDefinitionEvent.KIND), - tags = mapOf("k" to listOf(PollEvent.KIND.toString())), - limit = 300, - since = since, - ), - ), - ) -} - -fun filterPollAppsByAuthors( - authorSet: AuthorsTopNavPerRelayFilterSet, - since: SincePerRelayMap?, - defaultSince: Long? = null, -): List { - if (authorSet.set.isEmpty()) return emptyList() - - return authorSet.set - .mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterPollAppsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() -} - -fun filterPollAppsByAuthors( - authorSet: MutedAuthorsTopNavPerRelayFilterSet, - since: SincePerRelayMap?, - defaultSince: Long? = null, -): List { - if (authorSet.set.isEmpty()) return emptyList() - - return authorSet.set - .mapNotNull { - if (it.value.authors.isEmpty()) { - null - } else { - filterPollAppsAuthors( - relay = it.key, - authors = it.value.authors, - since = since?.get(it.key)?.time ?: defaultSince, - ) - } - }.flatten() -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsByFollows.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsByFollows.kt deleted file mode 100644 index ddd49e3db..000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsByFollows.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip88PollApps.subassemblies - -import com.vitorpamplona.amethyst.model.topNavFeeds.allFollows.AllFollowsTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter - -fun filterPollAppsByFollows( - followsSet: AllFollowsTopNavPerRelayFilterSet, - since: SincePerRelayMap?, - defaultSince: Long? = null, -): List { - if (followsSet.set.isEmpty()) return emptyList() - - return followsSet.set.flatMap { - val since = since?.get(it.key)?.time ?: defaultSince - val relay = it.key - - listOfNotNull( - it.value.authors?.let { - filterPollAppsAuthors(relay, it, since) - }, - ).flatten() - } -} diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsGlobal.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsGlobal.kt deleted file mode 100644 index e31572d83..000000000 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip88PollApps/subassemblies/FilterPollAppsGlobal.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2025 Vitor Pamplona - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the - * Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.vitorpamplona.amethyst.ui.screen.loggedIn.discover.nip88PollApps.subassemblies - -import com.vitorpamplona.amethyst.model.topNavFeeds.global.GlobalTopNavPerRelayFilterSet -import com.vitorpamplona.amethyst.service.relays.SincePerRelayMap -import com.vitorpamplona.quartz.nip01Core.relay.client.pool.RelayBasedFilter -import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter -import com.vitorpamplona.quartz.nip88Polls.poll.PollEvent -import com.vitorpamplona.quartz.nip89AppHandlers.definition.AppDefinitionEvent - -fun filterPollAppsGlobal( - relays: GlobalTopNavPerRelayFilterSet, - since: SincePerRelayMap?, - defaultSince: Long? = null, -): List { - if (relays.set.isEmpty()) return emptyList() - - return relays.set.flatMap { - val since = since?.get(it.key)?.time ?: defaultSince - listOf( - RelayBasedFilter( - relay = it.key, - filter = - Filter( - kinds = listOf(AppDefinitionEvent.KIND), - tags = mapOf("k" to listOf(PollEvent.KIND.toString())), - limit = 30, - since = since, - ), - ), - ) - } -}