mirror of https://github.com/djcb/mu.git
server: Implement forwarding attachments
Using the new infra in Message.
This commit is contained in:
parent
5d9bb72c0b
commit
e13dd0da98
|
@ -445,13 +445,13 @@ maybe_add_attachment(Message& message, const MessagePart& part, size_t index)
|
||||||
if (!part.is_attachment())
|
if (!part.is_attachment())
|
||||||
return Nothing;
|
return Nothing;
|
||||||
|
|
||||||
const auto cache_path{message.cache_path()};
|
const auto cache_path{message.cache_path(index)};
|
||||||
if (!cache_path)
|
if (!cache_path)
|
||||||
throw cache_path.error();
|
throw cache_path.error();
|
||||||
|
|
||||||
const auto fname{format("%s/%zu-%s", cache_path->c_str(),
|
const auto cooked_name{part.cooked_filename()};
|
||||||
index, part.cooked_filename()
|
const auto fname{format("%s/%s", cache_path->c_str(),
|
||||||
.value_or("part").c_str())};
|
cooked_name.value_or("part").c_str())};
|
||||||
|
|
||||||
const auto res = part.to_file(fname, true);
|
const auto res = part.to_file(fname, true);
|
||||||
if (!res)
|
if (!res)
|
||||||
|
@ -461,6 +461,8 @@ maybe_add_attachment(Message& message, const MessagePart& part, size_t index)
|
||||||
|
|
||||||
if (auto cdescr = part.content_description(); cdescr)
|
if (auto cdescr = part.content_description(); cdescr)
|
||||||
pi.add_prop(":description", Sexp::make_string(*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(":file-name", Sexp::make_string(fname));
|
||||||
pi.add_prop(":mime-type", Sexp::make_string(
|
pi.add_prop(":mime-type", Sexp::make_string(
|
||||||
|
|
Loading…
Reference in New Issue