about summary refs log tree commit diff
path: root/src/lib/api
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-05-31 18:41:06 +0300
committerGitHub <noreply@github.com>2024-05-31 10:41:06 -0500
commit8eb3cebb362cc438e368a9fbb78e2f85403ffeed (patch)
tree3c82cd4701c830a43e7f13825fc912304069625c /src/lib/api
parent455937dd0f7248033f412f53f7d2be89978aa4f2 (diff)
downloadvoidsky-8eb3cebb362cc438e368a9fbb78e2f85403ffeed.tar.zst
[🐴] send record via link in text (Record DMs - base PR) (#4227)
* send record via link in text

* re-trim text after removing link
Diffstat (limited to 'src/lib/api')
-rw-r--r--src/lib/api/index.ts15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts
index bc50f9cb3..dfaae2e01 100644
--- a/src/lib/api/index.ts
+++ b/src/lib/api/index.ts
@@ -4,7 +4,6 @@ import {
   AppBskyEmbedRecord,
   AppBskyEmbedRecordWithMedia,
   AppBskyFeedThreadgate,
-  AppBskyRichtextFacet,
   BskyAgent,
   ComAtprotoLabelDefs,
   ComAtprotoRepoUploadBlob,
@@ -15,7 +14,7 @@ import {AtUri} from '@atproto/api'
 import {logger} from '#/logger'
 import {ThreadgateSetting} from '#/state/queries/threadgate'
 import {isNetworkError} from 'lib/strings/errors'
-import {shortenLinks} from 'lib/strings/rich-text-manip'
+import {shortenLinks, stripInvalidMentions} from 'lib/strings/rich-text-manip'
 import {isNative, isWeb} from 'platform/detection'
 import {ImageModel} from 'state/models/media/image'
 import {LinkMeta} from '../link-meta/link-meta'
@@ -81,17 +80,7 @@ export async function post(agent: BskyAgent, opts: PostOpts) {
   opts.onStateChange?.('Processing...')
   await rt.detectFacets(agent)
   rt = shortenLinks(rt)
-
-  // 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
-  })
+  rt = stripInvalidMentions(rt)
 
   // add quote embed if present
   if (opts.quote) {