server/message-part: restore forwarding attachments

This commit is contained in:
Dirk-Jan C. Binnema 2022-05-05 23:45:11 +03:00
parent 62e546a4e2
commit e0d047105b
3 changed files with 29 additions and 4 deletions

View File

@ -95,6 +95,15 @@ MessagePart::mime_type() const noexcept
return Nothing;
}
Option<std::string>
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
{

View File

@ -87,6 +87,14 @@ public:
*/
Option<std::string> mime_type() const noexcept;
/**
* Get the content description for this part, or Nothing
*
* @return the content description
*/
Option<std::string> content_description() const noexcept;
/**
* Get the length of the (unencoded) MIME-part.
*

View File

@ -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")