From 5aafcdc97922f80a7d4f83a24605f9ff65625392 Mon Sep 17 00:00:00 2001 From: dusk Date: Sat, 23 Nov 2024 04:42:46 +0300 Subject: [PATCH] feat(gazebot): after posting a note, also reply with errors if any is included --- gazebot/src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gazebot/src/main.rs b/gazebot/src/main.rs index 6bf4447..d735f12 100644 --- a/gazebot/src/main.rs +++ b/gazebot/src/main.rs @@ -55,7 +55,17 @@ impl EventHandler for Handler { let created_note_id = note_resp["noteId"].as_str().expect("note id must be a string"); tracing::info!("succesfully created note with id {created_note_id}"); - let _ = msg.reply(ctx, format!("created log at https://gaze.systems/log?id={created_note_id}")).await; + let mut reply_content = format!("created log at https://gaze.systems/log?id={created_note_id}"); + let errors = note_resp["errors"].as_array().expect("must be array"); + if !errors.is_empty() { + reply_content.push_str("\n\nerrors:"); + for error in errors { + reply_content.push_str("\n--> "); + reply_content.push_str(error.as_str().expect("must be str")); + } + } + + let _ = msg.reply(ctx, reply_content).await; } async fn ready(&self, ctx: Context, ready: Ready) {