Fix NPMplus enable/disable request method
This commit is contained in:
@@ -34,11 +34,12 @@ def _request_json(
|
||||
headers: dict[str, str],
|
||||
data: dict[str, Any] | None,
|
||||
verify_tls: bool,
|
||||
method: str | None = None,
|
||||
) -> Any:
|
||||
body = None
|
||||
if data is not None:
|
||||
body = json.dumps(data).encode("utf-8")
|
||||
req = Request(url, headers=headers, data=body)
|
||||
req = Request(url, headers=headers, data=body, method=method)
|
||||
|
||||
context = None
|
||||
if not verify_tls:
|
||||
@@ -186,7 +187,7 @@ def set_proxy_host(cfg: dict[str, Any], host_id: int, enabled: bool) -> tuple[bo
|
||||
"User-Agent": "tg-admin-bot",
|
||||
}
|
||||
try:
|
||||
payload = _request_json(url, headers, None, verify_tls)
|
||||
payload = _request_json(url, headers, None, verify_tls, method="POST")
|
||||
except Exception as e:
|
||||
return False, str(e)
|
||||
if payload is True or (isinstance(payload, dict) and payload.get("success", True)):
|
||||
|
||||
Reference in New Issue
Block a user