aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrueter <crueter@eden-emu.dev>2026-04-08 22:09:55 +0200
committercrueter <crueter@eden-emu.dev>2026-04-08 22:09:55 +0200
commitc05d99922599bef03a64eb61646e6fe6fdd5f7e6 (patch)
tree7b235b033128f6d128d1cc7c461a8be5cdd2a4ff
parent71d3dd67d33be457d178c6b4c3dedc7ef032afcc (diff)
[bcat] Fix news to use Forgejo releases instead (#3841)
Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3841
-rw-r--r--src/core/hle/service/bcat/news/builtin_news.cpp69
1 files changed, 53 insertions, 16 deletions
diff --git a/src/core/hle/service/bcat/news/builtin_news.cpp b/src/core/hle/service/bcat/news/builtin_news.cpp
index d24431cdbc..66cf5bb697 100644
--- a/src/core/hle/service/bcat/news/builtin_news.cpp
+++ b/src/core/hle/service/bcat/news/builtin_news.cpp
@@ -35,7 +35,8 @@
namespace Service::News {
namespace {
-constexpr const char* GitHubAPI_EdenReleases = "/repos/eden-emulator/Releases/releases";
+// TODO(crueter): COMPILE DEFINITION
+constexpr const char* GitHubAPI_EdenReleases = "/api/v1/repos/eden-emu/eden/releases";
// Cached logo data
std::vector<u8> default_logo_small;
@@ -227,22 +228,58 @@ void WriteCachedJson(std::string_view json) {
std::optional<std::string> DownloadReleasesJson() {
try {
- httplib::SSLClient cli{"api.github.com", 443};
- cli.set_connection_timeout(10);
- cli.set_read_timeout(10);
+#ifdef YUZU_BUNDLED_OPENSSL
+ const auto url = "https://git.eden-emu.dev";
+#else
+ const auto url = "git.eden-emu.dev";
+#endif
- httplib::Headers headers{
- {"User-Agent", "Eden"},
- {"Accept", "application/vnd.github+json"},
- };
+ // TODO(crueter): This is duplicated between frontend and here.
+ constexpr auto path = GitHubAPI_EdenReleases;
+
+ constexpr std::size_t timeout_seconds = 15;
+
+ std::unique_ptr<httplib::Client> client = std::make_unique<httplib::Client>(url);
+ client->set_connection_timeout(timeout_seconds);
+ client->set_read_timeout(timeout_seconds);
+ client->set_write_timeout(timeout_seconds);
- // TODO(crueter): automate this in some way...
#ifdef YUZU_BUNDLED_OPENSSL
- cli.load_ca_cert_store(kCert, sizeof(kCert));
+ client->load_ca_cert_store(kCert, sizeof(kCert));
#endif
- if (auto res = cli.Get(GitHubAPI_EdenReleases, headers); res && res->status < 400) {
- return res->body;
+ if (client == nullptr) {
+ LOG_ERROR(Service_BCAT, "Invalid URL {}{}", url, path);
+ return {};
+ }
+
+ httplib::Request request{
+ .method = "GET",
+ .path = path,
+ };
+
+ client->set_follow_location(true);
+ httplib::Result result = client->send(request);
+
+ if (!result) {
+ LOG_ERROR(Service_BCAT, "GET to {}{} returned null", url, path);
+ return {};
+ } else if (result->status < 400) {
+ return result->body;
+ }
+
+ if (result->status >= 400) {
+ LOG_ERROR(Service_BCAT,
+ "GET to {}{} returned error status code: {}",
+ url,
+ path,
+ result->status);
+ return {};
+ }
+
+ if (!result->headers.contains("content-type")) {
+ LOG_ERROR(Service_BCAT, "GET to {}{} returned no content", url, path);
+ return {};
}
} catch (...) {
LOG_WARNING(Service_BCAT, " failed to download releases");
@@ -332,7 +369,7 @@ std::string FormatBody(const nlohmann::json& release, std::string_view title) {
body.pop_back();
}
- body += "\n\n... View more on GitHub";
+ body += "\n\n... View more on Forgejo";
}
return body;
@@ -489,7 +526,7 @@ std::vector<u8> BuildMsgpack(std::string_view title, std::string_view body,
w.WriteString("");
w.WriteKey("allow_domains");
- w.WriteString("^https?://github.com(/|$)");
+ w.WriteString("^https?://git.eden-emu.dev(/|$)");
// More link
w.WriteKey("more");
@@ -499,7 +536,7 @@ std::vector<u8> BuildMsgpack(std::string_view title, std::string_view body,
w.WriteKey("url");
w.WriteString(html_url);
w.WriteKey("text");
- w.WriteString("Open GitHub");
+ w.WriteString("Open Forgejo");
// Body
w.WriteKey("body");
@@ -536,7 +573,7 @@ void EnsureBuiltinNewsLoaded() {
if (const auto fresh = DownloadReleasesJson()) {
WriteCachedJson(*fresh);
ImportReleases(*fresh);
- LOG_DEBUG(Service_BCAT, "news: {} entries updated from GitHub", NewsStorage::Instance().ListAll().size());
+ LOG_DEBUG(Service_BCAT, "news: {} entries updated from Forgejo", NewsStorage::Instance().ListAll().size());
}
}).detach();
});