From 70e6b8f17f4e3e806e51a51c0a45a7289d00a348 Mon Sep 17 00:00:00 2001 From: Egor Date: Fri, 27 Feb 2026 13:43:47 -0800 Subject: [PATCH] rename Delete to Trash --- service/integration/proton/handlers.go | 14 +++++++------- service/integration/proton/messages.go | 20 ++++++++++---------- service/integration/proton/monitor.go | 2 +- service/integration/proton/routes.go | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/service/integration/proton/handlers.go b/service/integration/proton/handlers.go index 3f3d796..7f5787e 100644 --- a/service/integration/proton/handlers.go +++ b/service/integration/proton/handlers.go @@ -180,12 +180,12 @@ func (h *Handlers) HandleArchive(w http.ResponseWriter, r *http.Request) { } } -type deleteRequest struct { +type trashRequest struct { UID string `json:"uid"` } -func (h *Handlers) HandleDelete(w http.ResponseWriter, r *http.Request) { - var req deleteRequest +func (h *Handlers) HandleTrash(w http.ResponseWriter, r *http.Request) { + var req trashRequest if err := json.NewDecoder(r.Body).Decode(&req); err != nil { util.JSONError(w, "invalid request body", http.StatusBadRequest) return @@ -201,13 +201,13 @@ func (h *Handlers) HandleDelete(w http.ResponseWriter, r *http.Request) { return } - if err := h.monitor.Delete(req.UID); err != nil { - h.logger.Error("failed to delete email", "uid", req.UID, "error", err) - util.JSONError(w, "failed to delete", http.StatusInternalServerError) + if err := h.monitor.Trash(req.UID); err != nil { + h.logger.Error("failed to trash email", "uid", req.UID, "error", err) + util.JSONError(w, "failed to trash", http.StatusInternalServerError) return } - h.logger.Info("deleted email", "uid", req.UID) + h.logger.Info("trashed email", "uid", req.UID) w.Header().Set("Content-Type", "application/json") if err := json.NewEncoder(w).Encode(map[string]bool{"success": true}); err != nil { diff --git a/service/integration/proton/messages.go b/service/integration/proton/messages.go index fc3156b..4e2092a 100644 --- a/service/integration/proton/messages.go +++ b/service/integration/proton/messages.go @@ -81,15 +81,6 @@ func (m *Monitor) sendNotification(msg *protonmail.Message) { Message: subject, Tag: "proton-" + msg.ID, Actions: []delivery.Action{ - { - ID: "delete", - Label: "Delete", - Endpoint: "/api/v1/proton/delete", - Method: "POST", - Data: map[string]any{ - "uid": msg.ID, - }, - }, { ID: "archive", Label: "Archive", @@ -99,9 +90,18 @@ func (m *Monitor) sendNotification(msg *protonmail.Message) { "uid": msg.ID, }, }, + { + ID: "trash", + Label: "Trash", + Endpoint: "/api/v1/proton/trash", + Method: "POST", + Data: map[string]any{ + "uid": msg.ID, + }, + }, { ID: "mark-read", - Label: "Mark as Read", + Label: "Mark read", Endpoint: "/api/v1/proton/mark-read", Method: "POST", Data: map[string]any{ diff --git a/service/integration/proton/monitor.go b/service/integration/proton/monitor.go index 41b9807..532a2b8 100644 --- a/service/integration/proton/monitor.go +++ b/service/integration/proton/monitor.go @@ -168,7 +168,7 @@ func (m *Monitor) Archive(msgID string) error { return m.client.UnlabelMessages(protonmail.LabelInbox, []string{msgID}) } -func (m *Monitor) Delete(msgID string) error { +func (m *Monitor) Trash(msgID string) error { if m.client == nil { return nil } diff --git a/service/integration/proton/routes.go b/service/integration/proton/routes.go index b7f7d95..47e09b2 100644 --- a/service/integration/proton/routes.go +++ b/service/integration/proton/routes.go @@ -167,7 +167,7 @@ func RegisterRoutes(router *chi.Mux, handlers *Handlers, auth func(http.Handler) r.Use(auth) r.Post("/mark-read", handlers.HandleMarkRead) r.Post("/archive", handlers.HandleArchive) - r.Post("/delete", handlers.HandleDelete) + r.Post("/trash", handlers.HandleTrash) r.Post("/auth", authH.handleAuth) r.Delete("/auth", authH.handleDelete) })