Skip to content

Adds support for multiFlag triggers#3

Closed
zer0x64 wants to merge 2 commits intonsec:mainfrom
zer0x64:multiFlags-trigger
Closed

Adds support for multiFlag triggers#3
zer0x64 wants to merge 2 commits intonsec:mainfrom
zer0x64:multiFlags-trigger

Conversation

@zer0x64
Copy link
Copy Markdown
Contributor

@zer0x64 zer0x64 commented Mar 18, 2026

Adds a discourse trigger that requires multiple flags to be submitted to trigger. The optional threshold attributes allow requiring only a certain number of flags instead of all of them.

Note: I do not have a setup to test discourse integration, so while it builds, I have not tested it.

@zer0x64
Copy link
Copy Markdown
Contributor Author

zer0x64 commented Apr 5, 2026

New commit merges "flag" and "multiFlag" into a single trigger type. Currently defined triggers should work as they always did, but now there is only a single code flow

Copy link
Copy Markdown

@OliPro007 OliPro007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have managed to deploy discourse and askgod using docker compose and setting up a test team and some test posts/flags, and this has worked properly (3 flags/tags, threshold 2, the topic appeared after 2 out of the 3 flags mentioned were submitted). Other topics appear correctly, though I haven't done an exhaustive test

Comment thread cmd/askgod-discourse/sync.go Outdated
Comment on lines +107 to +108
Tags []string `yaml:"tags"`
Threshold int64 `yaml:"threshold"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lack of alignment is going to tick off CI :)

Comment thread cmd/askgod-discourse/sync.go Outdated
}
teams = append(teams, team)
}
} else if post.Trigger.Type == "multiFlag" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd call it multi_flag instead as we've generally been doing snake case for API stuff at least

if nTriggers < post.Trigger.Threshold {
continue
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line break here

if int64InSlice(team.AskgodID, askgodFlags[tag]) {
nTriggers++
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line break here

@@ -102,15 +102,34 @@ type post struct {
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should squash this commit into the previous one to make it easier to review as this mostly supersedes the logic from the previous commit

@stgraber
Copy link
Copy Markdown
Member

stgraber commented May 2, 2026

LGTM. I'm currently doing a bunch of spring cleaning on the codebase but I'll then pick this up, fix the few things I noted in review and merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants