Skip to content

Commit

Permalink
use getActor, failing atm
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Aug 17, 2023
1 parent 1a5b422 commit ff0d2df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
21 changes: 7 additions & 14 deletions packages/bsky/src/api/app/bsky/feed/getAuthorFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,22 @@ export default function (server: Server, ctx: AppContext) {
const feedService = ctx.services.feed(db)
const graphService = ctx.services.graph(db)

let did = ''
if (actor.startsWith('did:')) {
did = actor
} else {
const actorRes = await db.db
.selectFrom('actor')
.select('did')
.where('handle', '=', actor)
.executeTakeFirst()
if (actorRes) {
did = actorRes?.did
}
// maybe resolve did first
const actorRes = await actorService.getActor(actor)
if (!actorRes) {
throw new InvalidRequestError('Profile not found')
}
const actorDid = actorRes.did

// defaults to posts, reposts, and replies
let feedItemsQb = feedService
.selectFeedItemQb()
.where('originatorDid', '=', did)
.where('originatorDid', '=', actorDid)

if (filter === 'posts_with_media') {
feedItemsQb = feedItemsQb
// and only your own posts/reposts
.where('post.creator', '=', did)
.where('post.creator', '=', actorDid)
// only posts with media
.whereExists((qb) =>
qb
Expand Down
17 changes: 5 additions & 12 deletions packages/pds/src/app-view/api/app/bsky/feed/getAuthorFeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,16 @@ export default function (server: Server, ctx: AppContext) {

const { ref } = ctx.db.db.dynamic
const accountService = ctx.services.account(ctx.db)
const actorService = ctx.services.appView.actor(ctx.db)
const feedService = ctx.services.appView.feed(ctx.db)
const graphService = ctx.services.appView.graph(ctx.db)

// maybe resolve did first
let actorDid = ''
if (actor.startsWith('did:')) {
actorDid = actor
} else {
const actorRes = await ctx.db.db
.selectFrom('did_handle')
.select('did')
.where('did_handle.handle', '=', actor)
.executeTakeFirst()
if (actorRes) {
actorDid = actorRes?.did
}
const actorRes = await actorService.getActor(actor)
if (!actorRes) {
throw new InvalidRequestError('Profile not found')
}
const actorDid = actorRes.did

// defaults to posts, reposts, and replies
let feedItemsQb = feedService
Expand Down

0 comments on commit ff0d2df

Please sign in to comment.