Compare commits

...

3 commits

Author SHA1 Message Date
cd3d3c7733
fix(aurora): make sure the bot key does not exist in the Change.from_dict() data dictionary
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 30s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 54s
2024-08-21 15:16:40 -04:00
4d2004ed93
fix(aurora): fix changes not being imported 2024-08-21 15:16:10 -04:00
a3ad38f338
misc(aurora): improved Change.from_dict() 2024-08-21 15:15:50 -04:00
2 changed files with 11 additions and 8 deletions

View file

@ -60,16 +60,17 @@ class ImportAuroraView(ui.View):
case["target_id"] = int(case["target_id"])
case["moderator_id"] = int(case["moderator_id"])
if not case.get("changes", None):
changes = case.get("changes", None)
if not changes:
changes = []
else:
if not isinstance(case["changes"], list):
changes = json.loads(case["changes"])
if not isinstance(changes, list):
changes = json.loads(changes)
if isinstance(changes, str):
changes: list[dict] = json.loads(changes)
for change in changes:
if change.get("bot"):
if "bot" in change:
del change["bot"]
if "metadata" not in case:

View file

@ -40,16 +40,16 @@ class Change(AuroraBaseModel):
data = json.loads(data)
if data.get('duration'):
logger.debug(f"Duration: {data['duration']}")
if "duration" in data and data["duration"] and not isinstance(data["duration"], timedelta) and not data["duration"] == "NULL":
if data.get('duration') and not isinstance(data["duration"], timedelta) and not data["duration"] == "NULL":
duration = timedelta_from_string(data["duration"])
elif "duration" in data and isinstance(data["duration"], timedelta):
elif data.get('duration') and isinstance(data["duration"], timedelta):
duration = data["duration"]
else:
duration = None
if "end_timestamp" in data and data["end_timestamp"] and not isinstance(data["end_timestamp"], datetime):
if data.get('end_timestamp') and not isinstance(data["end_timestamp"], datetime):
end_timestamp = datetime.fromtimestamp(data["end_timestamp"])
elif "end_timestamp" in data and isinstance(data["end_timestamp"], datetime):
elif data.get('end_timestamp') and isinstance(data["end_timestamp"], datetime):
end_timestamp = data["end_timestamp"]
else:
end_timestamp = None
@ -69,4 +69,6 @@ class Change(AuroraBaseModel):
"end_timestamp": end_timestamp,
"duration": duration
})
if "bot" in data:
del data["bot"]
return cls(bot=bot, **data)