Skip to content

Commit

Permalink
Merge pull request #43 from lucasoeth/main
Browse files Browse the repository at this point in the history
fix pydantic invalid datetime error
  • Loading branch information
subzeroid authored May 19, 2024
2 parents 0d8fda2 + fdd216c commit a4a1d98
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions aiograpi/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ def extract_direct_thread(data):
if "inviter" in data:
data["inviter"] = extract_user_short(data["inviter"])
data["left_users"] = data.get("left_users", [])

data["last_activity_at"] = datetime.datetime.fromtimestamp(data["last_activity_at"] / 1_000_000)

return DirectThread(**data)


Expand Down Expand Up @@ -373,7 +376,7 @@ def extract_reply_message(data):
clip = clip.get("clip")
data["clip"] = extract_media_v1(clip)

data["timestamp"] = datetime.datetime.fromtimestamp(data["timestamp"] // 1_000_000)
data["timestamp"] = datetime.datetime.fromtimestamp(data["timestamp"] / 1_000_000)
data["user_id"] = str(data["user_id"])

return ReplyMessage(**data)
Expand Down Expand Up @@ -403,9 +406,7 @@ def extract_direct_message(data):
if xma_media_share:
data["xma_share"] = extract_media_v1_xma(xma_media_share[0])

data["timestamp"] = datetime.datetime.fromtimestamp(
int(data["timestamp"]) // 1_000_000
)
data["timestamp"] = datetime.datetime.fromtimestamp(data["timestamp"] / 1_000_000)
data["user_id"] = str(data.get("user_id", ""))

return DirectMessage(**data)
Expand Down

0 comments on commit a4a1d98

Please sign in to comment.