server: fix read-mark propagation

Whenever a message is flagged as 'read', do the same for all the duplicates as well.
This used to work, make it work again.

Fixes #2277
This commit is contained in:
Dirk-Jan C. Binnema
2022-06-29 08:59:40 +03:00
parent 98b0353c00
commit c4ed3e6ba7

View File

@ -571,7 +571,8 @@ docids_for_msgid(const Store& store, const std::string& msgid, size_t max = 100)
if (msgid.size() > MaxTermLength) { if (msgid.size() > MaxTermLength) {
throw Error(Error::Code::InvalidArgument, throw Error(Error::Code::InvalidArgument,
"invalid message-id '%s'", msgid.c_str()); "invalid message-id '%s'", msgid.c_str());
} } else if (msgid.empty())
return {};
const auto xprefix{field_from_id(Field::Id::MessageId).shortcut}; const auto xprefix{field_from_id(Field::Id::MessageId).shortcut};
/*XXX this is a bit dodgy */ /*XXX this is a bit dodgy */
@ -1047,11 +1048,8 @@ Server::Private::maybe_mark_as_read(Store::Id docid, Flags oldflags, bool rename
} }
bool bool
Server::Private::maybe_mark_msgid_as_read(const std::string& msgid, bool rename) try { Server::Private::maybe_mark_msgid_as_read(const std::string& msgid, bool rename) try
{
if (!msgid.empty())
return false; // nothing to do.
const auto docids = docids_for_msgid(store_, msgid); const auto docids = docids_for_msgid(store_, msgid);
if (!docids.empty()) if (!docids.empty())
g_debug("marking %zu messages with message-id '%s' as read", g_debug("marking %zu messages with message-id '%s' as read",
@ -1062,6 +1060,7 @@ Server::Private::maybe_mark_msgid_as_read(const std::string& msgid, bool rename)
maybe_mark_as_read(docid, msg->flags(), rename); maybe_mark_as_read(docid, msg->flags(), rename);
return true; return true;
} catch (...) { /* not fatal */ } catch (...) { /* not fatal */
g_warning("failed to mark <%s> as read", msgid.c_str()); g_warning("failed to mark <%s> as read", msgid.c_str());
return false; return false;
@ -1099,8 +1098,7 @@ Server::Private::view_handler(const Parameters& params)
Server::Server(Store& store, Server::Output output) Server::Server(Store& store, Server::Output output)
: priv_{std::make_unique<Private>(store, output)} : priv_{std::make_unique<Private>(store, output)}
{ {}
}
Server::~Server() = default; Server::~Server() = default;