mu-server: mark _all_ messages with message-id as read
Not just the one we're viewing.
This commit is contained in:
@ -1161,30 +1161,34 @@ maybe_mark_as_read (Mu::Store& store, MuMsg *msg, Store::Id docid)
|
|||||||
void
|
void
|
||||||
Server::Private::view_handler (const Parameters& params)
|
Server::Private::view_handler (const Parameters& params)
|
||||||
{
|
{
|
||||||
Store::Id docid{Store::InvalidId};
|
std::vector<Store::Id> docids;
|
||||||
const auto path{get_string_or(params, ":path")};
|
const auto path{get_string_or(params, ":path")};
|
||||||
const auto mark_as_read{get_bool_or(params, ":mark-as-read")};
|
const auto mark_as_read{get_bool_or(params, ":mark-as-read")};
|
||||||
|
|
||||||
GError *gerr{};
|
GError *gerr{};
|
||||||
MuMsg *msg{};
|
MuMsg *msg{};
|
||||||
|
|
||||||
if (!path.empty())
|
if (!path.empty()) {
|
||||||
msg = mu_msg_new_from_file (path.c_str(), NULL, &gerr);
|
/* only use for old view (embedded msgs) */
|
||||||
else {
|
msg = mu_msg_new_from_file (path.c_str(), NULL, &gerr);
|
||||||
docid = determine_docids(query(), params).at(0);
|
} else {
|
||||||
msg = store().find_message(docid);
|
docids = determine_docids(query(), params);
|
||||||
|
msg = store().find_message(docids.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msg)
|
if (!msg)
|
||||||
throw Error{Error::Code::Store, &gerr,
|
throw Error{Error::Code::Store, &gerr,
|
||||||
"failed to find message for view"};
|
"failed to find message for view"};
|
||||||
|
|
||||||
if (mark_as_read)
|
if (mark_as_read) {
|
||||||
maybe_mark_as_read (store(), msg, docid);
|
/* mark _all_ messsage with given docid as read. */
|
||||||
|
for (auto&& docid: docids)
|
||||||
|
maybe_mark_as_read (store(), msg, docid);
|
||||||
|
}
|
||||||
|
|
||||||
Sexp::List seq;
|
Sexp::List seq;
|
||||||
seq.add_prop(":view", build_message_sexp(msg, docid, {}, message_options(params)));
|
seq.add_prop(":view", build_message_sexp(
|
||||||
|
msg, docids.at(0), {}, message_options(params)));
|
||||||
mu_msg_unref(msg);
|
mu_msg_unref(msg);
|
||||||
|
|
||||||
output_sexp (std::move(seq));
|
output_sexp (std::move(seq));
|
||||||
|
|||||||
Reference in New Issue
Block a user