From 1660cac80d4eb97812dd488e0c5020542a26f10c Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Thu, 31 Aug 2023 22:31:11 +0300
Subject: [PATCH] SL-20243 Make viewer notice 403 from release-notes URL and
 handle it

---
 indra/newview/llstartup.cpp | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 1b0a814c458..5b41571eb17 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2419,6 +2419,34 @@ void login_callback(S32 option, void *userdata)
 	}
 }
 
+void release_notes_coro(const std::string url)
+{
+    if (url.empty())
+    {
+        return;
+    }
+
+    LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+    LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+        httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("releaseNotesCoro", httpPolicy));
+    LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+    LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
+
+    httpOpts->setHeadersOnly(true); // only making sure it isn't 404 or something like that
+
+    LLSD result = httpAdapter->getAndSuspend(httpRequest, url, httpOpts);
+
+    LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+    LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+    if (!status)
+    {
+        return;
+    }
+
+    LLWeb::loadURLInternal(url);
+}
+
 /**
 * Check if user is running a new version of the viewer.
 * Display the Release Notes if it's not overriden by the "UpdaterShowReleaseNotes" setting.
@@ -2451,7 +2479,8 @@ void show_release_notes_if_required()
             LLEventPumps::instance().obtain("relnotes").listen(
                 "showrelnotes",
                 [](const LLSD& url) {
-                LLWeb::loadURLInternal(url.asString());
+                    LLCoros::instance().launch("releaseNotesCoro",
+                    boost::bind(&release_notes_coro, url.asString()));
                 return false;
             });
         }
@@ -2459,7 +2488,9 @@ void show_release_notes_if_required()
 #endif // LL_RELEASE_FOR_DOWNLOAD
         {
             LLSD info(LLAppViewer::instance()->getViewerInfo());
-            LLWeb::loadURLInternal(info["VIEWER_RELEASE_NOTES_URL"]);
+            std::string url = info["VIEWER_RELEASE_NOTES_URL"].asString();
+            LLCoros::instance().launch("releaseNotesCoro",
+                                       boost::bind(&release_notes_coro, url));
         }
         release_notes_shown = true;
     }
-- 
GitLab