From 627d512c473b8429128869f77d4b2fbbe741d067 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Mon, 19 Aug 2024 08:41:10 +0300
Subject: viewer#2311 When email or profile image upload fails show a more
 fitting reason

---
 indra/newview/llviewerassetupload.cpp                |  8 +++++++-
 indra/newview/llwebprofile.cpp                       |  5 +++++
 indra/newview/llwebprofile.h                         |  2 ++
 indra/newview/skins/default/xui/en/notifications.xml | 20 ++++++++++++++++++++
 4 files changed, 34 insertions(+), 1 deletion(-)

(limited to 'indra')

diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp
index b74b48b9f6..7ef2c8d697 100644
--- a/indra/newview/llviewerassetupload.cpp
+++ b/indra/newview/llviewerassetupload.cpp
@@ -984,6 +984,7 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res
         label = result["label"].asString();
     }
 
+    LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::findInstance();
     if (result.has("message"))
     {
         reason = result["message"].asString();
@@ -994,6 +995,12 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res
         {
         case 404:
             reason = LLTrans::getString("AssetUploadServerUnreacheble");
+            if (floater_snapshot
+                && floater_snapshot->isWaitingState()
+                && uploadInfo->getAssetType() == LLAssetType::AT_IMAGE_JPEG)
+            {
+                label = "CannotUploadSnapshotEmailTooBig";
+            }
             break;
         case 499:
             reason = LLTrans::getString("AssetUploadServerDifficulties");
@@ -1030,7 +1037,6 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res
     // Todo: move these floater specific actions into proper callbacks
 
     // Let the Snapshot floater know we have failed uploading.
-    LLFloaterSnapshot* floater_snapshot = LLFloaterSnapshot::findInstance();
     if (floater_snapshot && floater_snapshot->isWaitingState())
     {
         if (uploadInfo->getAssetType() == LLAssetType::AT_IMAGE_JPEG)
diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp
index 83e417633a..feb5ecb1fb 100644
--- a/indra/newview/llwebprofile.cpp
+++ b/indra/newview/llwebprofile.cpp
@@ -38,6 +38,7 @@
 // newview
 #include "llavataractions.h" // for getProfileURL()
 #include "llviewermedia.h" // FIXME: don't use LLViewerMedia internals
+#include "llnotificationsutil.h"
 
 #include "llcorehttputil.h"
 
@@ -132,6 +133,10 @@ void LLWebProfile::uploadImageCoro(LLPointer<LLImageFormatted> image, std::strin
 
     if (!status)
     {
+        if (image->getDataSize() > MAX_WEB_DATASIZE)
+        {
+            LLNotificationsUtil::add("CannotUploadSnapshotWebTooBig");
+        }
         LL_WARNS("Snapshots") << "Failed to get image upload config" << LL_ENDL;
         LLWebProfile::reportImageUploadStatus(false);
         return;
diff --git a/indra/newview/llwebprofile.h b/indra/newview/llwebprofile.h
index 335282bf13..a9cfa102c0 100644
--- a/indra/newview/llwebprofile.h
+++ b/indra/newview/llwebprofile.h
@@ -57,6 +57,8 @@ public:
     static void setAuthCookie(const std::string& cookie);
     static void setImageUploadResultCallback(status_callback_t cb) { mStatusCallback = cb; }
 
+    static constexpr S32 MAX_WEB_DATASIZE = 8 * 1024 * 1024; // 8MB
+
 private:
     static LLCore::HttpHeaders::ptr_t buildDefaultHeaders();
 
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index 91b137b75f..e539388735 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -2388,6 +2388,26 @@ Unable to upload [FILE] due to the following reason: [REASON]
 Please try again later.
   <tag>fail</tag>
   </notification>
+    
+  <notification
+   icon="alertmodal.tga"
+   name="CannotUploadSnapshotEmailTooBig"
+   type="alertmodal">
+Unable to upload snapshot [FILE] due to the following reason: [REASON]
+
+File might be too big, try reducing resolution, quality or try again later.
+  <tag>fail</tag>
+  </notification>
+    
+  <notification
+   icon="alertmodal.tga"
+   name="CannotUploadSnapshotWebTooBig"
+   type="alertmodal">
+Unable to upload snapshot.
+
+File might be too big, try reducing resolution or try again later.
+  <tag>fail</tag>
+  </notification>
 
   <notification
    icon="notifytip.tga"
-- 
cgit v1.2.3