diff --git a/package.json b/package.json
index 7fd713d6b..818138f9d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "blacksky.community",
- "version": "1.127.4",
+ "version": "1.128.0",
"private": true,
"packageManager": "pnpm@11.7.0",
"engines": {
diff --git a/src/lib/api/__tests__/post-routing.test.ts b/src/lib/api/__tests__/post-routing.test.ts
index f9af8adac..7f883d9b5 100644
--- a/src/lib/api/__tests__/post-routing.test.ts
+++ b/src/lib/api/__tests__/post-routing.test.ts
@@ -17,6 +17,17 @@ jest.mock('#/state/queries/threadgate', () => ({
threadgateAllowUISettingToAllowRecordValue: jest.fn(() => []),
}))
+// The public write path hashes the record through ESM-only IPLD packages
+// that jest cannot load; the CID value is not under test here.
+jest.mock(
+ '@ipld/dag-cbor',
+ () => ({encode: (v: unknown) => Buffer.from(JSON.stringify(v))}),
+ {virtual: true},
+)
+jest.mock('multiformats/cid', () => ({
+ CID: {createV1: () => ({toString: () => 'bafyreifake'})},
+}))
+
jest.mock('../space-post', () => ({
postToSpace: jest.fn(() => Promise.resolve({uris: ['at://space/post']})),
}))
@@ -88,6 +99,38 @@ describe('post routing', () => {
})
})
+describe('self labels', () => {
+ beforeEach(() => jest.clearAllMocks())
+
+ it('publishes a text-only post with its self labels', async () => {
+ const {agent, applyWrites} = mockAgent()
+
+ await post(agent, queryClient, {
+ thread: {
+ posts: [
+ {
+ richtext: {text: 'words only', facets: []},
+ shortenedGraphemeLength: 10,
+ labels: ['porn'],
+ embed: {},
+ },
+ ],
+ postgate: {},
+ threadgate: [],
+ blackskyOnly: false,
+ } as never,
+ })
+
+ const [{writes}] = applyWrites.mock.calls[0] as unknown as [
+ {writes: {value: {labels?: unknown}}[]},
+ ]
+ expect(writes[0].value.labels).toEqual({
+ $type: 'com.atproto.label.defs#selfLabels',
+ values: [{val: 'porn'}],
+ })
+ })
+})
+
describe('quoting a space post from outside the space', () => {
const SPACE_POST = `${SPACE}/did:plc:bob/app.bsky.feed.post/3kabc`
const permalink = `https://blacksky.community/profile/did:plc:bob/post/3kabc?space=${encodeURIComponent(
diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx
index f2d61e698..cfccb6477 100644
--- a/src/view/com/composer/Composer.tsx
+++ b/src/view/com/composer/Composer.tsx
@@ -2095,24 +2095,6 @@ function ComposerPills({
const t = useTheme()
const {data: isCommunityMember = false} = useCommunityMembership()
const homeAppviewOutage = useHomeAppviewOutage()
- const media = post.embed.media
- const hasMedia =
- media?.type === 'images' ||
- media?.type === 'gallery' ||
- media?.type === 'gif' ||
- media?.type === 'video'
- const hasLink = !!post.embed.link
-
- if (
- isReply &&
- !hasMedia &&
- !hasLink &&
- !isForcedBlackskyOnly &&
- !thread.communityFeedUri &&
- !thread.communitySpaceUri
- ) {
- return null
- }
return (
- {hasMedia || hasLink ? (
- {
- dispatch({
- type: 'update_post',
- postId: post.id,
- postAction: {
- type: 'update_labels',
- labels: nextLabels,
- },
- })
- }}
- />
- ) : null}
+ {
+ dispatch({
+ type: 'update_post',
+ postId: post.id,
+ postAction: {
+ type: 'update_labels',
+ labels: nextLabels,
+ },
+ })
+ }}
+ />
{(thread.blackskyOnly ||
thread.communityFeedUri ||
diff --git a/src/view/com/composer/labels/LabelsBtn.tsx b/src/view/com/composer/labels/LabelsBtn.tsx
index 9471dc0d2..4df2625e9 100644
--- a/src/view/com/composer/labels/LabelsBtn.tsx
+++ b/src/view/com/composer/labels/LabelsBtn.tsx
@@ -109,8 +109,8 @@ function DialogInner({
- Please add any content warning labels that are applicable for the
- media you are posting.
+ Please add any content warning labels that apply to what you are
+ posting.
@@ -162,7 +162,7 @@ function DialogInner({
labels.includes('porn') ? (
{labels.includes('sexual') ? (
- Pictures meant for adults.
+ Suggestive content meant for adults.
) : labels.includes('nudity') ? (
Artistic or non-erotic nudity.
) : labels.includes('porn') ? (
@@ -204,7 +204,7 @@ function DialogInner({
{labels.includes('graphic-media') ? (
- Media that may be disturbing or inappropriate for some
+ Content that may be disturbing or inappropriate for some
audiences.
diff --git a/src/view/com/composer/state/__tests__/composer.test.ts b/src/view/com/composer/state/__tests__/composer.test.ts
new file mode 100644
index 000000000..c7e4e4b48
--- /dev/null
+++ b/src/view/com/composer/state/__tests__/composer.test.ts
@@ -0,0 +1,78 @@
+import {type ComposerImage} from '#/state/gallery'
+import {
+ type ComposerAction,
+ composerReducer,
+ createComposerState,
+} from '../composer'
+
+jest.mock('#/state/gallery', () => ({createInitialImages: jest.fn()}))
+jest.mock('#/state/queries/threadgate', () => ({
+ threadgateRecordToAllowUISetting: jest.fn(() => []),
+}))
+jest.mock('../video', () => ({
+ createVideoState: jest.fn(),
+ videoReducer: jest.fn(),
+}))
+
+const image = {
+ source: {
+ id: 'img-1',
+ path: 'file://a',
+ mime: 'image/jpeg',
+ width: 1,
+ height: 1,
+ },
+} as unknown as ComposerImage
+
+type PostAction = Extract['postAction']
+
+function draftAfter(actions: PostAction[]) {
+ let state = createComposerState({
+ initText: undefined,
+ initMention: undefined,
+ initImageUris: undefined,
+ initQuoteUri: undefined,
+ initInteractionSettings: undefined,
+ })
+ for (const postAction of actions) {
+ state = composerReducer(state, {
+ type: 'update_post',
+ postId: state.thread.posts[0].id,
+ postAction,
+ })
+ }
+ return state.thread.posts[0]
+}
+
+describe('composer self labels', () => {
+ it('keeps labels when the last image is removed', () => {
+ const post = draftAfter([
+ {type: 'embed_add_images', images: [image]},
+ {type: 'update_labels', labels: ['porn']},
+ {type: 'embed_remove_image', image},
+ ])
+
+ expect(post.embed.media).toBeUndefined()
+ expect(post.labels).toEqual(['porn'])
+ })
+
+ it('keeps labels when the link card is removed', () => {
+ const post = draftAfter([
+ {type: 'embed_add_uri', uri: 'https://example.com'},
+ {type: 'update_labels', labels: ['graphic-media']},
+ {type: 'embed_remove_link'},
+ ])
+
+ expect(post.embed.link).toBeUndefined()
+ expect(post.labels).toEqual(['graphic-media'])
+ })
+
+ it('keeps labels when a video is removed from a text-only draft', () => {
+ const post = draftAfter([
+ {type: 'update_labels', labels: ['sexual']},
+ {type: 'embed_remove_video'},
+ ])
+
+ expect(post.labels).toEqual(['sexual'])
+ })
+})
diff --git a/src/view/com/composer/state/composer.ts b/src/view/com/composer/state/composer.ts
index 3f0684bb1..625ce877b 100644
--- a/src/view/com/composer/state/composer.ts
+++ b/src/view/com/composer/state/composer.ts
@@ -466,7 +466,6 @@ function postReducer(state: PostDraft, action: PostAction): PostDraft {
}
case 'embed_remove_image': {
const prevMedia = state.embed.media
- let nextLabels = state.labels
if (prevMedia?.type === 'images' || prevMedia?.type === 'gallery') {
const removedImage = action.image
const remainingImages = prevMedia.images.filter(img => {
@@ -475,9 +474,6 @@ function postReducer(state: PostDraft, action: PostAction): PostDraft {
let nextMedia: ImagesMedia | GalleryMedia | undefined
if (remainingImages.length === 0) {
nextMedia = undefined
- if (!state.embed.link) {
- nextLabels = []
- }
} else {
// Re-pick the variant so a gallery that shrinks to <=4 demotes
// back to the legacy `app.bsky.embed.images` shape - keeps old
@@ -486,7 +482,6 @@ function postReducer(state: PostDraft, action: PostAction): PostDraft {
}
return {
...state,
- labels: nextLabels,
embed: {
...state.embed,
media: nextMedia,
@@ -537,13 +532,8 @@ function postReducer(state: PostDraft, action: PostAction): PostDraft {
prevMedia.video.abortController.abort()
nextMedia = undefined
}
- let nextLabels = state.labels
- if (!state.embed.link) {
- nextLabels = []
- }
return {
...state,
- labels: nextLabels,
embed: {
...state.embed,
media: nextMedia,
@@ -580,13 +570,8 @@ function postReducer(state: PostDraft, action: PostAction): PostDraft {
}
}
case 'embed_remove_link': {
- let nextLabels = state.labels
- if (!state.embed.media) {
- nextLabels = []
- }
return {
...state,
- labels: nextLabels,
embed: {
...state.embed,
link: undefined,