From dfb0b85d1accad8a064a6947c422e9f743b642d9 Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Fri, 20 Oct 2023 20:32:40 +0100 Subject: [PATCH] fix: webhook now uses utility::mime_type --- src/dpp/webhook.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/dpp/webhook.cpp b/src/dpp/webhook.cpp index 9915a95eee..97d34631e4 100644 --- a/src/dpp/webhook.cpp +++ b/src/dpp/webhook.cpp @@ -96,19 +96,13 @@ json webhook::to_json_impl(bool with_id) const { } webhook& webhook::load_image(const std::string &image_blob, const image_type type, bool is_base64_encoded) { - static const std::map mimetypes = { - { i_gif, "image/gif" }, - { i_jpg, "image/jpeg" }, - { i_png, "image/png" }, - { i_webp, "image/webp" }, - }; if (image_blob.size() > MAX_ICON_SIZE) { throw dpp::length_exception("Webhook icon file exceeds discord limit of 256 kilobytes"); } /* If there's already image data defined, free the old data, to prevent a memory leak */ delete image_data; - image_data = new std::string("data:" + mimetypes.find(type)->second + ";base64," + (is_base64_encoded ? image_blob : base64_encode((unsigned char const*)image_blob.data(), (unsigned int)image_blob.length()))); + image_data = new std::string("data:" + utility::mime_type(type) + ";base64," + (is_base64_encoded ? image_blob : base64_encode((unsigned char const*)image_blob.data(), (unsigned int)image_blob.length()))); return *this; }