Merge branch 'bugfix/reaction-of-reaction' into 'dev'

Fix bug reaction schedule could be child of parent

See merge request crafty-controller/crafty-4!636
This commit is contained in:
Iain Powrie 2023-10-07 15:19:36 +00:00
commit 48e659d683
2 changed files with 11 additions and 2 deletions

View File

@ -13,6 +13,7 @@
- Fix public status page not updating #255 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/615))
- Fix service worker vulrn and CQ raised by SonarQ ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/631))
- Fix Backup Restore/Schedules, Backup button function on `remote-comms2` ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/634))
- Fix bug where a reaction loop could be created, but would be cut short by an error when the loop occurred ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/636))
### Refactor
- Consolidate remaining frontend functions into API V2, and remove ajax internal API ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/585))
- Replace bleach with nh3 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/628))

View File

@ -330,6 +330,8 @@ class TasksManager:
# Check to see if it's enabled and is not a chain reaction.
if job_data["enabled"] and job_data["interval_type"] != "reaction":
# Lets make sure this can not be mistaken for a reaction
job_data["parent"] = None
new_job = "error"
if job_data["cron_string"] != "":
try:
@ -450,7 +452,10 @@ class TasksManager:
def update_job(self, sch_id, job_data):
# Checks to make sure some doofus didn't actually make the newly
# created task a child of itself.
if str(job_data.get("parent")) == str(sch_id):
if (
str(job_data.get("parent")) == str(sch_id)
or job_data["interval_type"] != "reaction"
):
job_data["parent"] = None
HelpersManagement.update_scheduled_task(sch_id, job_data)
@ -609,7 +614,10 @@ class TasksManager:
):
# event job ID's are strings so we need to look at
# this as the same data type.
if str(schedule.parent) == str(event.job_id):
if (
str(schedule.parent) == str(event.job_id)
and schedule.interval_type == "reaction"
):
if schedule.enabled:
delaytime = datetime.datetime.now() + datetime.timedelta(
seconds=schedule.delay