message: fall-back to received for dateless

For the (rare) messages without a Date: header, attempt to guess a date
from the top (most-recent) Received: header. Not perfect, of course, but
better than nothing.

Requires re-indexing to apply to already indexed messages.

Should help for #1083.
This commit is contained in:
Dirk-Jan C. Binnema
2026-07-30 23:38:45 +03:00
committed by Seth Ladygo
parent 4a8b797665
commit 54786e2e97
5 changed files with 86 additions and 15 deletions

View File

@ -741,7 +741,10 @@ fill_document(Message::Private& priv)
doc.add(field.id, priv.ctime);
break;
case Field::Id::Date:
if (const auto& date{mime_msg.date()}; date) {
/* for the rare message without a Date: header, fall back
* to the most recent Received: header */
if (const auto date{mime_msg.date().or_else([&]{
return mime_msg.received(); })}; date) {
doc.add(field.id, date->first);
doc.add(Field::Id::UtcOffset, date->second);
}