mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't create embeds of profiles/posts from users who ask not to be sh… (#2189)

* Don't create embeds of profiles/posts from users who ask not to be shown in public views

* Formatting cleanup

* Bump workflow file to build an image for this branch

authored by

Jaz and committed by
GitHub
bc427472 9ab0ff6f

+35 -17
+1
.github/workflows/build-and-push-bskyweb-aws.yaml
··· 4 4 branches: 5 5 - main 6 6 - traffic-reduction 7 + - respect-optout-for-embeds 7 8 env: 8 9 REGISTRY: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_REGISTRY }} 9 10 USERNAME: ${{ secrets.AWS_ECR_REGISTRY_USEAST2_PACKAGES_USERNAME }}
+34 -17
bskyweb/cmd/bskyweb/server.go
··· 296 296 if err != nil { 297 297 log.Warnf("failed to fetch handle: %s\t%v", handle, err) 298 298 } else { 299 - did := pv.Did 300 - data["did"] = did 299 + unauthedViewingOkay := true 300 + for _, label := range pv.Labels { 301 + if label.Src == pv.Did && label.Val == "!no-unauthenticated" { 302 + unauthedViewingOkay = false 303 + } 304 + } 305 + 306 + if unauthedViewingOkay { 307 + did := pv.Did 308 + data["did"] = did 301 309 302 - // then fetch the post thread (with extra context) 303 - uri := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", did, rkey) 304 - tpv, err := appbsky.FeedGetPostThread(ctx, srv.xrpcc, 1, uri) 305 - if err != nil { 306 - log.Warnf("failed to fetch post: %s\t%v", uri, err) 307 - } else { 308 - req := c.Request() 309 - postView := tpv.Thread.FeedDefs_ThreadViewPost.Post 310 - data["postView"] = postView 311 - data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path) 312 - if postView.Embed != nil && postView.Embed.EmbedImages_View != nil { 313 - data["imgThumbUrl"] = postView.Embed.EmbedImages_View.Images[0].Thumb 310 + // then fetch the post thread (with extra context) 311 + uri := fmt.Sprintf("at://%s/app.bsky.feed.post/%s", did, rkey) 312 + tpv, err := appbsky.FeedGetPostThread(ctx, srv.xrpcc, 1, uri) 313 + if err != nil { 314 + log.Warnf("failed to fetch post: %s\t%v", uri, err) 315 + } else { 316 + req := c.Request() 317 + postView := tpv.Thread.FeedDefs_ThreadViewPost.Post 318 + data["postView"] = postView 319 + data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path) 320 + if postView.Embed != nil && postView.Embed.EmbedImages_View != nil { 321 + data["imgThumbUrl"] = postView.Embed.EmbedImages_View.Images[0].Thumb 322 + } 314 323 } 315 324 } 316 325 } ··· 329 338 if err != nil { 330 339 log.Warnf("failed to fetch handle: %s\t%v", handle, err) 331 340 } else { 332 - req := c.Request() 333 - data["profileView"] = pv 334 - data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path) 341 + unauthedViewingOkay := true 342 + for _, label := range pv.Labels { 343 + if label.Src == pv.Did && label.Val == "!no-unauthenticated" { 344 + unauthedViewingOkay = false 345 + } 346 + } 347 + if unauthedViewingOkay { 348 + req := c.Request() 349 + data["profileView"] = pv 350 + data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path) 351 + } 335 352 } 336 353 } 337 354