feat(Api): Add more api endpoints to the scui api (#714)

* feat(Api): Add send message to player database
* feat(cpr): Disabling test build
* feat(Api): Fix max message length
* feat(Api): Download job for creator menu
This commit is contained in:
Bugisoft
2022-12-22 11:49:34 +01:00
committed by GitHub
parent 1dda472562
commit 9d9d438b5d
7 changed files with 110 additions and 10 deletions

View File

@ -3,6 +3,7 @@
#include "pointers.hpp"
#include "services/players/player_service.hpp"
#include "services/player_database/player_database_service.hpp"
#include "services/api/api_service.hpp"
#include "core/data/block_join_reasons.hpp"
#include "core/data/infractions.hpp"
#include "util/session.hpp"
@ -108,6 +109,21 @@ namespace big
session::join_by_rockstar_id(current_player.rockstar_id);
});
static char message[256];
ImGui::InputText("Input Message", message, sizeof(message));
if (components::button("Send Message"))
{
g_thread_pool->push([selected]
{
if (g_api_service->send_socialclub_message(selected->rockstar_id, message))
{
g_notification_service->push("SCAPI", "Message successfully sent");
return;
}
g_notification_service->push_error("SCAPI", "Message not sent. Are you connected to the internet?");
});
};
if (ImGui::Button("Save"))
{
if (current_player.rockstar_id != selected->rockstar_id)

View File

@ -2,7 +2,9 @@
#include "script.hpp"
#include "views/view.hpp"
#include "services/creator_storage/creator_storage_service.hpp"
#include "services/api/api_service.hpp"
#include "util/scripts.hpp"
#include "thread_pool.hpp"
static bool cached_creator_files = false;
static std::vector<std::string> creator_files;
@ -72,6 +74,37 @@ namespace big
cached_creator_files = false;
});
ImGui::Separator();
static char job_link[69]{};
ImGui::InputText("SocialClub Job Link", job_link, sizeof(job_link));
components::button("Import", []
{
g_thread_pool->push([]
{
nlohmann::json job_details;
if (g_api_service->get_job_details(job_link, job_details))
{
std::string img_src = job_details["content"]["imgSrc"];
std::string content_part = img_src.substr(53, 27);
nlohmann::json job_metadata;
if (g_api_service->download_job_metadata(content_part))
{
cached_creator_files = false;
g_notification_service->push("Job Import", "Job Import successfully done");
}
else {
g_notification_service->push_error("Job Import", "Couldn't download the job metadata");
}
} else {
g_notification_service->push_error("Job Import", "Couldn't get the job details");
}
});
});
ImGui::EndGroup();
components::sub_title("Launch Creator");