[feat] solution: SNS 연동 확인용 테스트 게시 기능 추가
This commit is contained in:
1 parent
d77f2aa14c
commit
921c85df25
4 files changed
+114
No files matched your search
@@ -30,6 +30,22 @@ async def account(response: Response, user: UserInfo = Depends(IsValidAccessToke
|
||||
return await service.account_state(UUID(user.user_id))
|
||||
|
||||
|
||||
class TestPost(BaseModel):
|
||||
text: str = Field(min_length=1, max_length=500)
|
||||
|
||||
|
||||
@router.post("/test-post")
|
||||
async def test_post(
|
||||
req: TestPost, response: Response, user: UserInfo = Depends(IsValidAccessToken)
|
||||
):
|
||||
"""연동 확인용 즉시 게시 — 승인 없이 바로 연결된 계정으로 올라간다."""
|
||||
private_response(response)
|
||||
try:
|
||||
return await service.test_post(UUID(user.user_id), req.text)
|
||||
except SocialError as ex:
|
||||
raise HTTPException(409, str(ex)) from ex
|
||||
|
||||
|
||||
@router.get("/place/{place_id}")
|
||||
async def list_posts(
|
||||
place_id: UUID, response: Response, user: UserInfo = Depends(IsValidAccessToken)
|
||||
|
||||
@@ -149,6 +149,26 @@ def posting_enabled():
|
||||
return accounts.configured() and config.get("SOCIAL_POSTING_ENABLED") == "1"
|
||||
|
||||
|
||||
async def test_post(user_id, text, provider=2):
|
||||
"""사장님이 자기 계정 연결이 실제로 되는지 확인하려고 한 줄 올려 보는 것.
|
||||
|
||||
★ 왜 posting_enabled()·승인 절차를 거치지 않는가 — 그 게이트는 승인 기반
|
||||
"소식 발행" 상품을 계약·해지 안내 정책이 끝나기 전에 열지 않으려는 것이다.
|
||||
여기서 사장님이 자기 계정에 테스트 한 줄을 올리는 것은 그 상품과 무관하다.
|
||||
"""
|
||||
|
||||
async def run(s):
|
||||
await accounts.lock_user(s, user_id, provider)
|
||||
row = await accounts.account(s, user_id, provider)
|
||||
if not row:
|
||||
raise SocialError("ACCOUNT_CONNECTION_REQUIRED")
|
||||
async with httpx.AsyncClient(timeout=20) as client:
|
||||
token = await accounts.get_usable_token(s, row, client)
|
||||
return await adapter(provider).publish(text, token, client=client)
|
||||
|
||||
return await db.transaction(run)
|
||||
|
||||
|
||||
async def create_draft(user_id, place_id, provider=2):
|
||||
async def run(s):
|
||||
place, site, url = await target(s, user_id, place_id)
|
||||
|
||||
Reference in new issue
Block a user