diff --git a/src/collect.rs b/src/collect.rs index 5f95f96..9113b7f 100644 --- a/src/collect.rs +++ b/src/collect.rs @@ -217,7 +217,7 @@ async fn list_all_issues(ctx: &crate::Context) -> anyhow::Result> { ) .all() .await - .context("Failed fetching issue list")?; + .with_context(|| format!("Failed fetching issue list"))?; Ok(issues) } @@ -231,11 +231,11 @@ trait IssueExt { impl IssueExt for Issue { fn get_number(&self) -> anyhow::Result { - self + Ok(self .number .context("Missing issue number")? .try_into() - .context("Failed converting issue number to u32") + .context("Failed converting issue number to u32")?) } fn get_title(&self) -> anyhow::Result { @@ -243,13 +243,13 @@ impl IssueExt for Issue { } fn get_state(&self) -> anyhow::Result { - self.state.context("Issue has no state") + Ok(self.state.context("Issue has no state")?) } fn get_label_names(&self) -> anyhow::Result> { let labels = self.labels.as_ref().context("Issue without labels list")?; let label_names = labels - .iter() + .into_iter() .map(|label| label.name.as_ref().context("Label without name").cloned()) .collect::>>()?; Ok(label_names) diff --git a/src/context.rs b/src/context.rs index 8a9bf23..2ee3933 100644 --- a/src/context.rs +++ b/src/context.rs @@ -56,10 +56,10 @@ impl Context { format!("Could not split repo slug {repo_with_owner:?} into owner and repo") })?; - let server_url = url::Url::parse(server_url).context("Failed parsing server URL")?; + let server_url = url::Url::parse(&server_url).context("Failed parsing server URL")?; let repo_url = server_url - .join(repo_with_owner) + .join(&repo_with_owner) .context("Failed to build server + repo URL")?; let repo_auth_url = { let mut repo_auth_url = repo_url.clone(); diff --git a/src/reminder.rs b/src/reminder.rs index 2c4da90..8d102c1 100644 --- a/src/reminder.rs +++ b/src/reminder.rs @@ -66,8 +66,8 @@ pub async fn remind_all_tasks(ctx: &crate::Context, tasks: &[task::Task]) -> any Ok(()) } -pub const SIGNATURE_BASIC: &str = "\\[TaskBot Comment\\]"; -pub const SIGNATURE_URGENT: &str = "\\[TaskBot Comment (Urgent)\\]"; +pub const SIGNATURE_BASIC: &'static str = "\\[TaskBot Comment\\]"; +pub const SIGNATURE_URGENT: &'static str = "\\[TaskBot Comment (Urgent)\\]"; async fn remind_task( ctx: &crate::Context, @@ -76,14 +76,22 @@ async fn remind_task( batching_interval: BatchingInterval, ) -> anyhow::Result<()> { let body = match (reminder_type, batching_interval) { - (ReminderType::Basic, BatchingInterval::Monthly) => "\ -Beep boop. This task is due this month, go take care of it!".to_string(), - (ReminderType::Basic, BatchingInterval::Weekly) => "\ -Beep boop. This task is due this week, go take care of it!".to_string(), - (ReminderType::Basic, BatchingInterval::OnTheDay) => "\ -Beep boop. This task is due today, go take care of it!".to_string(), - (ReminderType::Urgent, _) => "\ -Hello again. This task is overdue, please take care of it ASAP!".to_string(), + (ReminderType::Basic, BatchingInterval::Monthly) => format!( + "\ +Beep boop. This task is due this month, go take care of it!" + ), + (ReminderType::Basic, BatchingInterval::Weekly) => format!( + "\ +Beep boop. This task is due this week, go take care of it!" + ), + (ReminderType::Basic, BatchingInterval::OnTheDay) => format!( + "\ +Beep boop. This task is due today, go take care of it!" + ), + (ReminderType::Urgent, _) => format!( + "\ +Hello again. This task is overdue, please take care of it ASAP!" + ), }; let signature = match reminder_type { @@ -99,7 +107,7 @@ Hello again. This task is overdue, please take care of it ASAP!".to_string(), &ctx.repo, task.issue_number.into(), forgejo_api::structs::CreateIssueCommentOption { - body, + body: body, updated_at: None, }, ) diff --git a/src/util.rs b/src/util.rs index a8c6b18..81e1e47 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,7 +1,5 @@ pub fn time_to_jiff(t: time::OffsetDateTime) -> jiff::Zoned { - let tz = jiff::tz::TimeZone::fixed( - jiff::tz::Offset::from_seconds(t.offset().whole_seconds()).unwrap(), - ); + let tz = jiff::tz::TimeZone::fixed(jiff::tz::offset(t.offset().whole_hours())); jiff::Timestamp::new(t.unix_timestamp(), 0) .unwrap()