about summary refs log tree commit diff
path: root/src/lib/api/feed/custom.ts
diff options
context:
space:
mode:
authorEric Bailey <git@esb.lol>2024-04-29 16:04:35 -0500
committerGitHub <noreply@github.com>2024-04-29 22:04:35 +0100
commita4e34537cee8e12a022238f054bee4fe22cc7325 (patch)
treee8ffbb4993441f64e4c112e9b046c566e577d661 /src/lib/api/feed/custom.ts
parentd893fe005d9d43e28b2926f8fed4f13165843d3b (diff)
downloadvoidsky-a4e34537cee8e12a022238f054bee4fe22cc7325.tar.zst
Send Bluesky feeds and suggested follows more data (#3695)
* WIP

* Fix constructors

* Clean up

* Tweak

* Rm extra assignment

* Narrow down the argument

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Diffstat (limited to 'src/lib/api/feed/custom.ts')
-rw-r--r--src/lib/api/feed/custom.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/api/feed/custom.ts b/src/lib/api/feed/custom.ts
index 75182c41f..87e45ceba 100644
--- a/src/lib/api/feed/custom.ts
+++ b/src/lib/api/feed/custom.ts
@@ -7,20 +7,25 @@ import {
 
 import {getContentLanguages} from '#/state/preferences/languages'
 import {FeedAPI, FeedAPIResponse} from './types'
+import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils'
 
 export class CustomFeedAPI implements FeedAPI {
   getAgent: () => BskyAgent
   params: GetCustomFeed.QueryParams
+  userInterests?: string
 
   constructor({
     getAgent,
     feedParams,
+    userInterests,
   }: {
     getAgent: () => BskyAgent
     feedParams: GetCustomFeed.QueryParams
+    userInterests?: string
   }) {
     this.getAgent = getAgent
     this.params = feedParams
+    this.userInterests = userInterests
   }
 
   async peekLatest(): Promise<AppBskyFeedDefs.FeedViewPost> {
@@ -44,6 +49,8 @@ export class CustomFeedAPI implements FeedAPI {
   }): Promise<FeedAPIResponse> {
     const contentLangs = getContentLanguages().join(',')
     const agent = this.getAgent()
+    const isBlueskyOwned = isBlueskyOwnedFeed(this.params.feed)
+
     const res = agent.session
       ? await this.getAgent().app.bsky.feed.getFeed(
           {
@@ -53,6 +60,9 @@ export class CustomFeedAPI implements FeedAPI {
           },
           {
             headers: {
+              ...(isBlueskyOwned
+                ? createBskyTopicsHeader(this.userInterests)
+                : {}),
               'Accept-Language': contentLangs,
             },
           },