fix: stop sending notify_email in create_job, clarify format override prompt

notify_email is not supported by all Hashview servers and caused job
creation to fail. Changed default to None so it is omitted from the
request unless explicitly passed.

Also reworded the file format override prompt so the detected name does
not appear twice in the output.
This commit is contained in:
Justin Bollinger
2026-03-09 12:39:10 -04:00
parent 497039dd08
commit 903641f285
2 changed files with 5 additions and 16 deletions

View File

@@ -772,7 +772,7 @@ class HashviewAPI:
return resp.json()
def create_job(
self, name, hashfile_id, customer_id, limit_recovered=False, notify_email=True
self, name, hashfile_id, customer_id, limit_recovered=False, notify_email=None
):
url = f"{self.base_url}/v1/jobs/add"
headers = {"Content-Type": "application/json"}
@@ -787,18 +787,9 @@ class HashviewAPI:
resp = self.session.post(url, json=data, headers=headers)
resp.raise_for_status()
try:
payload = resp.json()
return resp.json()
except Exception:
return resp.json()
msg = str(payload.get("msg", ""))
if "invalid keyword argument for JobNotifications" in msg:
# Retry without notify_email for older Hashview servers.
data.pop("notify_email", None)
resp = self.session.post(url, json=data, headers=headers)
resp.raise_for_status()
return resp.json()
return payload
return {}
def stop_job(self, job_id):
url = f"{self.base_url}/v1/jobs/stop/{job_id}"

View File

@@ -2849,10 +2849,10 @@ def hashview_api():
4: "user:hash",
5: "hash_only",
}
print(f"\nAuto-detected file format: {file_format} ({format_names.get(file_format, 'unknown')})")
format_list = ", ".join(f"{k}={v}" for k, v in format_names.items())
print(f"\nAuto-detected file format: {file_format} ({format_names.get(file_format, 'unknown')})")
override = input(
f"Press Enter to accept or enter a format number [{format_list}]: "
f"Override format number? [{format_list}] (Enter to accept): "
).strip()
if override:
try:
@@ -2891,14 +2891,12 @@ def hashview_api():
if create_job.upper() == "Y":
job_name = input("Enter job name: ")
limit_recovered = False
notify_email = True
try:
job_result = api_harness.create_job(
job_name,
result["hashfile_id"],
customer_id,
limit_recovered,
notify_email,
)
print(
f"\n✓ Success: {job_result.get('msg', 'Job created')}"