fix: Micropub photo posts and failed creates (v2.6.5)
- A create that failed after the note was written (e.g. the same photo twice) answered 500 but left the post published without photos. Photos are now resolved first, and a failed note is removed. - Pooled connections roll back unfinished writes, so one failure no longer locks the database for the next ~10 s. - The same photo twice in one post is shown once. - Photo posts no longer need text (Micropub doesn't require content, and q=config already advertised a photo-only post type). Updates may clear the text while photos remain. Crossposts start with the link; the page is titled "Photo". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d16463ef8a
commit
d0bfc80c2e
10 files changed
+247
-31
No files matched your search
+16
-12
@@ -868,20 +868,24 @@ def attach_media_to_note(note_id: int, media_ids: List[int], captions: List[str]
|
||||
|
||||
db = get_db(current_app)
|
||||
|
||||
# Delete existing associations (for edit case)
|
||||
db.execute("DELETE FROM note_media WHERE note_id = ?", (note_id,))
|
||||
try:
|
||||
# Delete existing associations (for edit case)
|
||||
db.execute("DELETE FROM note_media WHERE note_id = ?", (note_id,))
|
||||
|
||||
# Insert new associations
|
||||
for i, (media_id, caption) in enumerate(zip(media_ids, captions)):
|
||||
db.execute(
|
||||
"""
|
||||
INSERT INTO note_media (note_id, media_id, display_order, caption)
|
||||
VALUES (?, ?, ?, ?)
|
||||
""",
|
||||
(note_id, media_id, i, caption or None)
|
||||
)
|
||||
# Insert new associations
|
||||
for i, (media_id, caption) in enumerate(zip(media_ids, captions)):
|
||||
db.execute(
|
||||
"""
|
||||
INSERT INTO note_media (note_id, media_id, display_order, caption)
|
||||
VALUES (?, ?, ?, ?)
|
||||
""",
|
||||
(note_id, media_id, i, caption or None)
|
||||
)
|
||||
|
||||
db.commit()
|
||||
db.commit()
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise
|
||||
|
||||
|
||||
def get_note_media(note_id: int) -> List[Dict]:
|
||||
|
||||
Reference in new issue
Block a user