|
2 | 2 | import logging |
3 | 3 |
|
4 | 4 | import aiohttp |
5 | | -from aleph_client.asynchronous import create_post |
6 | | -from aleph_client.chains.common import get_fallback_private_key |
7 | | -from aleph_client.chains.ethereum import ETHAccount |
8 | | -from aleph_client.types import StorageEnum |
| 5 | +from aleph_message.status import MessageStatus |
9 | 6 | from fastapi import FastAPI, HTTPException, Request |
10 | 7 | from fastapi.responses import Response, StreamingResponse |
11 | 8 | from pydantic import BaseModel |
12 | 9 |
|
| 10 | +from aleph.sdk import AuthenticatedAlephHttpClient |
| 11 | +from aleph.sdk.chains.common import get_fallback_private_key |
| 12 | +from aleph.sdk.chains.ethereum import ETHAccount |
| 13 | +from aleph.sdk.types import StorageEnum |
| 14 | + |
13 | 15 | from .conf import settings |
14 | 16 |
|
15 | 17 | logger = logging.getLogger(__file__) |
@@ -164,17 +166,21 @@ async def publish_data(body: PostBody): |
164 | 166 | content = json.loads(message["item_content"]) |
165 | 167 | content_content = content["content"] |
166 | 168 |
|
167 | | - result = await create_post( |
168 | | - account=account, |
169 | | - post_content=content_content, |
170 | | - post_type=content["type"], |
171 | | - address=content["address"], |
172 | | - ref=None, |
173 | | - channel=message["channel"], |
174 | | - inline=True, |
175 | | - storage_engine=StorageEnum.storage, |
176 | | - ) |
177 | | - return {"status": "success"} |
| 169 | + async with AuthenticatedAlephHttpClient(account) as client: |
| 170 | + result, status = await client.create_post( |
| 171 | + post_content=content_content, |
| 172 | + post_type=content["type"], |
| 173 | + address=content["address"], |
| 174 | + ref=None, |
| 175 | + channel=message["channel"], |
| 176 | + inline=True, |
| 177 | + storage_engine=StorageEnum.storage, |
| 178 | + sync=True, |
| 179 | + ) |
| 180 | + if status == MessageStatus.PROCESSED: |
| 181 | + return {"status": "success"} |
| 182 | + else: |
| 183 | + return {"status": "error"} |
178 | 184 |
|
179 | 185 |
|
180 | 186 | @app.get("/properties") |
|
0 commit comments