add self to topic and add pubkey

This commit is contained in:
Sebastian Klähn
2024-01-26 15:25:31 +01:00
parent 820a4b9357
commit f5a7a22239
2 changed files with 25 additions and 11 deletions

View File

@@ -1284,8 +1284,8 @@ impl<'a> MimeFactory<'a> {
self.sync_ids_to_delete = Some(ids.to_string()); self.sync_ids_to_delete = Some(ids.to_string());
} else if command == SystemMessage::WebxdcStatusUpdate { } else if command == SystemMessage::WebxdcStatusUpdate {
let json = self.msg.param.get(Param::Arg).unwrap_or_default(); let json = self.msg.param.get(Param::Arg).unwrap_or_default();
parts.push(context.build_status_update_part(json));
} else if self.msg.viewtype == Viewtype::Webxdc { if json.find("gossip_topic").is_some() {
if let Some(ref endpoint) = *context.endpoint.lock().await { if let Some(ref endpoint) = *context.endpoint.lock().await {
// Add iroh NodeAddr to headers so peers can connect to us. // Add iroh NodeAddr to headers so peers can connect to us.
let node_addr = endpoint.my_addr().await.unwrap(); let node_addr = endpoint.my_addr().await.unwrap();
@@ -1294,7 +1294,9 @@ impl<'a> MimeFactory<'a> {
serde_json::to_string(&node_addr)?, serde_json::to_string(&node_addr)?,
)); ));
} }
}
parts.push(context.build_status_update_part(json));
} else if self.msg.viewtype == Viewtype::Webxdc {
if let Some(json) = context if let Some(json) = context
.render_webxdc_status_update_object(self.msg.id, None) .render_webxdc_status_update_object(self.msg.id, None)
.await? .await?

View File

@@ -505,7 +505,7 @@ impl Context {
.sql .sql
.query_row_optional( .query_row_optional(
"SELECT 1 FROM iroh_gossip_peers WHERE topic=?", "SELECT 1 FROM iroh_gossip_peers WHERE topic=?",
(topic,), (topic.as_bytes(),),
|_| Ok(()), |_| Ok(()),
) )
.await .await
@@ -520,8 +520,20 @@ impl Context {
if !topic_exists { if !topic_exists {
info!( info!(
self, self,
"Gossip topic {topic} does not exist, sending over smpt", "Gossip topic {topic} does not exist, sending over smtp",
); );
let addr = self
.endpoint
.lock()
.await
.as_ref()
.unwrap()
.my_addr()
.await
.unwrap();
self.add_peer_for_topic(instance_msg_id, topic, addr.node_id)
.await?;
ephemeral = false; ephemeral = false;
} else { } else {
if let Some(ref gossip) = *self.gossip.lock().await { if let Some(ref gossip) = *self.gossip.lock().await {