Skip to content

Commit d77a2f5

Browse files
authored
Merge pull request #273 from pietroalbini/fix-269
[craterbot] Avoid parsing commands on comment edits/deletions
2 parents 51efff8 + 87280e9 commit d77a2f5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/server/github.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ pub struct User {
124124

125125
#[derive(Deserialize)]
126126
pub struct EventIssueComment {
127+
pub action: String,
127128
pub issue: Issue,
128129
pub comment: Comment,
129130
pub sender: User,

src/server/routes/webhooks/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ fn process_webhook(payload: &[u8], signature: &str, event: &str, data: &Data) ->
2525
"ping" => info!("the webhook is configured correctly!"),
2626
"issue_comment" => {
2727
let p: EventIssueComment = serde_json::from_slice(payload)?;
28+
29+
// Only process "created" events, and ignore when a comment is edited or deleted
30+
if p.action != "created" {
31+
return Ok(());
32+
}
33+
2834
if let Err(e) = process_command(&p.sender.login, &p.comment.body, &p.issue, data) {
2935
Message::new()
3036
.line("rotating_light", format!("**Error:** {}", e))

0 commit comments

Comments
 (0)