1
- import { mapDefined } from '@atproto/common'
1
+ import { mapDefined , noUndefinedVals } from '@atproto/common'
2
2
import AppContext from '../../../../context'
3
3
import { Server } from '../../../../lexicon'
4
4
import { QueryParams } from '../../../../lexicon/types/app/bsky/actor/getSuggestions'
@@ -27,12 +27,23 @@ export default function (server: Server, ctx: AppContext) {
27
27
const viewer = auth . credentials . iss
28
28
const labelers = ctx . reqLabelers ( req )
29
29
const hydrateCtx = await ctx . hydrator . createContext ( { viewer, labelers } )
30
- const result = await getSuggestions ( { ...params , hydrateCtx } , ctx )
31
-
30
+ const headers = noUndefinedVals ( {
31
+ 'accept-language' : req . headers [ 'accept-language' ] ,
32
+ } )
33
+ const { resHeaders : resultHeaders , ...result } = await getSuggestions (
34
+ { ...params , hydrateCtx, headers } ,
35
+ ctx ,
36
+ )
37
+ const suggestionsResHeaders = noUndefinedVals ( {
38
+ 'content-language' : resultHeaders ?. [ 'content-language' ] ,
39
+ } )
32
40
return {
33
41
encoding : 'application/json' ,
34
42
body : result ,
35
- headers : resHeaders ( { labelers : hydrateCtx . labelers } ) ,
43
+ headers : {
44
+ ...suggestionsResHeaders ,
45
+ ...resHeaders ( { labelers : hydrateCtx . labelers } ) ,
46
+ } ,
36
47
}
37
48
} ,
38
49
} )
@@ -46,14 +57,18 @@ const skeleton = async (input: {
46
57
const viewer = params . hydrateCtx . viewer
47
58
if ( ctx . suggestionsAgent ) {
48
59
const res =
49
- await ctx . suggestionsAgent . api . app . bsky . unspecced . getSuggestionsSkeleton ( {
50
- viewer : viewer ?? undefined ,
51
- limit : params . limit ,
52
- cursor : params . cursor ,
53
- } )
60
+ await ctx . suggestionsAgent . api . app . bsky . unspecced . getSuggestionsSkeleton (
61
+ {
62
+ viewer : viewer ?? undefined ,
63
+ limit : params . limit ,
64
+ cursor : params . cursor ,
65
+ } ,
66
+ { headers : params . headers } ,
67
+ )
54
68
return {
55
69
dids : res . data . actors . map ( ( a ) => a . did ) ,
56
70
cursor : res . data . cursor ,
71
+ resHeaders : res . headers ,
57
72
}
58
73
} else {
59
74
// @NOTE for appview swap moving to rkey-based cursors which are somewhat permissive, should not hard-break pagination
@@ -111,6 +126,7 @@ const presentation = (input: {
111
126
return {
112
127
actors,
113
128
cursor : skeleton . cursor ,
129
+ resHeaders : skeleton . resHeaders ,
114
130
}
115
131
}
116
132
@@ -123,6 +139,11 @@ type Context = {
123
139
124
140
type Params = QueryParams & {
125
141
hydrateCtx : HydrateCtx
142
+ headers : Record < string , string >
126
143
}
127
144
128
- type Skeleton = { dids : string [ ] ; cursor ?: string }
145
+ type Skeleton = {
146
+ dids : string [ ]
147
+ cursor ?: string
148
+ resHeaders ?: Record < string , string >
149
+ }
0 commit comments