List relays in Private DMs

pull/94/head
Vitor Pamplona 2023-02-06 18:15:18 -05:00
rodzic ba5eca648f
commit d252297ba4
3 zmienionych plików z 12 dodań i 6 usunięć

Wyświetl plik

@ -242,7 +242,7 @@ class Account(
advertiseNip18 = false
)
Client.send(signedEvent)
LocalCache.consume(signedEvent)
LocalCache.consume(signedEvent, null)
}
fun sendCreateNewChannel(name: String, about: String, picture: String) {

Wyświetl plik

@ -175,13 +175,18 @@ object LocalCache {
}
}
fun consume(event: PrivateDmEvent) {
fun consume(event: PrivateDmEvent, relay: Relay?) {
val note = getOrCreateNote(event.id.toHex())
val author = getOrCreateUser(event.pubKey.toHexKey())
if (relay != null) {
author.addRelay(relay, event.createdAt)
note.addRelay(relay)
}
// Already processed this event.
if (note.event != null) return
val author = getOrCreateUser(event.pubKey.toHexKey())
val recipient = event.recipientPubKey?.let { getOrCreateUser(it.toHexKey()) }
//Log.d("PM", "${author.toBestDisplayName()} to ${recipient?.toBestDisplayName()}")
@ -356,15 +361,16 @@ object LocalCache {
val note = getOrCreateNote(event.id.toHex())
channel.addNote(note)
val author = getOrCreateUser(event.pubKey.toHexKey())
if (relay != null) {
note.author?.addRelay(relay, event.createdAt)
author.addRelay(relay, event.createdAt)
note.addRelay(relay)
}
// Already processed this event.
if (note.event != null) return
val author = getOrCreateUser(event.pubKey.toHexKey())
val mentions = event.mentions.map { getOrCreateUser(it) }
val replyTo = event.replyTos
.map { getOrCreateNote(it) }

Wyświetl plik

@ -56,7 +56,7 @@ abstract class NostrDataSource<T>(val debugName: String) {
is TextNoteEvent -> LocalCache.consume(event, relay)
is RecommendRelayEvent -> LocalCache.consume(event)
is ContactListEvent -> LocalCache.consume(event)
is PrivateDmEvent -> LocalCache.consume(event)
is PrivateDmEvent -> LocalCache.consume(event, relay)
is DeletionEvent -> LocalCache.consume(event)
else -> when (event.kind) {
RepostEvent.kind -> {