Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: allow user to specify datetime and UUID objects in post content #61

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/aleph/sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from aleph_message.models.execution.base import Encoding
from aleph_message.status import MessageStatus
from pydantic import ValidationError
from pydantic.json import pydantic_encoder

from aleph.sdk.types import Account, GenericMessage, StorageEnum
from aleph.sdk.utils import Writable, copy_async_readable_to_buffer
Expand Down Expand Up @@ -1475,7 +1476,10 @@ async def _prepare_aleph_message(
"channel": channel,
}

item_content: str = json.dumps(content, separators=(",", ":"))
# Use the Pydantic encoder to serialize types like UUID, datetimes, etc.
item_content: str = json.dumps(
content, separators=(",", ":"), default=pydantic_encoder
)

if allow_inlining and (len(item_content) < settings.MAX_INLINE_SIZE):
message_dict["item_content"] = item_content
Expand Down