cargo fmt
This commit is contained in:
@@ -113,19 +113,17 @@ impl ClientCli {
|
||||
let (mut stream, _) = socket.events().await;
|
||||
while let Some(Ok(socket_event)) = stream.next().await {
|
||||
match socket_event {
|
||||
SocketEvent::Update(event) => {
|
||||
match event.data {
|
||||
EventData::ConversationChanged(conversation) => {
|
||||
println!("Conversation changed: {}", conversation.guid);
|
||||
}
|
||||
EventData::MessageReceived(conversation, message) => {
|
||||
println!(
|
||||
"Message received: msg: {} conversation: {}",
|
||||
message.guid, conversation.guid
|
||||
);
|
||||
}
|
||||
SocketEvent::Update(event) => match event.data {
|
||||
EventData::ConversationChanged(conversation) => {
|
||||
println!("Conversation changed: {}", conversation.guid);
|
||||
}
|
||||
}
|
||||
EventData::MessageReceived(conversation, message) => {
|
||||
println!(
|
||||
"Message received: msg: {} conversation: {}",
|
||||
message.guid, conversation.guid
|
||||
);
|
||||
}
|
||||
},
|
||||
SocketEvent::Pong => {
|
||||
println!("Pong");
|
||||
}
|
||||
|
||||
@@ -54,14 +54,10 @@ pub enum Commands {
|
||||
},
|
||||
|
||||
/// Downloads an attachment from the server to the attachment store. Returns the path to the attachment.
|
||||
DownloadAttachment {
|
||||
attachment_id: String,
|
||||
},
|
||||
DownloadAttachment { attachment_id: String },
|
||||
|
||||
/// Uploads an attachment to the server, returns upload guid.
|
||||
UploadAttachment {
|
||||
path: String,
|
||||
},
|
||||
UploadAttachment { path: String },
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
@@ -100,7 +96,9 @@ impl Commands {
|
||||
text,
|
||||
} => client.enqueue_outgoing_message(conversation_id, text).await,
|
||||
Commands::UploadAttachment { path } => client.upload_attachment(path).await,
|
||||
Commands::DownloadAttachment { attachment_id } => client.download_attachment(attachment_id).await,
|
||||
Commands::DownloadAttachment { attachment_id } => {
|
||||
client.download_attachment(attachment_id).await
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,8 +176,12 @@ impl DaemonCli {
|
||||
text: String,
|
||||
) -> Result<()> {
|
||||
let attachment_guids: Vec<&str> = vec![];
|
||||
let outgoing_message_id =
|
||||
KordophoneRepository::send_message(&self.proxy(), &conversation_id, &text, attachment_guids)?;
|
||||
let outgoing_message_id = KordophoneRepository::send_message(
|
||||
&self.proxy(),
|
||||
&conversation_id,
|
||||
&text,
|
||||
attachment_guids,
|
||||
)?;
|
||||
println!("Outgoing message ID: {}", outgoing_message_id);
|
||||
Ok(())
|
||||
}
|
||||
@@ -244,7 +246,8 @@ impl DaemonCli {
|
||||
KordophoneRepository::download_attachment(&self.proxy(), &attachment_id, false)?;
|
||||
|
||||
// Get attachment info.
|
||||
let attachment_info = KordophoneRepository::get_attachment_info(&self.proxy(), &attachment_id)?;
|
||||
let attachment_info =
|
||||
KordophoneRepository::get_attachment_info(&self.proxy(), &attachment_id)?;
|
||||
let (path, preview_path, downloaded, preview_downloaded) = attachment_info;
|
||||
|
||||
if downloaded {
|
||||
@@ -256,14 +259,18 @@ impl DaemonCli {
|
||||
|
||||
// Attach to the signal that the attachment has been downloaded.
|
||||
let _id = self.proxy().match_signal(
|
||||
move |h: dbus_interface::NetBuzzertKordophoneRepositoryAttachmentDownloadCompleted, _: &Connection, _: &dbus::message::Message| {
|
||||
move |h: dbus_interface::NetBuzzertKordophoneRepositoryAttachmentDownloadCompleted,
|
||||
_: &Connection,
|
||||
_: &dbus::message::Message| {
|
||||
println!("Signal: Attachment downloaded: {}", path);
|
||||
std::process::exit(0);
|
||||
},
|
||||
);
|
||||
|
||||
let _id = self.proxy().match_signal(
|
||||
|h: dbus_interface::NetBuzzertKordophoneRepositoryAttachmentDownloadFailed, _: &Connection, _: &dbus::message::Message| {
|
||||
|h: dbus_interface::NetBuzzertKordophoneRepositoryAttachmentDownloadFailed,
|
||||
_: &Connection,
|
||||
_: &dbus::message::Message| {
|
||||
println!("Signal: Attachment download failed: {}", h.attachment_id);
|
||||
std::process::exit(1);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user