Keeps track of a message's GiftWrap host in order to broadcast later.
This commit is contained in:
@@ -452,7 +452,13 @@ class Account(
|
|||||||
|
|
||||||
fun broadcast(note: Note) {
|
fun broadcast(note: Note) {
|
||||||
note.event?.let {
|
note.event?.let {
|
||||||
Client.send(it)
|
if (it is WrappedEvent && it.host != null) {
|
||||||
|
it.host?.let { hostEvent ->
|
||||||
|
Client.send(hostEvent)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Client.send(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ChatMessageEvent(
|
|||||||
tags: List<List<String>>,
|
tags: List<List<String>>,
|
||||||
content: String,
|
content: String,
|
||||||
sig: HexKey
|
sig: HexKey
|
||||||
) : Event(id, pubKey, createdAt, kind, tags, content, sig), ChatroomKeyable {
|
) : WrappedEvent(id, pubKey, createdAt, kind, tags, content, sig), ChatroomKeyable {
|
||||||
/**
|
/**
|
||||||
* Recepients intended to receive this conversation
|
* Recepients intended to receive this conversation
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -362,6 +362,22 @@ open class Event(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
open class WrappedEvent(
|
||||||
|
id: HexKey,
|
||||||
|
@JsonProperty("pubkey")
|
||||||
|
pubKey: HexKey,
|
||||||
|
@JsonProperty("created_at")
|
||||||
|
createdAt: Long,
|
||||||
|
kind: Int,
|
||||||
|
tags: List<List<String>>,
|
||||||
|
content: String,
|
||||||
|
sig: HexKey
|
||||||
|
) : Event(id, pubKey, createdAt, kind, tags, content, sig) {
|
||||||
|
@Transient
|
||||||
|
var host: Event? = null // host event to broadcast when needed
|
||||||
|
}
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
interface AddressableEvent {
|
interface AddressableEvent {
|
||||||
fun dTag(): String
|
fun dTag(): String
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ class GiftWrapEvent(
|
|||||||
if (cachedInnerEvent.contains(hex)) return cachedInnerEvent[hex]
|
if (cachedInnerEvent.contains(hex)) return cachedInnerEvent[hex]
|
||||||
|
|
||||||
val myInnerEvent = unwrap(privKey = privKey)
|
val myInnerEvent = unwrap(privKey = privKey)
|
||||||
|
if (myInnerEvent is WrappedEvent) {
|
||||||
|
myInnerEvent.host = this
|
||||||
|
}
|
||||||
|
|
||||||
cachedInnerEvent = cachedInnerEvent + Pair(hex, myInnerEvent)
|
cachedInnerEvent = cachedInnerEvent + Pair(hex, myInnerEvent)
|
||||||
return myInnerEvent
|
return myInnerEvent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class SealedGossipEvent(
|
|||||||
tags: List<List<String>>,
|
tags: List<List<String>>,
|
||||||
content: String,
|
content: String,
|
||||||
sig: HexKey
|
sig: HexKey
|
||||||
) : Event(id, pubKey, createdAt, kind, tags, content, sig) {
|
): WrappedEvent(id, pubKey, createdAt, kind, tags, content, sig) {
|
||||||
@Transient
|
@Transient
|
||||||
private var cachedInnerEvent: Map<HexKey, Event?> = mapOf()
|
private var cachedInnerEvent: Map<HexKey, Event?> = mapOf()
|
||||||
|
|
||||||
@@ -30,6 +30,10 @@ class SealedGossipEvent(
|
|||||||
|
|
||||||
val gossip = unseal(privKey = privKey)
|
val gossip = unseal(privKey = privKey)
|
||||||
val event = gossip?.mergeWith(this)
|
val event = gossip?.mergeWith(this)
|
||||||
|
if (event is WrappedEvent) {
|
||||||
|
event.host = host ?: this
|
||||||
|
}
|
||||||
|
|
||||||
cachedInnerEvent = cachedInnerEvent + Pair(hex, event)
|
cachedInnerEvent = cachedInnerEvent + Pair(hex, event)
|
||||||
return event
|
return event
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user