diff --git a/src/hooks/forgejo.rs b/src/hooks/forgejo.rs
index 90d2519..983233d 100644
--- a/src/hooks/forgejo.rs
+++ b/src/hooks/forgejo.rs
@@ -13,7 +13,9 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-use crate::hooks::types::{Commit, Hook, Issue, IssueAction, Push, Repository, User};
+use crate::hooks::types::{
+ Commit, Hook, Issue, IssueAction, IssueAttrs, Note, Push, Repository, User,
+};
use crate::Error;
pub use ::forgejo_hooks::{Hook as ForgejoHook, Issue as FjIssue, IssueAction as FjIssueAction};
@@ -21,7 +23,7 @@ pub use ::forgejo_hooks::{Hook as ForgejoHook, Issue as FjIssue, IssueAction as
impl From for IssueAction {
fn from(other: FjIssueAction) -> IssueAction {
match other {
- FjIssueAction::Opened => IssueAction::Open,
+ FjIssueAction::Created | FjIssueAction::Opened => IssueAction::Open,
FjIssueAction::Edited => IssueAction::Update,
}
}
@@ -44,6 +46,30 @@ impl From for Issue {
}
}
+impl From for Note {
+ fn from(other: FjIssue) -> Note {
+ Note {
+ issue: Some(IssueAttrs {
+ id: other.issue.number as u64,
+ title: other.issue.title,
+ }),
+ commit: None,
+ merge_request: None,
+ snippet: false,
+ author: User {
+ name: other.issue.user.login,
+ },
+ repository: Repository {
+ name: other.repository.name,
+ },
+ url: other
+ .comment
+ .map(|c| c.html_url)
+ .unwrap_or(other.issue.html_url),
+ }
+ }
+}
+
impl TryFrom for Hook {
type Error = Error;
@@ -68,7 +94,15 @@ impl TryFrom for Hook {
name: push.pusher.username,
},
}),
- ForgejoHook::Issue(issue) => Hook::Issue(issue.into()),
+ ForgejoHook::Issue(issue) => {
+ log::debug!("FOO: issue: {:?}", issue);
+ // TODO: Handle is_pull
+ if issue.comment.is_none() {
+ Hook::Issue(issue.into())
+ } else {
+ Hook::Note(issue.into())
+ }
+ }
_ => return Err(Error::UnsupportedHookConversion),
})
}