@atproto/bsky 0.0.189 → 0.0.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/data-plane/server/routes/suggestions.js +1 -1
- package/dist/data-plane/server/routes/suggestions.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +2 -2
- package/dist/lexicon/lexicons.js +1 -1
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/profile.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/actor/profile.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/profile.js +9 -7
- package/dist/lexicon/types/app/bsky/actor/profile.js.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/status.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/actor/status.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/actor/status.js +9 -7
- package/dist/lexicon/types/app/bsky/actor/status.js.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/generator.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/feed/generator.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/generator.js +9 -7
- package/dist/lexicon/types/app/bsky/feed/generator.js.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/like.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/feed/like.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/like.js +9 -7
- package/dist/lexicon/types/app/bsky/feed/like.js.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/post.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/feed/post.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/post.js +9 -7
- package/dist/lexicon/types/app/bsky/feed/post.js.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/postgate.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/feed/postgate.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/postgate.js +9 -7
- package/dist/lexicon/types/app/bsky/feed/postgate.js.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/repost.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/feed/repost.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/repost.js +9 -7
- package/dist/lexicon/types/app/bsky/feed/repost.js.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/threadgate.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/feed/threadgate.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/feed/threadgate.js +9 -7
- package/dist/lexicon/types/app/bsky/feed/threadgate.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/block.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/graph/block.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/block.js +9 -7
- package/dist/lexicon/types/app/bsky/graph/block.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/follow.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/graph/follow.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/follow.js +9 -7
- package/dist/lexicon/types/app/bsky/graph/follow.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/list.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/graph/list.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/list.js +9 -7
- package/dist/lexicon/types/app/bsky/graph/list.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/listblock.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/graph/listblock.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/listblock.js +9 -7
- package/dist/lexicon/types/app/bsky/graph/listblock.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/listitem.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/graph/listitem.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/listitem.js +9 -7
- package/dist/lexicon/types/app/bsky/graph/listitem.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/starterpack.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/graph/starterpack.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/starterpack.js +9 -7
- package/dist/lexicon/types/app/bsky/graph/starterpack.js.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/verification.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/graph/verification.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/graph/verification.js +9 -7
- package/dist/lexicon/types/app/bsky/graph/verification.js.map +1 -1
- package/dist/lexicon/types/app/bsky/labeler/service.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/labeler/service.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/labeler/service.js +9 -7
- package/dist/lexicon/types/app/bsky/labeler/service.js.map +1 -1
- package/dist/lexicon/types/app/bsky/notification/declaration.d.ts +4 -3
- package/dist/lexicon/types/app/bsky/notification/declaration.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/notification/declaration.js +9 -7
- package/dist/lexicon/types/app/bsky/notification/declaration.js.map +1 -1
- package/dist/lexicon/types/chat/bsky/actor/declaration.d.ts +4 -3
- package/dist/lexicon/types/chat/bsky/actor/declaration.d.ts.map +1 -1
- package/dist/lexicon/types/chat/bsky/actor/declaration.js +9 -7
- package/dist/lexicon/types/chat/bsky/actor/declaration.js.map +1 -1
- package/dist/lexicon/types/com/atproto/lexicon/schema.d.ts +4 -3
- package/dist/lexicon/types/com/atproto/lexicon/schema.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/lexicon/schema.js +9 -7
- package/dist/lexicon/types/com/atproto/lexicon/schema.js.map +1 -1
- package/package.json +6 -6
- package/src/data-plane/server/routes/suggestions.ts +1 -1
- package/src/lexicon/lexicons.ts +1 -1
- package/src/lexicon/types/app/bsky/actor/profile.ts +12 -6
- package/src/lexicon/types/app/bsky/actor/status.ts +12 -6
- package/src/lexicon/types/app/bsky/feed/generator.ts +12 -6
- package/src/lexicon/types/app/bsky/feed/like.ts +12 -6
- package/src/lexicon/types/app/bsky/feed/post.ts +12 -6
- package/src/lexicon/types/app/bsky/feed/postgate.ts +12 -6
- package/src/lexicon/types/app/bsky/feed/repost.ts +12 -6
- package/src/lexicon/types/app/bsky/feed/threadgate.ts +12 -6
- package/src/lexicon/types/app/bsky/graph/block.ts +12 -6
- package/src/lexicon/types/app/bsky/graph/follow.ts +12 -6
- package/src/lexicon/types/app/bsky/graph/list.ts +12 -6
- package/src/lexicon/types/app/bsky/graph/listblock.ts +12 -6
- package/src/lexicon/types/app/bsky/graph/listitem.ts +12 -6
- package/src/lexicon/types/app/bsky/graph/starterpack.ts +12 -6
- package/src/lexicon/types/app/bsky/graph/verification.ts +12 -6
- package/src/lexicon/types/app/bsky/labeler/service.ts +12 -6
- package/src/lexicon/types/app/bsky/notification/declaration.ts +12 -6
- package/src/lexicon/types/chat/bsky/actor/declaration.ts +12 -6
- package/src/lexicon/types/com/atproto/lexicon/schema.ts +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atproto/bsky
|
|
2
2
|
|
|
3
|
+
## 0.0.191
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`a8e307ef4`](https://github.com/bluesky-social/atproto/commit/a8e307ef4851b164ee38bb5149343631e329f143), [`8ff5ec4ca`](https://github.com/bluesky-social/atproto/commit/8ff5ec4caa9a1f5c1e453a416ba2af22d1ee4f58)]:
|
|
8
|
+
- @atproto/api@0.17.4
|
|
9
|
+
- @atproto-labs/fetch-node@0.2.0
|
|
10
|
+
|
|
11
|
+
## 0.0.190
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`386f583cf`](https://github.com/bluesky-social/atproto/commit/386f583cffa2c596a12be4e98dde498f3b8670f6)]:
|
|
16
|
+
- @atproto/api@0.17.3
|
|
17
|
+
|
|
3
18
|
## 0.0.189
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -43,7 +43,7 @@ const getFollowSuggestionsGlobal = async (db, input) => {
|
|
|
43
43
|
const firstTwo = suggestions.filter((row) => row.order === 1 || row.order === 2);
|
|
44
44
|
const rest = suggestions.filter((row) => row.order !== 1 && row.order !== 2);
|
|
45
45
|
const limited = firstTwo.concat(shuffle(rest)).slice(0, input.limit);
|
|
46
|
-
// if the result set ends up getting larger, consider using a seed included in the cursor for
|
|
46
|
+
// if the result set ends up getting larger, consider using a seed included in the cursor for the randomized shuffle
|
|
47
47
|
const cursor = limited.length > 0
|
|
48
48
|
? limited
|
|
49
49
|
.map((row) => row.order.toString())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestions.js","sourceRoot":"","sources":["../../../../src/data-plane/server/routes/suggestions.ts"],"names":[],"mappings":";;AACA,mCAA4B;AAI5B,kBAAe,CAAC,EAAY,EAAwC,EAAE,CAAC,CAAC;IACtE,KAAK,CAAC,oBAAoB,CAAC,GAAG;QAC5B,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;QACtD,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,8BAA8B,CAAC,EAAE,EAAE;gBACxC,QAAQ;gBACR,aAAa;gBACb,MAAM,EAAE,MAAM,IAAI,SAAS;gBAC3B,KAAK,EAAE,KAAK,IAAI,SAAS;aAC1B,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,0BAA0B,CAAC,EAAE,EAAE;gBACpC,QAAQ;gBACR,MAAM,EAAE,MAAM,IAAI,SAAS;gBAC3B,KAAK,EAAE,KAAK,IAAI,SAAS;aAC1B,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,EAAE;aACzB,UAAU,CAAC,mBAAmB,CAAC;aAC/B,SAAS,EAAE;aACX,OAAO,E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CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,CAAI,GAAQ,EAAO,EAAE;IACnC,OAAO,GAAG;SACP,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SAChD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;SAC/B,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { ServiceImpl } from '@connectrpc/connect'\nimport { sql } from 'kysely'\nimport { Service } from '../../../proto/bsky_connect'\nimport { Database } from '../db'\n\nexport default (db: Database): Partial<ServiceImpl<typeof Service>> => ({\n async getFollowSuggestions(req) {\n const { actorDid, relativeToDid, cursor, limit } = req\n if (relativeToDid) {\n return getFollowSuggestionsRelativeTo(db, {\n actorDid,\n relativeToDid,\n cursor: cursor || undefined,\n limit: limit || undefined,\n })\n } else {\n return getFollowSuggestionsGlobal(db, {\n actorDid,\n cursor: cursor || undefined,\n limit: limit || undefined,\n })\n }\n },\n\n async getSuggestedEntities() {\n const entities = await db.db\n .selectFrom('tagged_suggestion')\n .selectAll()\n .execute()\n return {\n entities,\n }\n },\n})\n\nconst getFollowSuggestionsGlobal = async (\n db: Database,\n input: { actorDid: string; cursor?: string; limit?: number },\n) => {\n const alreadyIncluded = parseCursor(input.cursor)\n const suggestions = await db.db\n .selectFrom('suggested_follow')\n .innerJoin('actor', 'actor.did', 'suggested_follow.did')\n .if(alreadyIncluded.length > 0, (qb) =>\n qb.where('suggested_follow.order', 'not in', alreadyIncluded),\n )\n .selectAll()\n .orderBy('suggested_follow.order', 'asc')\n .execute()\n\n // always include first two\n const firstTwo = suggestions.filter(\n (row) => row.order === 1 || row.order === 2,\n )\n const rest = suggestions.filter((row) => row.order !== 1 && row.order !== 2)\n const limited = firstTwo.concat(shuffle(rest)).slice(0, input.limit)\n\n // if the result set ends up getting larger, consider using a seed included in the cursor for for the randomized shuffle\n const cursor =\n limited.length > 0\n ? limited\n .map((row) => row.order.toString())\n .concat(alreadyIncluded.map((id) => id.toString()))\n .join(':')\n : undefined\n\n return {\n dids: limited.map((s) => s.did),\n cursor,\n }\n}\n\nconst getFollowSuggestionsRelativeTo = async (\n db: Database,\n input: {\n actorDid: string\n relativeToDid: string\n cursor?: string\n limit?: number\n },\n) => {\n if (input.cursor) return { dids: [] }\n const limit = input.limit ? Math.min(10, input.limit) : 10\n const actorsViewerFollows = db.db\n .selectFrom('follow')\n .where('creator', '=', input.actorDid)\n .select('subjectDid')\n const mostLikedAccounts = await db.db\n .selectFrom(\n db.db\n .selectFrom('like')\n .where('creator', '=', input.relativeToDid)\n .select(sql`split_part(subject, '/', 3)`.as('subjectDid'))\n .orderBy('sortAt', 'desc')\n .limit(1000) // limit to 1000\n .as('likes'),\n )\n .select('likes.subjectDid as did')\n .select((qb) => qb.fn.count('likes.subjectDid').as('count'))\n .where('likes.subjectDid', 'not in', actorsViewerFollows)\n .where('likes.subjectDid', 'not in', [input.actorDid, input.relativeToDid])\n .groupBy('likes.subjectDid')\n .orderBy('count', 'desc')\n .limit(limit)\n .execute()\n const resultDids = mostLikedAccounts.map((a) => ({ did: a.did })) as {\n did: string\n }[]\n\n if (resultDids.length < limit) {\n // backfill with popular accounts followed by actor\n const mostPopularAccountsActorFollows = await db.db\n .selectFrom('follow')\n .innerJoin('profile_agg', 'follow.subjectDid', 'profile_agg.did')\n .select('follow.subjectDid as did')\n .where('follow.creator', '=', input.actorDid)\n .where('follow.subjectDid', '!=', input.relativeToDid)\n .where('follow.subjectDid', 'not in', actorsViewerFollows)\n .if(resultDids.length > 0, (qb) =>\n qb.where(\n 'subjectDid',\n 'not in',\n resultDids.map((a) => a.did),\n ),\n )\n .orderBy('profile_agg.followersCount', 'desc')\n .limit(limit)\n .execute()\n\n resultDids.push(...mostPopularAccountsActorFollows)\n }\n\n if (resultDids.length < limit) {\n // backfill with suggested_follow table\n const additional = await db.db\n .selectFrom('suggested_follow')\n .where(\n 'did',\n 'not in',\n // exclude any we already have\n resultDids\n .map((a) => a.did)\n .concat([input.actorDid, input.relativeToDid]),\n )\n // and aren't already followed by viewer\n .where('did', 'not in', actorsViewerFollows)\n .selectAll()\n .execute()\n\n resultDids.push(...additional)\n }\n\n return { dids: resultDids.map((x) => x.did) }\n}\n\nconst parseCursor = (cursor?: string): number[] => {\n if (!cursor) {\n return []\n }\n try {\n return cursor\n .split(':')\n .map((id) => parseInt(id, 10))\n .filter((id) => !isNaN(id))\n } catch {\n return []\n }\n}\n\nconst shuffle = <T>(arr: T[]): T[] => {\n return arr\n .map((value) => ({ value, sort: Math.random() }))\n .sort((a, b) => a.sort - b.sort)\n .map(({ value }) => value)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"suggestions.js","sourceRoot":"","sources":["../../../../src/data-plane/server/routes/suggestions.ts"],"names":[],"mappings":";;AACA,mCAA4B;AAI5B,kBAAe,CAAC,EAAY,EAAwC,EAAE,CAAC,CAAC;IACtE,KAAK,CAAC,oBAAoB,CAAC,GAAG;QAC5B,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;QACtD,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,8BAA8B,CAAC,EAAE,EAAE;gBACxC,QAAQ;gBACR,aAAa;gBACb,MAAM,EAAE,MAAM,IAAI,SAAS;gBAC3B,KAAK,EAAE,KAAK,IAAI,SAAS;aAC1B,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,0BAA0B,CAAC,EAAE,EAAE;gBACpC,QAAQ;gBACR,MAAM,EAAE,MAAM,IAAI,SAAS;gBAC3B,KAAK,EAAE,KA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,CAAC;aACV,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;aAC7B,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,CAAI,GAAQ,EAAO,EAAE;IACnC,OAAO,GAAG;SACP,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SAChD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;SAC/B,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { ServiceImpl } from '@connectrpc/connect'\nimport { sql } from 'kysely'\nimport { Service } from '../../../proto/bsky_connect'\nimport { Database } from '../db'\n\nexport default (db: Database): Partial<ServiceImpl<typeof Service>> => ({\n async getFollowSuggestions(req) {\n const { actorDid, relativeToDid, cursor, limit } = req\n if (relativeToDid) {\n return getFollowSuggestionsRelativeTo(db, {\n actorDid,\n relativeToDid,\n cursor: cursor || undefined,\n limit: limit || undefined,\n })\n } else {\n return getFollowSuggestionsGlobal(db, {\n actorDid,\n cursor: cursor || undefined,\n limit: limit || undefined,\n })\n }\n },\n\n async getSuggestedEntities() {\n const entities = await db.db\n .selectFrom('tagged_suggestion')\n .selectAll()\n .execute()\n return {\n entities,\n }\n },\n})\n\nconst getFollowSuggestionsGlobal = async (\n db: Database,\n input: { actorDid: string; cursor?: string; limit?: number },\n) => {\n const alreadyIncluded = parseCursor(input.cursor)\n const suggestions = await db.db\n .selectFrom('suggested_follow')\n .innerJoin('actor', 'actor.did', 'suggested_follow.did')\n .if(alreadyIncluded.length > 0, (qb) =>\n qb.where('suggested_follow.order', 'not in', alreadyIncluded),\n )\n .selectAll()\n .orderBy('suggested_follow.order', 'asc')\n .execute()\n\n // always include first two\n const firstTwo = suggestions.filter(\n (row) => row.order === 1 || row.order === 2,\n )\n const rest = suggestions.filter((row) => row.order !== 1 && row.order !== 2)\n const limited = firstTwo.concat(shuffle(rest)).slice(0, input.limit)\n\n // if the result set ends up getting larger, consider using a seed included in the cursor for the randomized shuffle\n const cursor =\n limited.length > 0\n ? limited\n .map((row) => row.order.toString())\n .concat(alreadyIncluded.map((id) => id.toString()))\n .join(':')\n : undefined\n\n return {\n dids: limited.map((s) => s.did),\n cursor,\n }\n}\n\nconst getFollowSuggestionsRelativeTo = async (\n db: Database,\n input: {\n actorDid: string\n relativeToDid: string\n cursor?: string\n limit?: number\n },\n) => {\n if (input.cursor) return { dids: [] }\n const limit = input.limit ? Math.min(10, input.limit) : 10\n const actorsViewerFollows = db.db\n .selectFrom('follow')\n .where('creator', '=', input.actorDid)\n .select('subjectDid')\n const mostLikedAccounts = await db.db\n .selectFrom(\n db.db\n .selectFrom('like')\n .where('creator', '=', input.relativeToDid)\n .select(sql`split_part(subject, '/', 3)`.as('subjectDid'))\n .orderBy('sortAt', 'desc')\n .limit(1000) // limit to 1000\n .as('likes'),\n )\n .select('likes.subjectDid as did')\n .select((qb) => qb.fn.count('likes.subjectDid').as('count'))\n .where('likes.subjectDid', 'not in', actorsViewerFollows)\n .where('likes.subjectDid', 'not in', [input.actorDid, input.relativeToDid])\n .groupBy('likes.subjectDid')\n .orderBy('count', 'desc')\n .limit(limit)\n .execute()\n const resultDids = mostLikedAccounts.map((a) => ({ did: a.did })) as {\n did: string\n }[]\n\n if (resultDids.length < limit) {\n // backfill with popular accounts followed by actor\n const mostPopularAccountsActorFollows = await db.db\n .selectFrom('follow')\n .innerJoin('profile_agg', 'follow.subjectDid', 'profile_agg.did')\n .select('follow.subjectDid as did')\n .where('follow.creator', '=', input.actorDid)\n .where('follow.subjectDid', '!=', input.relativeToDid)\n .where('follow.subjectDid', 'not in', actorsViewerFollows)\n .if(resultDids.length > 0, (qb) =>\n qb.where(\n 'subjectDid',\n 'not in',\n resultDids.map((a) => a.did),\n ),\n )\n .orderBy('profile_agg.followersCount', 'desc')\n .limit(limit)\n .execute()\n\n resultDids.push(...mostPopularAccountsActorFollows)\n }\n\n if (resultDids.length < limit) {\n // backfill with suggested_follow table\n const additional = await db.db\n .selectFrom('suggested_follow')\n .where(\n 'did',\n 'not in',\n // exclude any we already have\n resultDids\n .map((a) => a.did)\n .concat([input.actorDid, input.relativeToDid]),\n )\n // and aren't already followed by viewer\n .where('did', 'not in', actorsViewerFollows)\n .selectAll()\n .execute()\n\n resultDids.push(...additional)\n }\n\n return { dids: resultDids.map((x) => x.did) }\n}\n\nconst parseCursor = (cursor?: string): number[] => {\n if (!cursor) {\n return []\n }\n try {\n return cursor\n .split(':')\n .map((id) => parseInt(id, 10))\n .filter((id) => !isNaN(id))\n } catch {\n return []\n }\n}\n\nconst shuffle = <T>(arr: T[]): T[] => {\n return arr\n .map((value) => ({ value, sort: Math.random() }))\n .sort((a, b) => a.sort - b.sort)\n .map(({ value }) => value)\n}\n"]}
|
|
@@ -3429,7 +3429,7 @@ export declare const schemaDict: {
|
|
|
3429
3429
|
};
|
|
3430
3430
|
readonly hiddenReplies: {
|
|
3431
3431
|
readonly type: "array";
|
|
3432
|
-
readonly maxLength:
|
|
3432
|
+
readonly maxLength: 300;
|
|
3433
3433
|
readonly items: {
|
|
3434
3434
|
readonly type: "string";
|
|
3435
3435
|
readonly format: "at-uri";
|
|
@@ -16309,7 +16309,7 @@ export declare const schemas: ({
|
|
|
16309
16309
|
};
|
|
16310
16310
|
readonly hiddenReplies: {
|
|
16311
16311
|
readonly type: "array";
|
|
16312
|
-
readonly maxLength:
|
|
16312
|
+
readonly maxLength: 300;
|
|
16313
16313
|
readonly items: {
|
|
16314
16314
|
readonly type: "string";
|
|
16315
16315
|
readonly format: "at-uri";
|