only send necessary data

This commit is contained in:
m 2023-01-02 10:39:34 -06:00
parent 58d8b085ac
commit 8185fd550c
2 changed files with 33 additions and 31 deletions

View File

@ -1,4 +1,5 @@
#include <std_include.hpp>
#include <utils/http.hpp>
#include "../services.hpp"
@ -13,40 +14,41 @@ namespace demonware
void bdMarketingComms::getMessages(service_server* server, byte_buffer* /*buffer*/) const
{
auto motd_content = utils::http::get_data("https://h1.gg/data/motd.json");
auto motd = new bdMarketingMessage;
auto reply = server->create_reply(this->task_id());
const auto motd_content = utils::http::get_data("https://h1.gg/data/motd.json");
if (motd_content.has_value())
{
const auto motd = new bdMarketingMessage;
motd->m_messageID = 1;
motd->m_languageCode = "en-US";
motd->m_content = motd_content.value().buffer.data();
motd->m_metadata = "{}";
reply->add(motd);
}
auto featured_content = utils::http::get_data("https://h1.gg/data/featured.json");
auto featured = new bdMarketingMessage;
const auto featured_content = utils::http::get_data("https://h1.gg/data/featured.json");
if (featured_content.has_value())
{
const auto featured = new bdMarketingMessage;
featured->m_messageID = 2;
featured->m_languageCode = "en-US";
featured->m_content = featured_content.value().buffer.data();
featured->m_metadata = "{}";
reply->add(featured);
}
auto featured2_content = utils::http::get_data("https://h1.gg/data/featured2.json");
auto featured2 = new bdMarketingMessage;
const auto featured2_content = utils::http::get_data("https://h1.gg/data/featured2.json");
if (featured2_content.has_value())
{
const auto featured2 = new bdMarketingMessage;
featured2->m_messageID = 3;
featured2->m_languageCode = "en-US";
featured2->m_content = featured2_content.value().buffer.data();
featured2->m_metadata = "{}";
reply->add(featured2);
}
auto reply = server->create_reply(this->task_id());
reply->add(motd);
reply->add(featured);
reply->add(featured2);
reply->send();
}