mirror of
https://github.com/lone-cloud/prism
synced 2026-06-04 04:04:44 -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"`
|
UID string `json:"uid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handlers) HandleDelete(w http.ResponseWriter, r *http.Request) {
|
func (h *Handlers) HandleTrash(w http.ResponseWriter, r *http.Request) {
|
||||||
var req deleteRequest
|
var req trashRequest
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
util.JSONError(w, "invalid request body", http.StatusBadRequest)
|
util.JSONError(w, "invalid request body", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
|
@ -201,13 +201,13 @@ func (h *Handlers) HandleDelete(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.monitor.Delete(req.UID); err != nil {
|
if err := h.monitor.Trash(req.UID); err != nil {
|
||||||
h.logger.Error("failed to delete email", "uid", req.UID, "error", err)
|
h.logger.Error("failed to trash email", "uid", req.UID, "error", err)
|
||||||
util.JSONError(w, "failed to delete", http.StatusInternalServerError)
|
util.JSONError(w, "failed to trash", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
h.logger.Info("deleted email", "uid", req.UID)
|
h.logger.Info("trashed email", "uid", req.UID)
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
if err := json.NewEncoder(w).Encode(map[string]bool{"success": true}); err != nil {
|
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,
|
Message: subject,
|
||||||
Tag: "proton-" + msg.ID,
|
Tag: "proton-" + msg.ID,
|
||||||
Actions: []delivery.Action{
|
Actions: []delivery.Action{
|
||||||
{
|
|
||||||
ID: "delete",
|
|
||||||
Label: "Delete",
|
|
||||||
Endpoint: "/api/v1/proton/delete",
|
|
||||||
Method: "POST",
|
|
||||||
Data: map[string]any{
|
|
||||||
"uid": msg.ID,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
ID: "archive",
|
ID: "archive",
|
||||||
Label: "Archive",
|
Label: "Archive",
|
||||||
|
|
@ -99,9 +90,18 @@ func (m *Monitor) sendNotification(msg *protonmail.Message) {
|
||||||
"uid": msg.ID,
|
"uid": msg.ID,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ID: "trash",
|
||||||
|
Label: "Trash",
|
||||||
|
Endpoint: "/api/v1/proton/trash",
|
||||||
|
Method: "POST",
|
||||||
|
Data: map[string]any{
|
||||||
|
"uid": msg.ID,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ID: "mark-read",
|
ID: "mark-read",
|
||||||
Label: "Mark as Read",
|
Label: "Mark read",
|
||||||
Endpoint: "/api/v1/proton/mark-read",
|
Endpoint: "/api/v1/proton/mark-read",
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Data: map[string]any{
|
Data: map[string]any{
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ func (m *Monitor) Archive(msgID string) error {
|
||||||
return m.client.UnlabelMessages(protonmail.LabelInbox, []string{msgID})
|
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 {
|
if m.client == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ func RegisterRoutes(router *chi.Mux, handlers *Handlers, auth func(http.Handler)
|
||||||
r.Use(auth)
|
r.Use(auth)
|
||||||
r.Post("/mark-read", handlers.HandleMarkRead)
|
r.Post("/mark-read", handlers.HandleMarkRead)
|
||||||
r.Post("/archive", handlers.HandleArchive)
|
r.Post("/archive", handlers.HandleArchive)
|
||||||
r.Post("/delete", handlers.HandleDelete)
|
r.Post("/trash", handlers.HandleTrash)
|
||||||
r.Post("/auth", authH.handleAuth)
|
r.Post("/auth", authH.handleAuth)
|
||||||
r.Delete("/auth", authH.handleDelete)
|
r.Delete("/auth", authH.handleDelete)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue