From 3f6b6033408b9d621cfa4e9137070dada3cc8321 Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Mon, 9 Oct 2023 11:20:08 +0100 Subject: [PATCH 1/3] fix: threads now send correctly to discord --- src/dpp/channel.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/dpp/channel.cpp b/src/dpp/channel.cpp index 00a4db96a6..8971f2fb20 100644 --- a/src/dpp/channel.cpp +++ b/src/dpp/channel.cpp @@ -478,14 +478,34 @@ channel& channel::fill_from_json(json* j) { } std::string thread::build_json(bool with_id) const { - json j = json::parse(channel::build_json(with_id)); - j["type"] = (flags & CHANNEL_TYPE_MASK); - j["thread_metadata"] = this->metadata; - if (!this->applied_tags.empty()) { - j["applied_tags"] = json::array(); - for (auto &tag_id: this->applied_tags) { - if (tag_id) { - j["applied_tags"].push_back(tag_id); + json j; + j["name"] = this->name; + j["archived"] = this->metadata.archived; + j["auto_archive_duration"] = this->metadata.auto_archive_duration; + j["locked"] = this->metadata.locked; + + if(this->get_type() == dpp::channel_type::CHANNEL_PRIVATE_THREAD) { + j["invitable"] = this->metadata.invitable; + } + + j["rate_limit_per_user"] = this->rate_limit_per_user; + + if (is_forum() || is_media_channel()) { + + uint32_t _flags = (flags & dpp::c_require_tag) ? dc_require_tag : 0; + if (is_media_channel()) { + _flags |= (flags & dpp::c_hide_media_download_options) ? dc_hide_media_download_options : 0; + } + if (_flags) { + j["flags"] = _flags; + } + + if (!this->applied_tags.empty()) { + j["applied_tags"] = json::array(); + for (auto &tag_id: this->applied_tags) { + if (tag_id) { + j["applied_tags"].push_back(tag_id); + } } } } From d9ef508e92a3a76de8726265bdbdd548f8ceea64 Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Mon, 9 Oct 2023 11:27:21 +0100 Subject: [PATCH 2/3] fix: changed 487 in channel.cpp to be better --- src/dpp/channel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dpp/channel.cpp b/src/dpp/channel.cpp index 8971f2fb20..f186f8c62e 100644 --- a/src/dpp/channel.cpp +++ b/src/dpp/channel.cpp @@ -484,7 +484,7 @@ std::string thread::build_json(bool with_id) const { j["auto_archive_duration"] = this->metadata.auto_archive_duration; j["locked"] = this->metadata.locked; - if(this->get_type() == dpp::channel_type::CHANNEL_PRIVATE_THREAD) { + if(is_private_thread()) { j["invitable"] = this->metadata.invitable; } From fc0f10d3467210e8f6c7120f6ae413a7889aaffb Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Mon, 9 Oct 2023 12:41:03 +0100 Subject: [PATCH 3/3] fix: build_json for threads now works on creation --- src/dpp/channel.cpp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/dpp/channel.cpp b/src/dpp/channel.cpp index f186f8c62e..7f90c7eaa2 100644 --- a/src/dpp/channel.cpp +++ b/src/dpp/channel.cpp @@ -478,34 +478,21 @@ channel& channel::fill_from_json(json* j) { } std::string thread::build_json(bool with_id) const { - json j; - j["name"] = this->name; + json j = json::parse(channel::build_json(with_id)); + j["type"] = (flags & CHANNEL_TYPE_MASK); j["archived"] = this->metadata.archived; j["auto_archive_duration"] = this->metadata.auto_archive_duration; j["locked"] = this->metadata.locked; - if(is_private_thread()) { + if(this->get_type() == dpp::channel_type::CHANNEL_PRIVATE_THREAD) { j["invitable"] = this->metadata.invitable; } - j["rate_limit_per_user"] = this->rate_limit_per_user; - - if (is_forum() || is_media_channel()) { - - uint32_t _flags = (flags & dpp::c_require_tag) ? dc_require_tag : 0; - if (is_media_channel()) { - _flags |= (flags & dpp::c_hide_media_download_options) ? dc_hide_media_download_options : 0; - } - if (_flags) { - j["flags"] = _flags; - } - - if (!this->applied_tags.empty()) { - j["applied_tags"] = json::array(); - for (auto &tag_id: this->applied_tags) { - if (tag_id) { - j["applied_tags"].push_back(tag_id); - } + if (!this->applied_tags.empty()) { + j["applied_tags"] = json::array(); + for (auto &tag_id: this->applied_tags) { + if (tag_id) { + j["applied_tags"].push_back(tag_id); } } }