|
52 | 52 | from aleph.sdk.types import Account, GenericMessage, StorageEnum
|
53 | 53 | from aleph.sdk.utils import Writable, copy_async_readable_to_buffer
|
54 | 54 |
|
55 |
| -from .base import AlephClientBase, AuthenticatedAlephClientBase |
| 55 | +from .base import BaseAlephClient, BaseAuthenticatedAlephClient |
56 | 56 | from .conf import settings
|
57 | 57 | from .exceptions import (
|
58 | 58 | BroadcastError,
|
|
61 | 61 | MessageNotFoundError,
|
62 | 62 | MultipleMessagesError,
|
63 | 63 | )
|
64 |
| -from .models import MessagesResponse, PostsResponse |
| 64 | +from .models import MessagesResponse, PostsResponse, Post |
65 | 65 | from .utils import check_unix_socket_valid, get_message_type_value
|
66 | 66 |
|
67 | 67 | logger = logging.getLogger(__name__)
|
@@ -471,7 +471,7 @@ def submit(
|
471 | 471 | )
|
472 | 472 |
|
473 | 473 |
|
474 |
| -class AlephClient(AlephClientBase): |
| 474 | +class AlephClient(BaseAlephClient): |
475 | 475 | api_server: str
|
476 | 476 | http_session: aiohttp.ClientSession
|
477 | 477 |
|
@@ -620,26 +620,15 @@ async def get_posts(
|
620 | 620 | response_json = await resp.json()
|
621 | 621 | posts_raw = response_json["posts"]
|
622 | 622 |
|
623 |
| - # All posts may not be valid according to the latest specification in |
624 |
| - # aleph-message. This allows the user to specify how errors should be handled. |
625 |
| - posts: List[AlephMessage] = [] |
| 623 | + posts: List[Post] = [] |
626 | 624 | for post_raw in posts_raw:
|
627 | 625 | try:
|
628 |
| - message = parse_message(post_raw) |
629 |
| - posts.append(message) |
630 |
| - except KeyError as e: |
631 |
| - if not ignore_invalid_messages: |
632 |
| - raise e |
633 |
| - logger.log( |
634 |
| - level=invalid_messages_log_level, |
635 |
| - msg=f"KeyError: Field '{e.args[0]}' not found", |
636 |
| - ) |
| 626 | + posts.append(Post.parse_obj(post_raw)) |
637 | 627 | except ValidationError as e:
|
638 | 628 | if not ignore_invalid_messages:
|
639 | 629 | raise e
|
640 | 630 | if invalid_messages_log_level:
|
641 | 631 | logger.log(level=invalid_messages_log_level, msg=e)
|
642 |
| - |
643 | 632 | return PostsResponse(
|
644 | 633 | posts=posts,
|
645 | 634 | pagination_page=response_json["pagination_page"],
|
@@ -919,7 +908,7 @@ async def watch_messages(
|
919 | 908 | break
|
920 | 909 |
|
921 | 910 |
|
922 |
| -class AuthenticatedAlephClient(AlephClient, AuthenticatedAlephClientBase): |
| 911 | +class AuthenticatedAlephClient(AlephClient, BaseAuthenticatedAlephClient): |
923 | 912 | account: Account
|
924 | 913 |
|
925 | 914 | BROADCAST_MESSAGE_FIELDS = {
|
|
0 commit comments