diff --git a/lib/message/mu-message-part.cc b/lib/message/mu-message-part.cc index dde57702..23758f8f 100644 --- a/lib/message/mu-message-part.cc +++ b/lib/message/mu-message-part.cc @@ -95,6 +95,15 @@ MessagePart::mime_type() const noexcept return Nothing; } +Option +MessagePart::content_description() const noexcept +{ + if (!mime_object().is_part()) + return Nothing; + else + return MimePart{mime_object()}.content_description(); +} + size_t MessagePart::size() const noexcept { diff --git a/lib/message/mu-message-part.hh b/lib/message/mu-message-part.hh index 624773c1..05e21eb7 100644 --- a/lib/message/mu-message-part.hh +++ b/lib/message/mu-message-part.hh @@ -87,6 +87,14 @@ public: */ Option mime_type() const noexcept; + + /** + * Get the content description for this part, or Nothing + * + * @return the content description + */ + Option content_description() const noexcept; + /** * Get the length of the (unencoded) MIME-part. * diff --git a/lib/mu-server.cc b/lib/mu-server.cc index a99e078f..c8e5cdd2 100644 --- a/lib/mu-server.cc +++ b/lib/mu-server.cc @@ -456,9 +456,14 @@ maybe_add_attachment(Message& message, const MessagePart& part, size_t index) throw res.error(); Sexp::List pi; - pi.add_prop(":file-name", Sexp::make_string(*cache_path)); - pi.add_prop(":mime-type", Sexp::make_string(part.mime_type() - .value_or("application/data"))); + + if (auto cdescr = part.content_description(); cdescr) + pi.add_prop(":description", Sexp::make_string(*cdescr)); + + pi.add_prop(":file-name", Sexp::make_string(fname)); + pi.add_prop(":mime-type", Sexp::make_string( + part.mime_type().value_or("application/octet-stream"))); + return Some(Sexp::make_list(std::move(pi))); } @@ -493,9 +498,12 @@ Server::Private::compose_handler(const Parameters& params) ++index; } } - if (!attseq.empty()) + if (!attseq.empty()) { comp_lst.add_prop(":include", Sexp::make_list(std::move(attseq))); + comp_lst.add_prop(":cache-path", + Sexp::make_string(*msg->cache_path())); + } } } else if (ctype != "new")