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