diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-06-17 02:46:55 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2022-06-17 02:46:55 -0400 |
commit | 4ee7025ab09b606a2556bf9f42c1218d7fd72843 (patch) | |
tree | 4b7747da4be59e672d649e254474d09cab0f01c0 /src/discord | |
parent | d0fa308f6e339b94044d39bf0e76b8221da48c3a (diff) | |
download | abaddon-portaudio-4ee7025ab09b606a2556bf9f42c1218d7fd72843.tar.gz abaddon-portaudio-4ee7025ab09b606a2556bf9f42c1218d7fd72843.zip |
add file upload via dnd + rework http
Diffstat (limited to 'src/discord')
-rw-r--r-- | src/discord/chatsubmitparams.hpp | 4 | ||||
-rw-r--r-- | src/discord/discord.cpp | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/discord/chatsubmitparams.hpp b/src/discord/chatsubmitparams.hpp index 0f0a0cd..6199634 100644 --- a/src/discord/chatsubmitparams.hpp +++ b/src/discord/chatsubmitparams.hpp @@ -2,6 +2,7 @@ #include <vector> #include <string> #include <glibmm/ustring.h> +#include <giomm/file.h> #include "discord/snowflake.hpp" struct ChatSubmitParams { @@ -11,8 +12,9 @@ struct ChatSubmitParams { }; struct Attachment { - std::string Path; + Glib::RefPtr<Gio::File> File; AttachmentType Type; + std::string Filename; }; Snowflake ChannelID; diff --git a/src/discord/discord.cpp b/src/discord/discord.cpp index 9849ae6..d26f1fe 100644 --- a/src/discord/discord.cpp +++ b/src/discord/discord.cpp @@ -480,13 +480,12 @@ void DiscordClient::SendChatMessageAttachments(const ChatSubmitParams ¶ms, c req.add_field("payload_json", nlohmann::json(obj).dump().c_str(), CURL_ZERO_TERMINATED); for (size_t i = 0; i < params.Attachments.size(); i++) { const auto field_name = "files[" + std::to_string(i) + "]"; - req.add_file(field_name, params.Attachments.at(i).Path, "unknown.png"); + req.add_file(field_name, params.Attachments.at(i).File, params.Attachments.at(i).Filename); } m_http.Execute(std::move(req), [this, params, nonce, callback](const http::response_type &res) { for (const auto &attachment : params.Attachments) { if (attachment.Type == ChatSubmitParams::AttachmentType::PastedImage) { - std::error_code ec; - std::filesystem::remove(attachment.Path, ec); + attachment.File->remove(); } } ChatMessageCallback(nonce, res, callback); |