mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Remove pro_licence_key from metadata as we have another way of checking if the status changed
This commit is contained in:
parent
aec7ed23dd
commit
7ca4de5579
3 changed files with 6 additions and 14 deletions
|
|
@ -96,9 +96,9 @@ try:
|
|||
db = Database(LOGGER, sqlalchemy_string=getenv("DATABASE_URI"))
|
||||
db_metadata = db.get_metadata()
|
||||
current_date = datetime.now()
|
||||
pro_license_key = getenv("PRO_LICENSE_KEY")
|
||||
pro_license_key = getenv("PRO_LICENSE_KEY", "").strip()
|
||||
|
||||
LOGGER.info("Checking BunkerWeb Pro license key...")
|
||||
LOGGER.info("Checking BunkerWeb Pro status...")
|
||||
|
||||
data = {
|
||||
"integration": get_integration(),
|
||||
|
|
@ -109,7 +109,6 @@ try:
|
|||
headers = {"User-Agent": f"BunkerWeb/{data['version']}"}
|
||||
default_metadata = {
|
||||
"is_pro": False,
|
||||
"pro_license_key": None,
|
||||
"pro_expire": None,
|
||||
"pro_status": "invalid",
|
||||
"pro_overlapped": False,
|
||||
|
|
@ -122,8 +121,6 @@ try:
|
|||
temp_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if pro_license_key:
|
||||
default_metadata["pro_license_key"] = (pro_license_key := pro_license_key.strip())
|
||||
|
||||
LOGGER.info("BunkerWeb Pro license provided, checking if it's valid...")
|
||||
headers["Authorization"] = f"Bearer {pro_license_key}"
|
||||
resp = get(f"{API_ENDPOINT}/pro/status", headers=headers, json=data, timeout=5, allow_redirects=True)
|
||||
|
|
@ -157,12 +154,11 @@ try:
|
|||
metadata["pro_overlapped"] = True
|
||||
metadata["is_pro"] = metadata["pro_status"] == "active"
|
||||
|
||||
# If we already checked today, skip the check
|
||||
# ? If we already checked today, skip the check and if the metadata is the same, skip the check
|
||||
if (
|
||||
metadata["is_pro"] == db_metadata["is_pro"]
|
||||
and pro_license_key == db_metadata["pro_license_key"]
|
||||
metadata.get("is_pro", False) == db_metadata["is_pro"]
|
||||
and db_metadata["last_pro_check"]
|
||||
and current_date.day == db_metadata["last_pro_check"].day
|
||||
and current_date.replace(hour=0, minute=0, second=0, microsecond=0) == db_metadata["last_pro_check"].replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
):
|
||||
LOGGER.info("Skipping the check for BunkerWeb Pro license (already checked today)")
|
||||
sys_exit(0)
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ class Database:
|
|||
|
||||
return ""
|
||||
|
||||
def set_pro_metadata(self, data: Dict[Literal["is_pro", "pro_license_key", "pro_expire", "pro_status", "pro_overlapped", "pro_services"], Any] = {}) -> str:
|
||||
def set_pro_metadata(self, data: Dict[Literal["is_pro", "pro_expire", "pro_status", "pro_overlapped", "pro_services"], Any] = {}) -> str:
|
||||
"""Set the pro metadata values"""
|
||||
with self.__db_session() as session:
|
||||
try:
|
||||
|
|
@ -312,7 +312,6 @@ class Database:
|
|||
"integration": "unknown",
|
||||
"database_version": "Unknown",
|
||||
"is_pro": "no",
|
||||
"pro_license_key": "",
|
||||
"pro_expire": None,
|
||||
"pro_services": 0,
|
||||
"pro_overlapped": False,
|
||||
|
|
@ -332,7 +331,6 @@ class Database:
|
|||
Metadata.version,
|
||||
Metadata.integration,
|
||||
Metadata.is_pro,
|
||||
Metadata.pro_license_key,
|
||||
Metadata.pro_expire,
|
||||
Metadata.pro_services,
|
||||
Metadata.pro_overlapped,
|
||||
|
|
@ -348,7 +346,6 @@ class Database:
|
|||
"version": metadata.version,
|
||||
"integration": metadata.integration,
|
||||
"is_pro": metadata.is_pro,
|
||||
"pro_license_key": metadata.pro_license_key or "",
|
||||
"pro_expire": metadata.pro_expire,
|
||||
"pro_services": metadata.pro_services,
|
||||
"pro_overlapped": metadata.pro_overlapped,
|
||||
|
|
|
|||
|
|
@ -216,7 +216,6 @@ class Metadata(Base):
|
|||
id = Column(Integer, primary_key=True, default=1)
|
||||
is_initialized = Column(Boolean, nullable=False)
|
||||
is_pro = Column(Boolean, default=False, nullable=False)
|
||||
pro_license_key = Column(String(256), nullable=True)
|
||||
pro_expire = Column(DateTime, nullable=True)
|
||||
pro_status = Column(PRO_STATUS_ENUM, default="invalid", nullable=False)
|
||||
pro_services = Column(Integer, default=0, nullable=False)
|
||||
|
|
|
|||
Loading…
Reference in a new issue