basic w30 sending and receiving

This commit is contained in:
B. Petersen
2021-11-22 18:20:34 +01:00
committed by bjoern
parent 41f9314e2a
commit de20e4c9dd
16 changed files with 810 additions and 7 deletions

View File

@@ -37,6 +37,7 @@ use crate::mimeparser::SystemMessage;
use crate::param::{Param, Params};
use crate::peerstate::{Peerstate, PeerstateVerifiedStatus};
use crate::stock_str;
use crate::w30::W30_SUFFIX;
/// An chat item, such as a message or a marker.
#[derive(Debug, Copy, Clone)]
@@ -645,6 +646,9 @@ impl ChatId {
.await?
.context("no file stored in params")?;
msg.param.set(Param::File, blob.as_name());
if blob.suffix() == Some(W30_SUFFIX) {
msg.viewtype = Viewtype::W30;
}
}
}
@@ -1796,6 +1800,7 @@ pub(crate) fn msgtype_has_file(msgtype: Viewtype) -> bool {
Viewtype::Video => true,
Viewtype::File => true,
Viewtype::VideochatInvitation => false,
Viewtype::W30 => true,
}
}
@@ -1836,6 +1841,11 @@ async fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<()> {
msg.param.set(Param::MimeType, mime);
}
}
if msg.viewtype == Viewtype::W30 && blob.suffix() != Some(W30_SUFFIX) {
bail!("w30 message {} does not have suffix {}", blob, W30_SUFFIX);
}
info!(
context,
"Attaching \"{}\" for message type #{}.",