From e13dd0da98223ce1b3ab7e69d3658fb9ecd46cd8 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sun, 15 May 2022 11:33:14 +0300 Subject: [PATCH] server: Implement forwarding attachments Using the new infra in Message. --- lib/mu-server.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/mu-server.cc b/lib/mu-server.cc index b5fc59d7..d33c13e7 100644 --- a/lib/mu-server.cc +++ b/lib/mu-server.cc @@ -445,13 +445,13 @@ maybe_add_attachment(Message& message, const MessagePart& part, size_t index) if (!part.is_attachment()) return Nothing; - const auto cache_path{message.cache_path()}; + const auto cache_path{message.cache_path(index)}; if (!cache_path) throw cache_path.error(); - const auto fname{format("%s/%zu-%s", cache_path->c_str(), - index, part.cooked_filename() - .value_or("part").c_str())}; + const auto cooked_name{part.cooked_filename()}; + const auto fname{format("%s/%s", cache_path->c_str(), + cooked_name.value_or("part").c_str())}; const auto res = part.to_file(fname, true); if (!res) @@ -461,6 +461,8 @@ maybe_add_attachment(Message& message, const MessagePart& part, size_t index) if (auto cdescr = part.content_description(); cdescr) pi.add_prop(":description", Sexp::make_string(*cdescr)); + else if (cooked_name) + pi.add_prop(":description", Sexp::make_string(cooked_name.value())); pi.add_prop(":file-name", Sexp::make_string(fname)); pi.add_prop(":mime-type", Sexp::make_string(