Filter out bad mentions instead of erroring during post (close #391) (#422)

zio/stable
Paul Frazee 2023-04-07 11:51:20 -05:00 committed by GitHub
parent 0407e93ef8
commit 0c9935f125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import {
AppBskyEmbedExternal,
AppBskyEmbedRecord,
AppBskyEmbedRecordWithMedia,
AppBskyRichtextFacet,
ComAtprotoRepoUploadBlob,
RichText,
} from '@atproto/api'
@ -83,6 +84,17 @@ export async function post(store: RootStoreModel, opts: PostOpts) {
opts.onStateChange?.('Processing...')
await rt.detectFacets(store.agent)
// filter out any mention facets that didn't map to a user
rt.facets = rt.facets?.filter(facet => {
const mention = facet.features.find(feature =>
AppBskyRichtextFacet.isMention(feature),
)
if (mention && !mention.did) {
return false
}
return true
})
if (opts.quote) {
embed = {
$type: 'app.bsky.embed.record',