Compare commits

..

No commits in common. "cd3d3c77333acc9b6bc96250f962e266d64f704e" and "64758686bb782352f8cb01ded501452bcb640490" have entirely different histories.

2 changed files with 8 additions and 11 deletions

View file

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

View file

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