summaryrefslogtreecommitdiffstats
path: root/src/rest.c
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2021-03-15 10:06:04 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-03-15 12:17:56 +0100
commit8b7b5f33a126e3884ec540d79256a4cd704a4887 (patch)
treebe3adec402944f37f1bdf3d1d06798da50ed2148 /src/rest.c
parente7e80cdde6ec663f62e9b6d5b29331002d84265e (diff)
#997 Use stale check flag in schedule/update
Commit e68fefe introduced 'check_stale' flag to better distinguish real scheduled actions that do not execute if they are stale from immediate actions that we want them to be logged in the action queue (by creating a decoy schedule for the exact moment they are processed, meaning that we ignore if the are stale). Add this feature into schedule update too, in order to avoid executing stale commands that were not meant to, ie. real scheduled commands. Follows e68fefe ("Set stale check flag when processing schedule/create")
Diffstat (limited to 'src/rest.c')
-rw-r--r--src/rest.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/rest.c b/src/rest.c
index 1a25efc..81d2f54 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -3593,6 +3593,7 @@ static int og_cmd_schedule_create(json_t *element, struct og_msg_params *params)
static int og_cmd_schedule_update(json_t *element, struct og_msg_params *params)
{
struct og_dbi *dbi;
+ bool when = false;
const char *key;
json_t *value;
int err = 0;
@@ -3610,13 +3611,30 @@ static int og_cmd_schedule_update(json_t *element, struct og_msg_params *params)
} else if (!strcmp(key, "name")) {
err = og_json_parse_string(value, &params->name);
params->flags |= OG_REST_PARAM_NAME;
- } else if (!strcmp(key, "when"))
+ } else if (!strcmp(key, "when")) {
err = og_json_parse_time_params(value, params);
+ when = true;
+ }
if (err < 0)
return err;
}
+ if (!when) {
+ params->time.check_stale = false;
+ og_schedule_time_now(&params->time);
+ params->flags |= OG_REST_PARAM_TIME_YEARS |
+ OG_REST_PARAM_TIME_MONTHS |
+ OG_REST_PARAM_TIME_WEEKS |
+ OG_REST_PARAM_TIME_WEEK_DAYS |
+ OG_REST_PARAM_TIME_DAYS |
+ OG_REST_PARAM_TIME_HOURS |
+ OG_REST_PARAM_TIME_AM_PM |
+ OG_REST_PARAM_TIME_MINUTES;
+ } else {
+ params->time.check_stale = true;
+ }
+
if (!og_msg_params_validate(params, OG_REST_PARAM_ID |
OG_REST_PARAM_TASK |
OG_REST_PARAM_NAME |