Update relayreg.cpp — serialize displays JSON array in registerHost

This commit is contained in:
Zac Gaetano 2026-05-06 19:50:14 -04:00
parent 5f9661605c
commit ece712ec61

View file

@ -11,6 +11,7 @@
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
#include <vector>
namespace wg { namespace wg {
@ -151,8 +152,27 @@ bool RelayReg::deleteVPNPeer(const std::string &peerId, std::string &errOut) {
// ── registerHost ────────────────────────────────────────────────────────────── // ── registerHost ──────────────────────────────────────────────────────────────
bool RelayReg::registerHost(const std::string &name, const std::string &wgIP, bool RelayReg::registerHost(const std::string &name, const std::string &wgIP,
int port, std::string &errOut) { int port, const std::vector<DisplayInfo> &displays,
json body = { {"name", name}, {"wg_ip", wgIP}, {"port", port} }; std::string &errOut) {
// Build displays JSON array
json displaysArr = json::array();
for (const auto &d : displays) {
displaysArr.push_back({
{"name", d.name},
{"friendlyName", d.friendlyName},
{"width", d.width},
{"height", d.height},
{"isPrimary", d.isPrimary}
});
}
json body = {
{"name", name},
{"wg_ip", wgIP},
{"port", port},
{"displays", displaysArr}
};
std::string resp; std::string resp;
int code = request("POST", "/api/host/register", body.dump(), resp); int code = request("POST", "/api/host/register", body.dump(), resp);
if (code != 200 && code != 201) { if (code != 200 && code != 201) {