mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 20:26:33 +02:00
Moves GiftCard filter to Account filters and not Chats
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.vitorpamplona.amethyst.service
|
package com.vitorpamplona.amethyst.service
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.service.model.*
|
import com.vitorpamplona.amethyst.service.model.*
|
||||||
import com.vitorpamplona.amethyst.service.model.BadgeAwardEvent
|
import com.vitorpamplona.amethyst.service.model.BadgeAwardEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.BadgeProfilesEvent
|
import com.vitorpamplona.amethyst.service.model.BadgeProfilesEvent
|
||||||
@@ -111,16 +112,51 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun createGiftWrapsToMeFilter() = TypedFilter(
|
||||||
|
types = COMMON_FEED_TYPES,
|
||||||
|
filter = JsonFilter(
|
||||||
|
kinds = listOf(GiftWrapEvent.kind),
|
||||||
|
tags = mapOf("p" to listOf(account.userProfile().pubkeyHex))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val accountChannel = requestNewChannel { time, relayUrl ->
|
val accountChannel = requestNewChannel { time, relayUrl ->
|
||||||
latestEOSEs.addOrUpdate(account.userProfile(), account.defaultNotificationFollowList, relayUrl, time)
|
latestEOSEs.addOrUpdate(account.userProfile(), account.defaultNotificationFollowList, relayUrl, time)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun consume(event: Event, relay: Relay) {
|
||||||
|
if (LocalCache.justVerify(event)) {
|
||||||
|
if (event is GiftWrapEvent) {
|
||||||
|
val privateKey = NostrChatroomListDataSource.account.keyPair.privKey
|
||||||
|
if (privateKey != null) {
|
||||||
|
event.cachedGift(privateKey)?.let {
|
||||||
|
this.consume(it, relay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event is SealedGossipEvent) {
|
||||||
|
val privateKey = NostrChatroomListDataSource.account.keyPair.privKey
|
||||||
|
if (privateKey != null) {
|
||||||
|
event.cachedGossip(privateKey)?.let {
|
||||||
|
LocalCache.justConsume(it, relay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't store sealed gossips to avoid rebroadcasting by mistake.
|
||||||
|
} else {
|
||||||
|
LocalCache.justConsume(event, relay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun updateChannelFilters() {
|
override fun updateChannelFilters() {
|
||||||
// gets everthing about the user logged in
|
// gets everthing about the user logged in
|
||||||
accountChannel.typedFilters = listOf(
|
accountChannel.typedFilters = listOf(
|
||||||
createAccountMetadataFilter(),
|
createAccountMetadataFilter(),
|
||||||
createAccountContactListFilter(),
|
createAccountContactListFilter(),
|
||||||
createNotificationFilter(),
|
createNotificationFilter(),
|
||||||
|
createGiftWrapsToMeFilter(),
|
||||||
createAccountReportsFilter(),
|
createAccountReportsFilter(),
|
||||||
createAccountAcceptedAwardsFilter(),
|
createAccountAcceptedAwardsFilter(),
|
||||||
createAccountBookmarkListFilter(),
|
createAccountBookmarkListFilter(),
|
||||||
|
@@ -1,19 +1,14 @@
|
|||||||
package com.vitorpamplona.amethyst.service
|
package com.vitorpamplona.amethyst.service
|
||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
|
||||||
import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent
|
import com.vitorpamplona.amethyst.service.model.ChannelCreateEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.ChannelMessageEvent
|
import com.vitorpamplona.amethyst.service.model.ChannelMessageEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.ChannelMetadataEvent
|
import com.vitorpamplona.amethyst.service.model.ChannelMetadataEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.Event
|
|
||||||
import com.vitorpamplona.amethyst.service.model.GiftWrapEvent
|
|
||||||
import com.vitorpamplona.amethyst.service.model.PrivateDmEvent
|
import com.vitorpamplona.amethyst.service.model.PrivateDmEvent
|
||||||
import com.vitorpamplona.amethyst.service.model.SealedGossipEvent
|
|
||||||
import com.vitorpamplona.amethyst.service.relays.COMMON_FEED_TYPES
|
import com.vitorpamplona.amethyst.service.relays.COMMON_FEED_TYPES
|
||||||
import com.vitorpamplona.amethyst.service.relays.EOSEAccount
|
import com.vitorpamplona.amethyst.service.relays.EOSEAccount
|
||||||
import com.vitorpamplona.amethyst.service.relays.FeedType
|
import com.vitorpamplona.amethyst.service.relays.FeedType
|
||||||
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.TypedFilter
|
import com.vitorpamplona.amethyst.service.relays.TypedFilter
|
||||||
|
|
||||||
object NostrChatroomListDataSource : NostrDataSource("MailBoxFeed") {
|
object NostrChatroomListDataSource : NostrDataSource("MailBoxFeed") {
|
||||||
@@ -25,7 +20,7 @@ object NostrChatroomListDataSource : NostrDataSource("MailBoxFeed") {
|
|||||||
fun createMessagesToMeFilter() = TypedFilter(
|
fun createMessagesToMeFilter() = TypedFilter(
|
||||||
types = setOf(FeedType.PRIVATE_DMS),
|
types = setOf(FeedType.PRIVATE_DMS),
|
||||||
filter = JsonFilter(
|
filter = JsonFilter(
|
||||||
kinds = listOf(PrivateDmEvent.kind, GiftWrapEvent.kind),
|
kinds = listOf(PrivateDmEvent.kind),
|
||||||
tags = mapOf("p" to listOf(account.userProfile().pubkeyHex)),
|
tags = mapOf("p" to listOf(account.userProfile().pubkeyHex)),
|
||||||
since = latestEOSEs.users[account.userProfile()]?.followList?.get(chatRoomList)?.relayList
|
since = latestEOSEs.users[account.userProfile()]?.followList?.get(chatRoomList)?.relayList
|
||||||
)
|
)
|
||||||
@@ -97,32 +92,6 @@ object NostrChatroomListDataSource : NostrDataSource("MailBoxFeed") {
|
|||||||
latestEOSEs.addOrUpdate(account.userProfile(), chatRoomList, relayUrl, time)
|
latestEOSEs.addOrUpdate(account.userProfile(), chatRoomList, relayUrl, time)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun consume(event: Event, relay: Relay) {
|
|
||||||
if (LocalCache.justVerify(event)) {
|
|
||||||
if (event is GiftWrapEvent) {
|
|
||||||
val privateKey = account.keyPair.privKey
|
|
||||||
if (privateKey != null) {
|
|
||||||
event.cachedGift(privateKey)?.let {
|
|
||||||
this.consume(it, relay)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event is SealedGossipEvent) {
|
|
||||||
val privateKey = account.keyPair.privKey
|
|
||||||
if (privateKey != null) {
|
|
||||||
event.cachedGossip(privateKey)?.let {
|
|
||||||
LocalCache.justConsume(it, relay)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't store sealed gossips to avoid rebroadcasting by mistake.
|
|
||||||
} else {
|
|
||||||
LocalCache.justConsume(event, relay)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateChannelFilters() {
|
override fun updateChannelFilters() {
|
||||||
val list = listOf(
|
val list = listOf(
|
||||||
createMessagesToMeFilter(),
|
createMessagesToMeFilter(),
|
||||||
|
Reference in New Issue
Block a user