-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathdads-media.ts
43 lines (35 loc) · 979 Bytes
/
dads-media.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { QueryParams } from '../lexicon/types/app/bsky/feed/getFeedSkeleton'
import { AppContext } from '../config'
import { AlgoManager } from '../addn/algoManager'
import dotenv from 'dotenv'
import { Post } from '../db/schema'
import dbClient from '../db/dbClient'
dotenv.config()
// max 15 chars
export const shortname = 'dads-media'
export const handler = async (ctx: AppContext, params: QueryParams) => {
const builder = await dbClient.getLatestPostsForTag({
tag: 'dads',
limit: params.limit,
cursor: params.cursor,
mediaOnly: true,
})
const feed = builder.map((row) => ({
post: row.uri,
}))
let cursor: string | undefined
const last = builder.at(-1)
if (last) {
cursor = `${new Date(last.indexedAt).getTime()}::${last.cid}`
}
return {
cursor,
feed,
}
}
export class manager extends AlgoManager {
public name: string = shortname
public async filter_post(post: Post): Promise<Boolean> {
return false
}
}