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
This commit is contained in:
Graham Christensen 2018-08-09 15:50:54 -04:00
parent 1783e3a0e4
commit 43dc12d984
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
3 changed files with 14 additions and 1 deletions

View file

@ -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,
}

View file

@ -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};

View file

@ -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];