Skip to content

Commit

Permalink
fix: build_json for threads now works on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaskowicz1 committed Oct 9, 2023
1 parent d9ef508 commit fc0f10d
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions src/dpp/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit fc0f10d

Please sign in to comment.