mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-22 11:46:06 +08:00
feat(webhooks): add validation mode support and enhance start notifications
Add a validation_mode flag to prevent sending start webhooks during config validation. Enhance webhook payload with enabled commands and execution options for better notification details.
This commit is contained in:
parent
462cab9246
commit
2f8e9d9ca1
3 changed files with 28 additions and 2 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
4.6.3-develop14
|
||||
4.6.3-develop15
|
||||
|
|
|
@ -901,6 +901,7 @@ class WebAPI:
|
|||
temp_args = self.args.copy()
|
||||
temp_args["config_file"] = temp_config_path.name # Use temp file name
|
||||
temp_args["_from_web_api"] = True
|
||||
temp_args["validation_mode"] = True # Flag to indicate this is validation, not a real run
|
||||
temp_args["time"] = now.strftime("%H:%M")
|
||||
temp_args["time_obj"] = now
|
||||
temp_args["run"] = True
|
||||
|
|
|
@ -100,12 +100,35 @@ class Webhooks:
|
|||
|
||||
def start_time_hooks(self, start_time):
|
||||
"""Send a webhook to notify that the run has started."""
|
||||
if self.run_start_webhooks:
|
||||
# Skip sending start notifications during config validation
|
||||
if self.run_start_webhooks and not self.config.args.get("validation_mode", False):
|
||||
dry_run = self.config.commands["dry_run"]
|
||||
if dry_run:
|
||||
start_type = "Dry-"
|
||||
else:
|
||||
start_type = ""
|
||||
|
||||
# Get enabled commands
|
||||
enabled_commands = [
|
||||
cmd
|
||||
for cmd in [
|
||||
"recheck",
|
||||
"cat_update",
|
||||
"tag_update",
|
||||
"rem_unregistered",
|
||||
"tag_tracker_error",
|
||||
"rem_orphaned",
|
||||
"tag_nohardlinks",
|
||||
"share_limits",
|
||||
]
|
||||
if self.config.commands.get(cmd, False)
|
||||
]
|
||||
|
||||
# Get execution options
|
||||
execution_options = [
|
||||
opt for opt in ["skip_cleanup", "dry_run", "skip_qb_version_check"] if self.config.commands.get(opt, False)
|
||||
]
|
||||
|
||||
self._request(
|
||||
self.run_start_webhooks,
|
||||
{
|
||||
|
@ -115,6 +138,8 @@ class Webhooks:
|
|||
"start_time": start_time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"dry_run": self.config.commands["dry_run"],
|
||||
"web_api_used": self.web_api_used,
|
||||
"commands": enabled_commands,
|
||||
"execution_options": execution_options,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue