From 43dc12d984458b5e2e0aebdb135182308d4c9f59 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 9 Aug 2018 15:50:54 -0400 Subject: [PATCH] Don't trigger events on deleted comments According to https://developer.github.com/v3/activity/events/types/#issuecommentevent we should just filter out delete actions. Closes #156 --- ofborg/src/ghevent/issuecomment.rs | 9 +++++++++ ofborg/src/ghevent/mod.rs | 2 +- ofborg/src/tasks/githubcommentfilter.rs | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ofborg/src/ghevent/issuecomment.rs b/ofborg/src/ghevent/issuecomment.rs index e487127..f358942 100644 --- a/ofborg/src/ghevent/issuecomment.rs +++ b/ofborg/src/ghevent/issuecomment.rs @@ -2,7 +2,16 @@ use ofborg::ghevent::{Comment, Repository, Issue}; #[derive(Serialize, Deserialize, Debug)] pub struct IssueComment { + pub action: IssueCommentAction, pub comment: Comment, pub repository: Repository, pub issue: Issue, } + +#[derive(Serialize, Deserialize, Debug, PartialEq)] +#[serde(rename_all="snake_case")] +pub enum IssueCommentAction { + Created, + Edited, + Deleted, +} diff --git a/ofborg/src/ghevent/mod.rs b/ofborg/src/ghevent/mod.rs index d50c400..c38ea27 100644 --- a/ofborg/src/ghevent/mod.rs +++ b/ofborg/src/ghevent/mod.rs @@ -2,6 +2,6 @@ mod common; mod issuecomment; mod pullrequestevent; -pub use self::issuecomment::IssueComment; +pub use self::issuecomment::{IssueComment,IssueCommentAction}; pub use self::pullrequestevent::{PullRequest, PullRequestEvent, PullRequestAction, PullRequestState}; pub use self::common::{Issue, Repository, User, Comment}; diff --git a/ofborg/src/tasks/githubcommentfilter.rs b/ofborg/src/tasks/githubcommentfilter.rs index 06f5035..54ed984 100644 --- a/ofborg/src/tasks/githubcommentfilter.rs +++ b/ofborg/src/tasks/githubcommentfilter.rs @@ -50,6 +50,10 @@ impl worker::SimpleWorker for GitHubCommentWorker { } fn consumer(&mut self, job: &ghevent::IssueComment) -> worker::Actions { + if job.action == ghevent::IssueCommentAction::Deleted { + return vec![worker::Action::Ack]; + } + let instructions = commentparser::parse(&job.comment.body); if instructions == None { return vec![worker::Action::Ack];