draft: explicitly remove drafts after sending
This seems necessary in some cases.
This commit is contained in:
@ -409,8 +409,11 @@ Server::Private::make_command_map()
|
|||||||
"remove",
|
"remove",
|
||||||
CommandInfo{
|
CommandInfo{
|
||||||
ArgMap{{":docid",
|
ArgMap{{":docid",
|
||||||
ArgInfo{Type::Number, true, "document-id for the message to remove"}}},
|
ArgInfo{Type::Number, false, "document-id for the message to remove"}},
|
||||||
"remove a message from filesystem and database",
|
{":path",
|
||||||
|
ArgInfo{Type::String, false, "document-id for the message to remove"}}
|
||||||
|
},
|
||||||
|
"remove a message from filesystem and database, using either :docid or :path",
|
||||||
[&](const auto& params) { remove_handler(params); }});
|
[&](const auto& params) { remove_handler(params); }});
|
||||||
|
|
||||||
cmap.emplace(
|
cmap.emplace(
|
||||||
@ -989,8 +992,18 @@ Server::Private::quit_handler(const Command& cmd)
|
|||||||
void
|
void
|
||||||
Server::Private::remove_handler(const Command& cmd)
|
Server::Private::remove_handler(const Command& cmd)
|
||||||
{
|
{
|
||||||
const auto docid{cmd.number_arg(":docid").value_or(0)};
|
auto docid_opt{cmd.number_arg(":docid")};
|
||||||
const auto path{path_from_docid(store(), docid)};
|
auto path_opt{cmd.string_arg(":path")};
|
||||||
|
|
||||||
|
if (!!docid_opt == !!path_opt)
|
||||||
|
throw Error(Error::Code::InvalidArgument,
|
||||||
|
"must pass precisely one of :docid and :path");
|
||||||
|
std::string path;
|
||||||
|
Store::Id docid{};
|
||||||
|
if (docid = docid_opt.value_or(0); docid != 0)
|
||||||
|
path = path_from_docid(store(), docid);
|
||||||
|
else
|
||||||
|
path = path_opt.value();
|
||||||
|
|
||||||
if (::unlink(path.c_str()) != 0 && errno != ENOENT)
|
if (::unlink(path.c_str()) != 0 && errno != ENOENT)
|
||||||
throw Error(Error::Code::File,
|
throw Error(Error::Code::File,
|
||||||
|
|||||||
@ -421,9 +421,8 @@ message buffer."
|
|||||||
"Handler called with DOCID and PATH for the just-sent message.
|
"Handler called with DOCID and PATH for the just-sent message.
|
||||||
For Forwarded ('Passed') and Replied messages, try to set the
|
For Forwarded ('Passed') and Replied messages, try to set the
|
||||||
appropriate flag at the message forwarded or replied-to."
|
appropriate flag at the message forwarded or replied-to."
|
||||||
;; XXX we don't need this function anymore here, but
|
;; XXX we don't need this function anymore here, but we have an external
|
||||||
;; we have an external caller in mu4e-icalendar... we should
|
;; caller in mu4e-icalendar... we should update that.
|
||||||
;; update that.
|
|
||||||
(mu4e--set-parent-flags path)
|
(mu4e--set-parent-flags path)
|
||||||
;; if the draft file exists, remove it now.
|
;; if the draft file exists, remove it now.
|
||||||
(when (file-exists-p path)
|
(when (file-exists-p path)
|
||||||
@ -457,7 +456,10 @@ appropriate flag at the message forwarded or replied-to."
|
|||||||
;; we end up with a ((buried) buffer here, visiting the
|
;; we end up with a ((buried) buffer here, visiting the
|
||||||
;; fcc-path; not quite sure why. But let's get rid of it (#2681)
|
;; fcc-path; not quite sure why. But let's get rid of it (#2681)
|
||||||
(when-let ((buf (find-buffer-visiting fcc-path)))
|
(when-let ((buf (find-buffer-visiting fcc-path)))
|
||||||
(kill-buffer buf))))
|
(kill-buffer buf))
|
||||||
|
;; remove draft
|
||||||
|
(when-let ((draft (buffer-file-name)))
|
||||||
|
(mu4e--server-remove draft))))
|
||||||
nil t))
|
nil t))
|
||||||
|
|
||||||
;; overrides for message-* functions
|
;; overrides for message-* functions
|
||||||
|
|||||||
@ -684,11 +684,13 @@ QUERIES is a list of queries for the number of results with
|
|||||||
read/unread status are returned in the pong-response."
|
read/unread status are returned in the pong-response."
|
||||||
(mu4e--server-call-mu `(queries :queries ,queries)))
|
(mu4e--server-call-mu `(queries :queries ,queries)))
|
||||||
|
|
||||||
(defun mu4e--server-remove (docid)
|
(defun mu4e--server-remove (docid-or-path)
|
||||||
"Remove message with DOCID.
|
"Remove message with either DOCID or PATH.
|
||||||
The results are reported through either (:update ... )
|
The results are reported through either (:update ... )
|
||||||
or (:error) sexps."
|
or (:error) sexps."
|
||||||
(mu4e--server-call-mu `(remove :docid ,docid)))
|
(if (stringp docid-or-path)
|
||||||
|
(mu4e--server-call-mu `(remove :path ,docid-or-path))
|
||||||
|
(mu4e--server-call-mu `(remove :docid ,docid-or-path))))
|
||||||
|
|
||||||
(defun mu4e--server-view (docid-or-msgid &optional mark-as-read)
|
(defun mu4e--server-view (docid-or-msgid &optional mark-as-read)
|
||||||
"View a message referred to by DOCID-OR-MSGID.
|
"View a message referred to by DOCID-OR-MSGID.
|
||||||
|
|||||||
Reference in New Issue
Block a user