Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/appview-v2' into appview-v2-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Jan 29, 2024
2 parents 0a8525f + 8e59aad commit 0329ec9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/bsky/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as plc from '@did-plc/lib'
import AtpAgent from '@atproto/api'
import { IdResolver } from '@atproto/identity'
import AtpAgent from '@atproto/api'
import { Keypair } from '@atproto/crypto'
import { createServiceJwt } from '@atproto/xrpc-server'
import { ServerConfig } from './config'
Expand Down
11 changes: 8 additions & 3 deletions packages/bsky/src/hydration/actor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { DataPlaneClient } from '../data-plane/client'
import { Record as ProfileRecord } from '../lexicon/types/app/bsky/actor/profile'
import { HydrationMap, parseRecordBytes, parseString } from './util'
import {
HydrationMap,
parseRecordBytes,
parseString,
safeTakedownRef,
} from './util'

export type Actor = {
did: string
Expand Down Expand Up @@ -92,9 +97,9 @@ export class ActorHydrator {
handle: parseString(actor.handle),
profile: parseRecordBytes<ProfileRecord>(profile?.record),
profileCid: profile?.cid,
profileTakedownRef: profile?.takedownRef || undefined,
profileTakedownRef: safeTakedownRef(profile),
sortedAt: profile?.sortedAt?.toDate(),
takedownRef: actor.takedownRef || undefined,
takedownRef: safeTakedownRef(actor),
})
}, new HydrationMap<Actor>())
}
Expand Down
11 changes: 10 additions & 1 deletion packages/bsky/src/hydration/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const parseRecord = <T>(
record,
cid,
sortedAt,
takedownRef: entry.takedownRef || undefined,
takedownRef: safeTakedownRef(entry),
}
}

Expand Down Expand Up @@ -96,3 +96,12 @@ export const split = <T>(
}
return [yes, no]
}

export const safeTakedownRef = (obj?: {
takenDown: boolean
takedownRef: string
}): string | undefined => {
if (!obj) return
if (obj.takedownRef) return obj.takedownRef
if (obj.takenDown) return 'BSKY-TAKEDOWN-UNKNOWN'
}

0 comments on commit 0329ec9

Please sign in to comment.