From 29918f1d90c87978a00c1ef9495d6e6cae760ade Mon Sep 17 00:00:00 2001 From: scanash00 Date: Sun, 18 Jan 2026 18:08:53 -0900 Subject: [PATCH] fix token refersh on quick handler --- backend/internal/api/apikey.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/internal/api/apikey.go b/backend/internal/api/apikey.go index 03d6472..dbe9a9a 100644 --- a/backend/internal/api/apikey.go +++ b/backend/internal/api/apikey.go @@ -157,8 +157,12 @@ func (h *APIKeyHandler) QuickBookmark(w http.ResponseWriter, r *http.Request) { urlHash := db.HashURL(req.URL) record := xrpc.NewBookmarkRecord(req.URL, urlHash, req.Title, req.Description) - client := h.refresher.CreateClientFromSession(session) - result, err := client.CreateRecord(r.Context(), session.DID, xrpc.CollectionBookmark, record) + var result *xrpc.CreateRecordOutput + err = h.refresher.ExecuteWithAutoRefresh(r, session, func(client *xrpc.Client, did string) error { + var createErr error + result, createErr = client.CreateRecord(r.Context(), did, xrpc.CollectionBookmark, record) + return createErr + }) if err != nil { http.Error(w, "Failed to create bookmark: "+err.Error(), http.StatusInternalServerError) return @@ -228,8 +232,12 @@ func (h *APIKeyHandler) QuickAnnotation(w http.ResponseWriter, r *http.Request) urlHash := db.HashURL(req.URL) record := xrpc.NewAnnotationRecord(req.URL, urlHash, req.Text, nil, "") - client := h.refresher.CreateClientFromSession(session) - result, err := client.CreateRecord(r.Context(), session.DID, xrpc.CollectionAnnotation, record) + var result *xrpc.CreateRecordOutput + err = h.refresher.ExecuteWithAutoRefresh(r, session, func(client *xrpc.Client, did string) error { + var createErr error + result, createErr = client.CreateRecord(r.Context(), did, xrpc.CollectionAnnotation, record) + return createErr + }) if err != nil { http.Error(w, "Failed to create annotation: "+err.Error(), http.StatusInternalServerError) return -- 2.51.2