From af94da150a0376f48a1a7d8312796ddbb2bf5d4a Mon Sep 17 00:00:00 2001
From: automated-signal <37887102+automated-signal@users.noreply.github.com>
Date: Mon, 9 Sep 2024 17:03:39 -0500
Subject: [PATCH] getQuoteAttachment: Handle attachments with no path

Co-authored-by: Scott Nonnenberg <scott@signal.org>
---
 ts/util/makeQuote.ts | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/ts/util/makeQuote.ts b/ts/util/makeQuote.ts
index 4c6a24fc6f8..f25733b3b5b 100644
--- a/ts/util/makeQuote.ts
+++ b/ts/util/makeQuote.ts
@@ -80,14 +80,13 @@ export async function getQuoteAttachment(
         return {
           contentType: isGIFQuote ? IMAGE_GIF : contentType,
           fileName,
-          thumbnail: thumbnail
-            ? {
-                ...(await loadAttachmentData(thumbnail)),
-                objectUrl: thumbnail.path
-                  ? getLocalAttachmentUrl(thumbnail)
-                  : undefined,
-              }
-            : undefined,
+          thumbnail:
+            thumbnail && thumbnail.path
+              ? {
+                  ...(await loadAttachmentData(thumbnail)),
+                  objectUrl: getLocalAttachmentUrl(thumbnail),
+                }
+              : undefined,
         };
       })
     );
@@ -103,14 +102,13 @@ export async function getQuoteAttachment(
 
         return {
           contentType,
-          thumbnail: image
-            ? {
-                ...(await loadAttachmentData(image)),
-                objectUrl: image.path
-                  ? getLocalAttachmentUrl(image)
-                  : undefined,
-              }
-            : undefined,
+          thumbnail:
+            image && image.path
+              ? {
+                  ...(await loadAttachmentData(image)),
+                  objectUrl: getLocalAttachmentUrl(image),
+                }
+              : undefined,
         };
       })
     );
@@ -122,10 +120,12 @@ export async function getQuoteAttachment(
     return [
       {
         contentType,
-        thumbnail: {
-          ...(await loadAttachmentData(sticker.data)),
-          objectUrl: path ? getLocalAttachmentUrl(sticker.data) : undefined,
-        },
+        thumbnail: path
+          ? {
+              ...(await loadAttachmentData(sticker.data)),
+              objectUrl: getLocalAttachmentUrl(sticker.data),
+            }
+          : undefined,
       },
     ];
   }