mirror of
https://github.com/lone-cloud/prism
synced 2026-06-03 08:43:10 -07:00
rename Delete to Trash
This commit is contained in:
parent
fa716d86b0
commit
70e6b8f17f
4 changed files with 19 additions and 19 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue