fix indentations in macro

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
ゆめ 2024-09-05 00:22:41 -05:00
parent e087326755
commit f0f7542332
No known key found for this signature in database

View file

@ -90,33 +90,34 @@ impl MatrixClient {
match $msg {
$(
MessageType::$variant(file) => {
Ok(Some(Box::pin(
async move {
let src = match &file.source {
MediaSource::Plain(s) => s,
MediaSource::Encrypted(e) => &e.url,
};
let filename = file.filename.as_deref().map(|s| s.to_string()).unwrap_or(file.body.clone());
let url = mxc_url_to_https(src.as_str(), self.client.homeserver().as_str());
let resp = client.get(&url).send().await?;
let body = resp.bytes_stream();
Ok(FileStream {
filename,
url,
stream: match &file.source {
MediaSource::Plain(_) => {
Box::pin(body.map_err(DumpError::from)) as Pin<Box<dyn TryStream<Ok = Bytes, Error = DumpError, Item = Result<Bytes, DumpError>> + Send>>
Ok(Some(Box::pin(
async move {
let src = match &file.source {
MediaSource::Plain(s) => s,
MediaSource::Encrypted(e) => &e.url,
};
let filename = file.filename.as_deref().map(|s| s.to_string()).unwrap_or(file.body.clone());
let url = mxc_url_to_https(src.as_str(), self.client.homeserver().as_str());
let resp = client.get(&url).send().await?;
let body = resp.bytes_stream();
Ok(FileStream {
filename,
url,
stream: match &file.source {
MediaSource::Plain(_) => {
Box::pin(body.map_err(DumpError::from))
}
MediaSource::Encrypted(e) => Box::pin(decrypt_file(e.as_ref(), body).await?.map_ok(|v| Bytes::from(v)).map_err(
|e| match e {
ErrOrWrongHash::Err(e) => e.into(),
ErrOrWrongHash::WrongHash => DumpError::HashMismatch,
},
))
}})
}
MediaSource::Encrypted(e) => Box::pin(decrypt_file(e.as_ref(), body).await?.map_ok(|v| Bytes::from(v)).map_err(
|e| match e {
ErrOrWrongHash::Err(e) => e.into(),
ErrOrWrongHash::WrongHash => DumpError::HashMismatch,
},
)) as Pin<Box<dyn TryStream<Ok = Bytes, Error = DumpError, Item = Result<Bytes, DumpError>> + Send>>,
}
})
})))}
)*
)))
}
)*
_ => Ok(None),
}
};