about summary refs log tree commit diff
path: root/bskyweb/cmd
diff options
context:
space:
mode:
authorCaidan <caidan@internet.dev>2025-09-17 14:30:10 -0700
committerGitHub <noreply@github.com>2025-09-17 14:30:10 -0700
commitac71ea235f27234a34e5005af03935f80a9d1092 (patch)
treeafb869bbcc6f4313e2ce7942c016d40c4a726d52 /bskyweb/cmd
parent5e78c947a0853792900f76d17bd9468983ad51b6 (diff)
downloadvoidsky-ac71ea235f27234a34e5005af03935f80a9d1092.tar.zst
improve: enhance post OpenGraph metadata with engagement data and auth handling (#9046)
Diffstat (limited to 'bskyweb/cmd')
-rw-r--r--bskyweb/cmd/bskyweb/server.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go
index 8d75bb6ef..672e8d25e 100644
--- a/bskyweb/cmd/bskyweb/server.go
+++ b/bskyweb/cmd/bskyweb/server.go
@@ -488,20 +488,26 @@ func (srv *Server) WebPost(c echo.Context) error {
 		}
 	}
 
+	req := c.Request()
 	if !unauthedViewingOkay {
+		// Provide minimal OpenGraph data for auth-required posts
+		data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path)
+		data["requiresAuth"] = true
+		data["profileHandle"] = pv.Handle
+		if pv.DisplayName != nil {
+			data["profileDisplayName"] = *pv.DisplayName
+		}
 		return c.Render(http.StatusOK, "post.html", data)
 	}
-	did := pv.Did
-	data["did"] = did
 
 	// then fetch the post thread (with extra context)
-	uri := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", did, rkey)
+	uri := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", pv.Did, rkey)
 	tpv, err := appbsky.FeedGetPostThread(ctx, srv.xrpcc, 1, 0, uri)
 	if err != nil {
 		log.Warnf("failed to fetch post: %s\t%v", uri, err)
 		return c.Render(http.StatusOK, "post.html", data)
 	}
-	req := c.Request()
+
 	postView := tpv.Thread.FeedDefs_ThreadViewPost.Post
 	data["postView"] = postView
 	data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path)