Main: Allow downloading unencrypted media from positional mxc url argument
This commit is contained in:
parent
db19efbede
commit
e4cecf1bf5
1 changed files with 13 additions and 2 deletions
15
src/main.rs
15
src/main.rs
|
@ -9,7 +9,7 @@ use log::{info, debug, error};
|
|||
use serde::Deserialize;
|
||||
use rustyline_async::{Readline, ReadlineEvent};
|
||||
|
||||
use matrix_sdk::{matrix_auth::{MatrixSession, MatrixSessionTokens}, ruma::{api::client::{authenticated_media, media}, device_id, user_id}, Client, SessionMeta};
|
||||
use matrix_sdk::{matrix_auth::{MatrixSession, MatrixSessionTokens}, ruma::{api::client::{authenticated_media, media}, device_id, user_id, OwnedMxcUri}, Client, SessionMeta};
|
||||
use matrix_sdk::ruma::events::room::{MediaSource, message::{MessageType, RoomMessageEventContent}};
|
||||
|
||||
// NOTE: This has been stolen from the matrix-rust-sdk to patch out checks for authenticated media
|
||||
|
@ -155,6 +155,8 @@ struct Arguments {
|
|||
/// Homeserver URL or Name
|
||||
#[clap(long, env)]
|
||||
server: Option<String>,
|
||||
|
||||
mxc_url: Option<String>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
@ -162,9 +164,18 @@ async fn main() -> Result<()> {
|
|||
env_logger::init_from_env(env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "matrix_media_event_decrypt=debug"));
|
||||
|
||||
let Arguments {
|
||||
server
|
||||
server,
|
||||
mxc_url,
|
||||
} = Arguments::parse();
|
||||
|
||||
if mxc_url.is_some() {
|
||||
if let Err(error) = process_media(MediaSource::Plain(OwnedMxcUri::from(mxc_url.unwrap())), None, server).await {
|
||||
error!("Unable to process media: {}", error);
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
info!("Enter decrypted event source, confirm with Ctrl+D");
|
||||
|
||||
let (mut readline, mut _stdout) = Readline::new("> ".to_owned()).unwrap();
|
||||
|
|
Loading…
Reference in a new issue