mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
refactor: generate topic inside create_iroh_header()
This commit is contained in:
@@ -20,6 +20,7 @@ use crate::e2ee::EncryptHelper;
|
|||||||
use crate::ephemeral::Timer as EphemeralTimer;
|
use crate::ephemeral::Timer as EphemeralTimer;
|
||||||
use crate::headerdef::HeaderDef;
|
use crate::headerdef::HeaderDef;
|
||||||
use crate::html::new_html_mimepart;
|
use crate::html::new_html_mimepart;
|
||||||
|
use crate::location;
|
||||||
use crate::message::{self, Message, MsgId, Viewtype};
|
use crate::message::{self, Message, MsgId, Viewtype};
|
||||||
use crate::mimeparser::SystemMessage;
|
use crate::mimeparser::SystemMessage;
|
||||||
use crate::param::Param;
|
use crate::param::Param;
|
||||||
@@ -32,7 +33,6 @@ use crate::tools::{
|
|||||||
create_outgoing_rfc724_mid, create_smeared_timestamp, remove_subject_prefix, time,
|
create_outgoing_rfc724_mid, create_smeared_timestamp, remove_subject_prefix, time,
|
||||||
};
|
};
|
||||||
use crate::webxdc::StatusUpdateSerial;
|
use crate::webxdc::StatusUpdateSerial;
|
||||||
use crate::{location, peer_channels};
|
|
||||||
|
|
||||||
// attachments of 25 mb brutto should work on the majority of providers
|
// attachments of 25 mb brutto should work on the majority of providers
|
||||||
// (brutto examples: web.de=50, 1&1=40, t-online.de=32, gmail=25, posteo=50, yahoo=25, all-inkl=100).
|
// (brutto examples: web.de=50, 1&1=40, t-online.de=32, gmail=25, posteo=50, yahoo=25, all-inkl=100).
|
||||||
@@ -1387,8 +1387,7 @@ impl MimeFactory {
|
|||||||
let json = msg.param.get(Param::Arg).unwrap_or_default();
|
let json = msg.param.get(Param::Arg).unwrap_or_default();
|
||||||
parts.push(context.build_status_update_part(json));
|
parts.push(context.build_status_update_part(json));
|
||||||
} else if msg.viewtype == Viewtype::Webxdc {
|
} else if msg.viewtype == Viewtype::Webxdc {
|
||||||
let topic = peer_channels::create_random_topic();
|
headers.push(create_iroh_header(context, msg.id).await?);
|
||||||
headers.push(create_iroh_header(context, topic, msg.id).await?);
|
|
||||||
if let (Some(json), _) = context
|
if let (Some(json), _) = context
|
||||||
.render_webxdc_status_update_object(
|
.render_webxdc_status_update_object(
|
||||||
msg.id,
|
msg.id,
|
||||||
|
|||||||
@@ -419,15 +419,15 @@ pub async fn leave_webxdc_realtime(ctx: &Context, msg_id: MsgId) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn create_random_topic() -> TopicId {
|
/// Creates a new random gossip topic.
|
||||||
|
fn create_random_topic() -> TopicId {
|
||||||
TopicId::from_bytes(rand::random())
|
TopicId::from_bytes(rand::random())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn create_iroh_header(
|
/// Creates `Iroh-Gossip-Header` with a new random topic
|
||||||
ctx: &Context,
|
/// and stores the topic for the message.
|
||||||
topic: TopicId,
|
pub(crate) async fn create_iroh_header(ctx: &Context, msg_id: MsgId) -> Result<Header> {
|
||||||
msg_id: MsgId,
|
let topic = create_random_topic();
|
||||||
) -> Result<Header> {
|
|
||||||
insert_topic_stub(ctx, msg_id, topic).await?;
|
insert_topic_stub(ctx, msg_id, topic).await?;
|
||||||
Ok(Header::new(
|
Ok(Header::new(
|
||||||
HeaderDef::IrohGossipTopic.get_headername().to_string(),
|
HeaderDef::IrohGossipTopic.get_headername().to_string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user