From a845587e1f0b74b087b0c59d1cdc8e6c5feaf98f Mon Sep 17 00:00:00 2001
From: dan <dan.abramov@gmail.com>
Date: Sat, 13 Apr 2024 05:50:09 +0100
Subject: [Embeds] Show error for users with PWI flag on landing (#3524)

---
 bskyembed/src/screens/landing.tsx | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

(limited to 'bskyembed/src/screens/landing.tsx')

diff --git a/bskyembed/src/screens/landing.tsx b/bskyembed/src/screens/landing.tsx
index 7c8ef2810..06b455981 100644
--- a/bskyembed/src/screens/landing.tsx
+++ b/bskyembed/src/screens/landing.tsx
@@ -86,7 +86,14 @@ function LandingPage() {
         if (!AppBskyFeedDefs.isThreadViewPost(data.thread)) {
           throw new Error('Post not found')
         }
-
+        const pwiOptOut = !!data.thread.post.author.labels?.find(
+          label => label.val === '!no-unauthenticated',
+        )
+        if (pwiOptOut) {
+          throw new Error(
+            'The author of this post has requested their posts not be displayed on external sites.',
+          )
+        }
         setThread(data.thread)
       } catch (err) {
         console.error(err)
@@ -113,25 +120,15 @@ function LandingPage() {
           className="border rounded-lg py-3 w-full max-w-[600px] px-4"
           placeholder={DEFAULT_POST}
         />
-        <p className={`text-red-500 ${error ? '' : 'invisible'}`}>{error}</p>
       </div>
 
       <img src={arrowBottom as string} className="w-6" />
 
       <div className="w-full max-w-[600px] gap-8 flex flex-col">
         {uri && !error && thread && <Snippet thread={thread} />}
-
-        {thread ? (
-          <Post thread={thread} key={thread.post.uri} />
-        ) : (
-          <Container href="https://bsky.social/about">
-            <Link
-              href="https://bsky.social/about"
-              className="transition-transform hover:scale-110 absolute top-4 right-4">
-              <img src={logo as string} className="h-8" />
-            </Link>
-            <div className="h-32" />
-          </Container>
+        {!error && thread && <Post thread={thread} key={thread.post.uri} />}
+        {error && (
+          <p className={`text-red-500 ${error ? '' : 'invisible'}`}>{error}</p>
         )}
       </div>
     </main>
-- 
cgit 1.4.1

