From fc0f10d3467210e8f6c7120f6ae413a7889aaffb Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Mon, 9 Oct 2023 12:41:03 +0100 Subject: [PATCH] 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); } } }