Spaces:
Running
Running
Claude commited on
下書き→公開時に likes を引き継ぐよう修正
Browse files旧記事の likes 値を post_data に含めてから POST するようにした。
コメント・バックアップと同様に新 ID の記事へ移行される。
https://claude.ai/code/session_018sq37X4VGvDxwtnyyvQmFv
main.py
CHANGED
|
@@ -476,6 +476,9 @@ async def api_save(request: Request):
|
|
| 476 |
was_draft = existing.get("title", "").startswith("【下書き】")
|
| 477 |
|
| 478 |
if was_draft and becomes_public:
|
|
|
|
|
|
|
|
|
|
| 479 |
http_requests.delete(f"{base_url}/{article_id}", headers=CMS_HEADERS_GET())
|
| 480 |
r = http_requests.post(base_url, headers=CMS_HEADERS_POST(), json=post_data)
|
| 481 |
if r.status_code in [200, 201]:
|
|
|
|
| 476 |
was_draft = existing.get("title", "").startswith("【下書き】")
|
| 477 |
|
| 478 |
if was_draft and becomes_public:
|
| 479 |
+
likes_count = int(existing.get("likes", 0) or 0)
|
| 480 |
+
if likes_count:
|
| 481 |
+
post_data["likes"] = likes_count
|
| 482 |
http_requests.delete(f"{base_url}/{article_id}", headers=CMS_HEADERS_GET())
|
| 483 |
r = http_requests.post(base_url, headers=CMS_HEADERS_POST(), json=post_data)
|
| 484 |
if r.status_code in [200, 201]:
|