aboutsummaryrefslogtreecommitdiff
path: root/internal/api
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api')
-rw-r--r--internal/api/api.go1
-rw-r--r--internal/api/entry.go6
2 files changed, 7 insertions, 0 deletions
diff --git a/internal/api/api.go b/internal/api/api.go
index 1a53336c..2da998b5 100644
--- a/internal/api/api.go
+++ b/internal/api/api.go
@@ -66,4 +66,5 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool) {
sr.HandleFunc("/entries/{entryID}/bookmark", handler.toggleBookmark).Methods(http.MethodPut)
sr.HandleFunc("/entries/{entryID}/save", handler.saveEntry).Methods(http.MethodPost)
sr.HandleFunc("/entries/{entryID}/fetch-content", handler.fetchContent).Methods(http.MethodGet)
+ sr.HandleFunc("/flush-history", handler.flushHistory).Methods(http.MethodPut, http.MethodDelete)
}
diff --git a/internal/api/entry.go b/internal/api/entry.go
index 1355fa3b..e6c00e3a 100644
--- a/internal/api/entry.go
+++ b/internal/api/entry.go
@@ -283,6 +283,12 @@ func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) {
json.OK(w, r, map[string]string{"content": entry.Content})
}
+func (h *handler) flushHistory(w http.ResponseWriter, r *http.Request) {
+ loggedUserID := request.UserID(r)
+ go h.store.FlushHistory(loggedUserID)
+ json.Accepted(w, r)
+}
+
func configureFilters(builder *storage.EntryQueryBuilder, r *http.Request) {
if beforeEntryID := request.QueryInt64Param(r, "before_entry_id", 0); beforeEntryID > 0 {
builder.BeforeEntryID(beforeEntryID)