-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uik: Add
pending_signals
table (#3959)
* Add signal message handling and enforce limits - Introduced PendingSignal struct and related DB schema - Defined and imposed new limits for pending signals - Added new signal message types, enums, and SQL queries - Implemented action channel verification - Revised existing code to handle new signal message types and limits - Compiled and executed conditional rules for actions * revert version change * Enhance email and webhook destination configuration - Added `IsDynamicAction` and `DynamicParams` to email and webhook destinations for flexible parameter handling - Removed unused `ActionResult` struct from integration key module * regen * fix dest creation * drop funcs on migrate down * gen * remove limit rows on migrate down
- Loading branch information
1 parent
996121e
commit a0497eb
Showing
16 changed files
with
525 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package uik | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/expr-lang/expr" | ||
"github.com/expr-lang/expr/vm" | ||
"github.com/target/goalert/integrationkey" | ||
) | ||
|
||
func CompileRule(cond string, actions []integrationkey.Action) (*vm.Program, error) { | ||
var actionExpr []string | ||
for _, a := range actions { | ||
var params []string | ||
for k, v := range a.DynamicParams { | ||
params = append(params, fmt.Sprintf(`%s: string(%s)`, strconv.Quote(k), v)) | ||
} | ||
|
||
actionExpr = append(actionExpr, fmt.Sprintf(`{ %s }`, strings.Join(params, ", "))) | ||
} | ||
|
||
src := "[" + strings.Join(actionExpr, ",") + "]" | ||
if cond != "" { | ||
src = fmt.Sprintf(`string(%s) == "true" ? %s : nil`, cond, src) | ||
} | ||
|
||
return expr.Compile(src, expr.AsKind(reflect.Slice), expr.AllowUndefinedVariables(), expr.Optimize(true)) | ||
} |
Oops, something went wrong.