From f8a845ccb779508a3bfebc5adabf454125b1afab Mon Sep 17 00:00:00 2001 From: AiraNadih <128119996+AiraNadih@users.noreply.github.com> Date: Thu, 17 Apr 2025 12:49:42 +0000 Subject: [PATCH] fix(entry): add `update_content` query parameter to make content updates optional --- internal/api/entry.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/api/entry.go b/internal/api/entry.go index d3606035..dd4c7fbb 100644 --- a/internal/api/entry.go +++ b/internal/api/entry.go @@ -331,12 +331,19 @@ func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) { return } - if err := h.store.UpdateEntryTitleAndContent(entry); err != nil { - json.ServerError(w, r, err) + 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]interface{}{"content": mediaproxy.RewriteDocumentWithRelativeProxyURL(h.router, entry.Content), "reading_time": entry.ReadingTime}) + json.OK(w, r, map[string]string{"content": entry.Content}) } func (h *handler) flushHistory(w http.ResponseWriter, r *http.Request) {