diff --git a/Cargo.toml b/Cargo.toml index 474304e..288bc61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ hmac = "0.12" sha2 = "0.10" hex = "0.4" camino = { version = "1.2", features = ["serde1"] } +chrono = { version = "0.4", default-features = false } [patch.crates-io] forgejo-hooks = { path = "forgejo-hooks" } diff --git a/Changelog b/Changelog index 28f3949..9df20c6 100644 --- a/Changelog +++ b/Changelog @@ -8,6 +8,7 @@ Version NEXT: - Add 'rejoin' command to rejoin (leave/join) all rooms * Added: - Add PartialEq on hook types. + - Add `updated_at` parameter to `MergeRequest` and `Issue` hook types. Version 0.2.0: 2023-08-23 Maxime “pep” Buquet diff --git a/src/hooks/forgejo.rs b/src/hooks/forgejo.rs index 01e6aad..9a32686 100644 --- a/src/hooks/forgejo.rs +++ b/src/hooks/forgejo.rs @@ -19,6 +19,7 @@ use crate::hooks::types::{ }; pub use ::forgejo_hooks::{Hook as ForgejoHook, Issue as FjIssue, IssueAction as FjIssueAction}; +use chrono::Utc; impl From for IssueAction { fn from(other: FjIssueAction) -> IssueAction { @@ -43,6 +44,7 @@ impl From for Issue { name: other.repository.name, }, url: Some(other.issue.html_url), + updated_at: other.issue.updated_at.unwrap_or(Utc::now()), } } } diff --git a/src/hooks/gitlab.rs b/src/hooks/gitlab.rs index 1b9feb4..8972e15 100644 --- a/src/hooks/gitlab.rs +++ b/src/hooks/gitlab.rs @@ -79,6 +79,7 @@ impl From for Issue { id: other.object_attributes.iid, title: other.object_attributes.title, url: other.object_attributes.url, + updated_at: other.object_attributes.updated_at.as_ref().clone(), } } } @@ -121,6 +122,7 @@ impl From for MergeRequest { id: other.object_attributes.iid, title: other.object_attributes.title, url: other.object_attributes.url, + updated_at: other.object_attributes.updated_at.as_ref().clone(), } } } diff --git a/src/hooks/types.rs b/src/hooks/types.rs index 11cb374..6525fe2 100644 --- a/src/hooks/types.rs +++ b/src/hooks/types.rs @@ -13,6 +13,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +use chrono::{DateTime, Utc}; + /// Defines a generic user that can be used for many purposes. #[derive(Debug, Clone, PartialEq)] pub struct User { @@ -66,6 +68,7 @@ pub struct Issue { pub id: u64, pub title: String, pub url: Option, + pub updated_at: DateTime, } #[derive(Debug, Clone, PartialEq)] @@ -95,6 +98,7 @@ pub struct MergeRequest { pub id: u64, pub title: String, pub url: Option, + pub updated_at: DateTime, } #[derive(Debug, Clone, PartialEq)]