Improved filter for notifications
This commit is contained in:
+17
-2
@@ -68,6 +68,7 @@ import com.vitorpamplona.quartz.events.SearchRelayListEvent
|
|||||||
import com.vitorpamplona.quartz.events.StatusEvent
|
import com.vitorpamplona.quartz.events.StatusEvent
|
||||||
import com.vitorpamplona.quartz.events.TextNoteEvent
|
import com.vitorpamplona.quartz.events.TextNoteEvent
|
||||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||||
|
import kotlinx.coroutines.flow.filter
|
||||||
|
|
||||||
// TODO: Migrate this to a property of AccountVi
|
// TODO: Migrate this to a property of AccountVi
|
||||||
object NostrAccountDataSource : AmethystNostrDataSource("AccountData") {
|
object NostrAccountDataSource : AmethystNostrDataSource("AccountData") {
|
||||||
@@ -179,12 +180,26 @@ object NostrAccountDataSource : AmethystNostrDataSource("AccountData") {
|
|||||||
)
|
)
|
||||||
|
|
||||||
fun createNotificationFilter(): TypedFilter {
|
fun createNotificationFilter(): TypedFilter {
|
||||||
val since =
|
var since =
|
||||||
latestEOSEs.users[account.userProfile()]
|
latestEOSEs.users[account.userProfile()]
|
||||||
?.followList
|
?.followList
|
||||||
?.get(account.defaultNotificationFollowList.value)
|
?.get(account.defaultNotificationFollowList.value)
|
||||||
?.relayList
|
?.relayList
|
||||||
?: account.connectToRelays.value.associate { it.url to EOSETime(TimeUtils.oneWeekAgo()) }
|
?.toMutableMap()
|
||||||
|
|
||||||
|
if (since == null) {
|
||||||
|
since =
|
||||||
|
account.connectToRelays.value
|
||||||
|
.associate { it.url to EOSETime(TimeUtils.oneWeekAgo()) }
|
||||||
|
.toMutableMap()
|
||||||
|
} else {
|
||||||
|
account.connectToRelays.value.forEach {
|
||||||
|
val eose = since.get(it.url)
|
||||||
|
if (eose == null) {
|
||||||
|
since.put(it.url, EOSETime(TimeUtils.oneWeekAgo()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TypedFilter(
|
return TypedFilter(
|
||||||
types = COMMON_FEED_TYPES,
|
types = COMMON_FEED_TYPES,
|
||||||
|
|||||||
Reference in New Issue
Block a user