From 6b70a7dc812edbf88b17fc573858327c892c4c59 Mon Sep 17 00:00:00 2001 From: AiraNadih <128119996+AiraNadih@users.noreply.github.com> Date: Fri, 18 Apr 2025 03:41:58 +0800 Subject: [PATCH] feat(api): add `update_content` query parameter to `/entries/{entryID}/fetch-content` endpoint --- internal/api/entry.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/api/entry.go b/internal/api/entry.go index 508bbee4..dd4c7fbb 100644 --- a/internal/api/entry.go +++ b/internal/api/entry.go @@ -331,6 +331,18 @@ func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) { return } + shouldUpdateContent := request.QueryBoolParam(r, "update_content", false) + if shouldUpdateContent { + if err := h.store.UpdateEntryTitleAndContent(entry); err != nil { + json.ServerError(w, r, err) + return + } + + json.OK(w, r, map[string]interface{}{"content": mediaproxy.RewriteDocumentWithRelativeProxyURL(h.router, entry.Content), "reading_time": entry.ReadingTime}) + + return + } + json.OK(w, r, map[string]string{"content": entry.Content}) }