diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-08-09 17:34:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-09 17:34:16 -0700 |
commit | 03d152675ee1ce208856498acf7285fbf07fd45b (patch) | |
tree | 70803ebe16276b3a6b7c350f78d069641a0a6118 /src/lib/api | |
parent | 48813a96d686d97009e260d0a87f32d28a631052 (diff) | |
download | voidsky-03d152675ee1ce208856498acf7285fbf07fd45b.tar.zst |
Add self-labeling controls (#1141)
* Add self-label modal * Use the shield-exclamation icon consistently on post moderation * Wire up self-labeling * Bump @atproto/api@0.6.0 * Bump @atproto/dev-env@^0.2.3 * Add e2e test for self-labeling * Fix types
Diffstat (limited to 'src/lib/api')
-rw-r--r-- | src/lib/api/index.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 381d78435..bb4ff8fcb 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -4,6 +4,7 @@ import { AppBskyEmbedRecord, AppBskyEmbedRecordWithMedia, AppBskyRichtextFacet, + ComAtprotoLabelDefs, ComAtprotoRepoUploadBlob, RichText, } from '@atproto/api' @@ -77,6 +78,7 @@ interface PostOpts { } extLink?: ExternalEmbedDraft images?: ImageModel[] + labels?: string[] knownHandles?: Set<string> onStateChange?: (state: string) => void langs?: string[] @@ -234,6 +236,15 @@ export async function post(store: RootStoreModel, opts: PostOpts) { } } + // set labels + let labels: ComAtprotoLabelDefs.SelfLabels | undefined + if (opts.labels?.length) { + labels = { + $type: 'com.atproto.label.defs#selfLabels', + values: opts.labels.map(val => ({val})), + } + } + // add top 3 languages from user preferences if langs is provided let langs = opts.langs if (opts.langs) { @@ -248,6 +259,7 @@ export async function post(store: RootStoreModel, opts: PostOpts) { reply, embed, langs, + labels, }) } catch (e: any) { console.error(`Failed to create post: ${e.toString()}`) |