Begin rules

This commit is contained in:
mitteneer 2025-04-18 21:29:00 -04:00
parent ff8cdabbf1
commit 18cdb48b53
3 changed files with 151 additions and 4 deletions

View file

@ -20,6 +20,26 @@ pub fn edit(id: []const u8, request: *jetzig.Request) !jetzig.View {
}
pub fn post(request: *jetzig.Request) !jetzig.View {
const params = try request.params();
var job = try request.job("process_rule");
_ = try job.params.put("name", params.get("rule-title"));
var conditionals = try job.params.put("conditionals", .array);
var cond0 = try conditionals.append(.object);
try cond0.put("match_on", params.get("match-on"));
try cond0.put("match_cond", params.get("match-cond"));
try cond0.put("match_txt", params.get("match-txt"));
var actions = try job.params.put("actions", .array);
var act0 = try actions.append(.object);
try act0.put("action", params.get("action"));
try act0.put("action_on", params.get("action-on"));
try act0.put("action_txt", params.get("action-txt"));
try job.schedule();
return request.render(.created);
}
@ -38,7 +58,6 @@ pub fn delete(id: []const u8, request: *jetzig.Request) !jetzig.View {
return request.render(.ok);
}
test "index" {
var app = try jetzig.testing.app(std.testing.allocator, @import("routes"));
defer app.deinit();