mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
fix: fix reception of realtime advertisements
This commit is contained in:
@@ -1442,33 +1442,59 @@ async fn add_parts(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(node_addr) = mime_parser.get_header(HeaderDef::IrohNodeAddr) {
|
if let Some(node_addr) = mime_parser.get_header(HeaderDef::IrohNodeAddr) {
|
||||||
|
chat_id = DC_CHAT_ID_TRASH;
|
||||||
match serde_json::from_str::<NodeAddr>(node_addr).context("Failed to parse node address") {
|
match serde_json::from_str::<NodeAddr>(node_addr).context("Failed to parse node address") {
|
||||||
Ok(node_addr) => {
|
Ok(node_addr) => {
|
||||||
info!(context, "Adding iroh peer with address {node_addr:?}.");
|
info!(context, "Adding iroh peer with address {node_addr:?}.");
|
||||||
let instance_id = parent.context("Failed to get parent message")?.id;
|
match mime_parser.get_header(HeaderDef::InReplyTo) {
|
||||||
context.emit_event(EventType::WebxdcRealtimeAdvertisementReceived {
|
Some(in_reply_to) => match rfc724_mid_exists(context, in_reply_to).await? {
|
||||||
msg_id: instance_id,
|
Some((instance_id, _ts_sent)) => {
|
||||||
});
|
context.emit_event(EventType::WebxdcRealtimeAdvertisementReceived {
|
||||||
if let Some(topic) = get_iroh_topic_for_msg(context, instance_id).await? {
|
msg_id: instance_id,
|
||||||
let node_id = node_addr.node_id;
|
});
|
||||||
let relay_server = node_addr.relay_url().map(|relay| relay.as_str());
|
if let Some(topic) =
|
||||||
iroh_add_peer_for_topic(context, instance_id, topic, node_id, relay_server)
|
get_iroh_topic_for_msg(context, instance_id).await?
|
||||||
.await?;
|
{
|
||||||
if context
|
let node_id = node_addr.node_id;
|
||||||
.get_config_bool(Config::WebxdcRealtimeEnabled)
|
let relay_server =
|
||||||
.await?
|
node_addr.relay_url().map(|relay| relay.as_str());
|
||||||
{
|
iroh_add_peer_for_topic(
|
||||||
let iroh = context.get_or_try_init_peer_channel().await?;
|
context,
|
||||||
iroh.maybe_add_gossip_peers(topic, vec![node_addr]).await?;
|
instance_id,
|
||||||
|
topic,
|
||||||
|
node_id,
|
||||||
|
relay_server,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
if context
|
||||||
|
.get_config_bool(Config::WebxdcRealtimeEnabled)
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
let iroh = context.get_or_try_init_peer_channel().await?;
|
||||||
|
iroh.maybe_add_gossip_peers(topic, vec![node_addr]).await?;
|
||||||
|
}
|
||||||
|
info!(context, "Added iroh peer to the topic of {instance_id}.");
|
||||||
|
} else {
|
||||||
|
warn!(
|
||||||
|
context,
|
||||||
|
"Could not add iroh peer because {instance_id} has no topic."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
warn!(
|
||||||
|
context,
|
||||||
|
"Cannot add iroh peer because WebXDC instance does not exist."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
warn!(
|
||||||
|
context,
|
||||||
|
"Cannot add iroh peer because the message has no In-Reply-To."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
info!(context, "Added iroh peer to the topic of {instance_id}.");
|
|
||||||
} else {
|
|
||||||
warn!(
|
|
||||||
context,
|
|
||||||
"Could not add iroh peer because {instance_id} has no topic."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
chat_id = DC_CHAT_ID_TRASH;
|
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(context, "Couldn't parse NodeAddr: {err:#}.");
|
warn!(context, "Couldn't parse NodeAddr: {err:#}.");
|
||||||
|
|||||||
Reference in New Issue
Block a user