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