[feat] solution/backend,docs: 미니블로그 승인 → 쓰레드 자동 게재, 쓰레드 초안 생성 OpenAI 전환
사장님 지시: "쓰레드에 연동되어 있으면 같이 업로드 되는 기능". 미니블로그의 두 승인 경로(이메일 GET 토큰, 로그인 "바로 발행")를 공통 메서드로 묶고, 그 끝에서 쓰레드 연동을 시도한다. 미니블로그 승인 자체가 발화 동의로 취급되므로 쓰레드 쪽 별도 승인은 묻지 않는다(DECISIONS 7-1-2 개정, 문구를 그대로 재사용하는 경우에 한정). 겸사겸사 쓰레드 초안 생성(generate_social_post)이 LLM_PROVIDER 를 안 타고 Gemini 를 직접 호출하던 것도 다른 생성 함수와 같은 추상화로 맞췄다. - blog_jobs._published_places: sites.domain IS NOT NULL 조건 추가(쓰레드 기준과 통일) - social_service.publish_reused_text: 연동 없음/게시 비활성/domain 미확정이면 스킵, 정상이면 APPROVED 삽입 + run_post(job_type=9) enqueue — 새 게시 로직은 안 만든다 - post_service: decide/approve_by_owner → _approve_and_publish 로 공통화, _try_social_share 는 실패를 전부 삼켜 미니블로그 승인을 막지 않는다 - gemini_text.generate_social_post: services.llm.provider.active() 로 전환, Gemini 전용 import 제거 - DECISIONS.md 7-1-2, MINI_BLOG.md 5·8절, SOCIAL.md 갱신 test_blog_owner.py·test_social.py 다수 추가/수정, 관련 스위트 전체 PASS
This commit is contained in:
1 parent
07c53d30bf
commit
47da2f29b3
9 files changed
+861
-101
No files matched your search
@@ -19,7 +19,7 @@ from common.database.model.models import (
|
||||
place_facts,
|
||||
owner_social_accounts as Account,
|
||||
)
|
||||
from common.enums import SiteStatus, ErrorType, PUBLISHABLE_FACT_STATUSES
|
||||
from common.enums import SiteStatus, ErrorType, PUBLISHABLE_FACT_STATUSES, SocialProvider
|
||||
from crud.place_crud import PlaceCRUD
|
||||
from crud import social_crud as db
|
||||
from services import site_payload, social_account_service as accounts
|
||||
@@ -580,3 +580,49 @@ async def run_post(job):
|
||||
except Exception:
|
||||
await set_failure(post_id, "POST_RESULT_UNKNOWN", status="UNKNOWN")
|
||||
raise SocialOutcomeUnknown("POST_RESULT_UNKNOWN") from None
|
||||
|
||||
|
||||
async def publish_reused_text(user_id, place_id, body: str):
|
||||
"""미니블로그 승인 문구를 그대로 쓰레드에 낸다 — 승인 자체가 발화 동의라 별도 승인을
|
||||
또 묻지 않는다(2026-09-21, DECISIONS 7-1-2 개정: 미니블로그 문구를 그대로 재사용하는
|
||||
경우에 한정한 예외). 연동 안 돼 있거나 조건 미달이면 조용히 None을 돌려준다 — 호출부가
|
||||
실패로 취급하지 않는다."""
|
||||
if not posting_enabled():
|
||||
return None
|
||||
|
||||
async def run(s):
|
||||
account = await accounts.account(s, user_id, SocialProvider.THREADS.value)
|
||||
if not account or account.status != "linked":
|
||||
return None
|
||||
_place, site, url = await target(s, user_id, place_id)
|
||||
full_text = f"{body}\n\n{url}"
|
||||
row_id = (
|
||||
await s.execute(
|
||||
insert(Post)
|
||||
.values(
|
||||
place_id=place_id,
|
||||
user_id=user_id,
|
||||
site_version_id=site.current_version_id,
|
||||
provider=SocialProvider.THREADS.value,
|
||||
account_id=account.account_id,
|
||||
link_url=url,
|
||||
body=full_text,
|
||||
status="APPROVED",
|
||||
decided_at=datetime.now(timezone.utc),
|
||||
decided_via="mini_blog",
|
||||
)
|
||||
.on_conflict_do_nothing(
|
||||
index_elements=["place_id", "site_version_id"],
|
||||
index_where=text("deleted=false"),
|
||||
)
|
||||
.returning(Post.post_id)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
if row_id:
|
||||
await db.enqueue(s, row_id, 9)
|
||||
return row_id
|
||||
|
||||
try:
|
||||
return await db.transaction(run)
|
||||
except HTTPException:
|
||||
return None
|
||||
Reference in new issue
Block a user