mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 19:07:09 +02:00
Removes unnecessary code
This commit is contained in:
@@ -2,15 +2,10 @@ package com.vitorpamplona.amethyst.service
|
|||||||
|
|
||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.model.ChatroomKey
|
import com.vitorpamplona.amethyst.model.ChatroomKey
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
|
||||||
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.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 NostrChatroomDataSource : NostrDataSource("ChatroomFeed") {
|
object NostrChatroomDataSource : NostrDataSource("ChatroomFeed") {
|
||||||
@@ -43,26 +38,6 @@ object NostrChatroomDataSource : NostrDataSource("ChatroomFeed") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DOESN'T Load gift wraps here because it is already loaded on Chatroom List.
|
|
||||||
There is no way to filter for gifts only in this conversation.
|
|
||||||
fun createGiftWrapsToMeFilter(): TypedFilter? {
|
|
||||||
val myPeer = withRoom
|
|
||||||
|
|
||||||
return if (myPeer != null) {
|
|
||||||
TypedFilter(
|
|
||||||
types = setOf(FeedType.PRIVATE_DMS),
|
|
||||||
filter = JsonFilter(
|
|
||||||
kinds = listOf(GiftWrapEvent.kind),
|
|
||||||
tags = mapOf("p" to listOf(account.userProfile().pubkeyHex)),
|
|
||||||
since = latestEOSEs.users[account.userProfile()]?.followList?.get(withRoom.hashCode().toString())?.relayList
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun createMessagesFromMeFilter(): TypedFilter? {
|
fun createMessagesFromMeFilter(): TypedFilter? {
|
||||||
val myPeer = withRoom
|
val myPeer = withRoom
|
||||||
|
|
||||||
@@ -81,32 +56,6 @@ object NostrChatroomDataSource : NostrDataSource("ChatroomFeed") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun consume(event: Event, relay: Relay) {
|
|
||||||
if (this::account.isInitialized && 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val inandoutChannel = requestNewChannel { time, relayUrl ->
|
val inandoutChannel = requestNewChannel { time, relayUrl ->
|
||||||
latestEOSEs.addOrUpdate(account.userProfile(), withRoom.hashCode().toString(), relayUrl, time)
|
latestEOSEs.addOrUpdate(account.userProfile(), withRoom.hashCode().toString(), relayUrl, time)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user