diff --git a/package.json b/package.json index d13487e37..bd3ee1d2a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blacksky.community", - "version": "1.127.1", + "version": "1.128.0", "private": true, "packageManager": "pnpm@11.7.0", "engines": { diff --git a/src/components/CommunityOnlyBadge.tsx b/src/components/CommunityOnlyBadge.tsx index 5ecc0a8a2..589945a87 100644 --- a/src/components/CommunityOnlyBadge.tsx +++ b/src/components/CommunityOnlyBadge.tsx @@ -7,6 +7,7 @@ import {Trans} from '@lingui/react/macro' import {Logo as BlackskyLogo} from '#/view/icons/Logo' import {atoms as a, useTheme} from '#/alf' import {ChevronBottom_Stroke2_Corner0_Rounded as ChevronDown} from '#/components/icons/Chevron' +import {Group3_Stroke2_Corner0_Rounded as GroupIcon} from '#/components/icons/Group' import * as Tooltip from '#/components/Tooltip' import {Text} from '#/components/Typography' @@ -16,10 +17,17 @@ export function isCommunityPostUri(uri: string | undefined): boolean { return !!uri && uri.includes(COMMUNITY_POST_COLLECTION) } -export function CommunityOnlyBadge() { +export function CommunityOnlyBadge({communityFeed}: {communityFeed?: string}) { const t = useTheme() const {_} = useLingui() const [visible, setVisible] = useState(false) + const isTenant = !!communityFeed + const label = isTenant + ? _(msg`Community-only post`) + : _(msg`Blacksky-only post`) + const hint = isTenant + ? _(msg`Only visible to members of this community`) + : _(msg`Only visible to members of the Blacksky community`) useEffect(() => { return () => setVisible(false) @@ -33,10 +41,8 @@ export function CommunityOnlyBadge() { setVisible(v => !v)} style={[ a.flex_row, @@ -47,19 +53,33 @@ export function CommunityOnlyBadge() { a.rounded_full, {backgroundColor: t.palette.primary_500}, ]}> - + {isTenant ? ( + + ) : ( + + )} - + - Blacksky Only + {isTenant ? ( + Community Only + ) : ( + Blacksky Only + )} - - This post is only visible to members of the Blacksky community. - + {isTenant ? ( + + This post is only visible to members of its community. + + ) : ( + + This post is only visible to members of the Blacksky community. + + )} diff --git a/src/components/PostControls/PostMenu/PostMenuItems.tsx b/src/components/PostControls/PostMenu/PostMenuItems.tsx index 8b0c4651c..6323f358f 100644 --- a/src/components/PostControls/PostMenu/PostMenuItems.tsx +++ b/src/components/PostControls/PostMenu/PostMenuItems.tsx @@ -17,6 +17,7 @@ import {plural} from '@lingui/core/macro' import {useLingui} from '@lingui/react/macro' import {useNavigation} from '@react-navigation/native' +import {getCommunityFeedUri} from '#/lib/api/community-post' import {getCurrentRoute} from '#/lib/routes/helpers' import {makeProfileLink} from '#/lib/routes/links' import { @@ -162,7 +163,8 @@ let PostMenuItems = ({ [postUri], ) const {data: peerModPerms} = useMyPeerModPermissions() - const canLabelPost = !!peerModPerms?.isPeerMod && isCommunityPost + const canLabelPost = + !!peerModPerms?.isPeerMod && isCommunityPost && !getCommunityFeedUri(post) const [isThreadMuted, muteThread, unmuteThread] = useThreadMuteMutationQueue( post, rootUri, diff --git a/src/components/PostControls/index.tsx b/src/components/PostControls/index.tsx index 240a4256c..a2d446aaa 100644 --- a/src/components/PostControls/index.tsx +++ b/src/components/PostControls/index.tsx @@ -9,6 +9,7 @@ import { import {plural} from '@lingui/core/macro' import {useLingui} from '@lingui/react/macro' +import {getCommunityFeedUri} from '#/lib/api/community-post' import {CountWheel} from '#/lib/custom-animations/CountWheel' import {AnimatedLikeIcon} from '#/lib/custom-animations/LikeIcon' import {useOpenComposer} from '#/lib/hooks/useOpenComposer' @@ -323,7 +324,9 @@ let PostControls = ({ a.align_center, secondaryControlSpacingStyles, ]}> - {isCommunityPostUri(post.uri) && } + {isCommunityPostUri(post.uri) && ( + + )} ({ + getServiceAuthToken: jest.fn(), +})) + +const feed = 'at://did:plc:community/app.bsky.feed.generator/3m2communityfeed' +const serviceDid = 'did:web:feeds.example.com' +const config = { + $type: 'community.blacksky.feed.config', + contentType: 'publicRecord', + visibility: 'public', + policyMode: 'public', + group: 'at://did:plc:community/community.blacksky.group/community', + createdAt: '2026-08-06T12:00:00.000Z', +} as const + +function mockAgent() { + const getRecord = jest.fn(({collection}: {collection: string}) => { + if (collection === 'community.blacksky.feed.config') { + return Promise.resolve({data: {value: config}}) + } + return Promise.resolve({ + data: {value: {$type: collection, did: serviceDid}}, + }) + }) + const fetchHandler = jest.fn, [string, RequestInit?]>() + return { + agent: { + com: {atproto: {repo: {getRecord}}}, + fetchHandler, + } as unknown as AtpAgent, + fetchHandler, + getRecord, + } +} + +describe('community feed API', () => { + beforeEach(() => { + jest.mocked(getServiceAuthToken).mockReset() + jest.mocked(getServiceAuthToken).mockResolvedValue('service-token') + }) + + it('loads config and generator records from the feed owner at the same rkey', async () => { + const {agent, getRecord} = mockAgent() + + await expect(fetchCommunityFeedConfig(agent, feed)).resolves.toEqual(config) + await expect(fetchFeedServiceDid(agent, feed)).resolves.toBe(serviceDid) + + expect(getRecord).toHaveBeenNthCalledWith(1, { + repo: 'did:plc:community', + collection: 'community.blacksky.feed.config', + rkey: '3m2communityfeed', + }) + expect(getRecord).toHaveBeenNthCalledWith(2, { + repo: 'did:plc:community', + collection: 'app.bsky.feed.generator', + rkey: '3m2communityfeed', + }) + }) + + it('checks self-scoped permissions with exact service auth and filters unknown values', async () => { + const {agent, fetchHandler} = mockAgent() + fetchHandler.mockResolvedValue( + new Response( + JSON.stringify({ + permissions: ['canView', 'futurePermission', 'canPost'], + }), + ), + ) + + await expect(fetchFeedPermissions(agent, feed)).resolves.toEqual([ + 'canView', + 'canPost', + ]) + expect(getServiceAuthToken).toHaveBeenCalledWith( + expect.objectContaining({ + agent, + aud: serviceDid, + lxm: CHECK_FEED_PERMISSIONS, + }), + ) + expect(fetchHandler).toHaveBeenCalledWith( + `/xrpc/${CHECK_FEED_PERMISSIONS}?feed=${encodeURIComponent(feed)}`, + { + headers: { + Authorization: 'Bearer service-token', + 'atproto-proxy': `${serviceDid}#bsky_fg`, + }, + }, + ) + }) + + it('fails closed when the permission service rejects the request', async () => { + const {agent, fetchHandler} = mockAgent() + fetchHandler.mockResolvedValue(new Response('{}', {status: 403})) + + await expect(fetchFeedPermissions(agent, feed)).resolves.toEqual([]) + }) + + it('resolves a post target only when the user can post', async () => { + const {agent, fetchHandler} = mockAgent() + fetchHandler.mockResolvedValue( + new Response(JSON.stringify({permissions: ['canView', 'canPost']})), + ) + + await expect(fetchCommunityFeedTarget(agent, feed)).resolves.toEqual({ + feed, + name: feed, + serviceDid, + config, + }) + }) + + it('fails closed when resolving a post target without canPost', async () => { + const {agent, fetchHandler} = mockAgent() + fetchHandler.mockResolvedValue( + new Response(JSON.stringify({permissions: ['canView']})), + ) + + await expect(fetchCommunityFeedTarget(agent, feed)).resolves.toBeNull() + }) + + it('admits a canonical record through the feed generator service', async () => { + const {agent, fetchHandler} = mockAgent() + fetchHandler.mockResolvedValue(new Response('{}')) + const post = 'at://did:plc:author/app.bsky.feed.post/3m2post' + + await admitFeedPost( + agent, + {feed, name: 'Community', serviceDid, config}, + post, + 'bafyrecordcid', + ) + + expect(getServiceAuthToken).toHaveBeenCalledWith( + expect.objectContaining({agent, aud: serviceDid, lxm: ADMIT_FEED_POST}), + ) + expect(fetchHandler).toHaveBeenCalledWith(`/xrpc/${ADMIT_FEED_POST}`, { + method: 'POST', + headers: { + Authorization: 'Bearer service-token', + 'Content-Type': 'application/json', + 'atproto-proxy': `${serviceDid}#bsky_fg`, + }, + body: JSON.stringify({feed, post, cid: 'bafyrecordcid'}), + }) + }) +}) diff --git a/src/lib/api/__tests__/community-post.test.ts b/src/lib/api/__tests__/community-post.test.ts new file mode 100644 index 000000000..0e49e0d32 --- /dev/null +++ b/src/lib/api/__tests__/community-post.test.ts @@ -0,0 +1,25 @@ +import {getCommunityFeedUri} from '../community-post' + +const post = (communityFeed?: unknown) => + ({ + uri: 'at://did:plc:author/community.blacksky.feed.post/3m2post', + communityFeed, + }) as never + +describe(getCommunityFeedUri, () => { + it('accepts a feed generator URI', () => { + const feed = + 'at://did:plc:community/app.bsky.feed.generator/3m2communityfeed' + + expect(getCommunityFeedUri(post(feed))).toBe(feed) + }) + + it.each([ + undefined, + 42, + 'not-an-at-uri', + 'at://did:plc:community/community.blacksky.feed.config/3m2communityfeed', + ])('rejects absent or invalid feed context: %p', communityFeed => { + expect(getCommunityFeedUri(post(communityFeed))).toBeUndefined() + }) +}) diff --git a/src/lib/api/__tests__/community.test.ts b/src/lib/api/__tests__/community.test.ts index 28b2539f1..9ffd99c32 100644 --- a/src/lib/api/__tests__/community.test.ts +++ b/src/lib/api/__tests__/community.test.ts @@ -34,4 +34,20 @@ describe('communityXrpc', () => { BLUESKY_FALLBACK_PROXY_HEADER, ) }) + + it('can target a configured content store', async () => { + const {agent, fetchHandler} = mockAgent() + + await communityXrpc(agent, 'community.blacksky.feed.submitPost', { + body: {text: 'hello'}, + serviceDid: 'did:web:content.example.com', + }) + + const init = fetchHandler.mock.calls[0][1] as { + headers: Record + } + expect(init.headers['atproto-proxy']).toBe( + 'did:web:content.example.com#bsky_appview', + ) + }) }) diff --git a/src/lib/api/community-feed.ts b/src/lib/api/community-feed.ts new file mode 100644 index 000000000..17d9f9cd4 --- /dev/null +++ b/src/lib/api/community-feed.ts @@ -0,0 +1,219 @@ +import {type AtpAgent, AtUri} from '@atproto/api' + +import {getServiceAuthToken} from '#/lib/api/service-auth' + +export const COMMUNITY_FEED_CONFIG_COLLECTION = 'community.blacksky.feed.config' +export const CHECK_FEED_PERMISSIONS = 'community.blacksky.feed.checkPermissions' +export const ADMIT_FEED_POST = 'community.blacksky.feed.admitPost' + +export const COMMUNITY_FEED_PERMISSIONS = [ + 'canView', + 'canPost', + 'canRemovePost', + 'canRemoveMember', + 'canConfigure', + 'canModerate', +] as const + +export type CommunityFeedPermission = + (typeof COMMUNITY_FEED_PERMISSIONS)[number] + +export type CommunityFeedConfig = { + $type: 'community.blacksky.feed.config' + contentType: 'publicRecord' | 'communityRecord' + visibility: 'public' | 'gated' + authorization?: { + serviceDid: string + method?: string + } + policyMode?: 'memberList' | 'managingApp' | 'public' + contentStore?: string + group: string + createdAt: string +} + +export type CommunityFeedTarget = { + feed: string + name: string + serviceDid: string + config: CommunityFeedConfig +} + +type CommunityFeedGenerator = { + serviceDid: string + name: string +} + +function parseCommunityFeedConfig(value: unknown): CommunityFeedConfig | null { + if (!value || typeof value !== 'object') return null + const config = value as Record + const authorization = config.authorization as + | Record + | undefined + if ( + config.$type !== COMMUNITY_FEED_CONFIG_COLLECTION || + (config.contentType !== 'publicRecord' && + config.contentType !== 'communityRecord') || + (config.visibility !== 'public' && config.visibility !== 'gated') || + (authorization !== undefined && + typeof authorization.serviceDid !== 'string') || + typeof config.group !== 'string' || + typeof config.createdAt !== 'string' + ) { + return null + } + return config as CommunityFeedConfig +} + +export async function fetchCommunityFeedConfig( + agent: AtpAgent, + feed: string, +): Promise { + try { + const uri = new AtUri(feed) + if (!uri.rkey) return null + const {data} = await agent.com.atproto.repo.getRecord({ + repo: uri.hostname, + collection: COMMUNITY_FEED_CONFIG_COLLECTION, + rkey: uri.rkey, + }) + return parseCommunityFeedConfig(data.value) + } catch { + return null + } +} + +async function fetchFeedGenerator( + agent: AtpAgent, + feed: string, +): Promise { + try { + const uri = new AtUri(feed) + if (!uri.rkey) return null + const {data} = await agent.com.atproto.repo.getRecord({ + repo: uri.hostname, + collection: 'app.bsky.feed.generator', + rkey: uri.rkey, + }) + const value = data.value as Record + return typeof value.did === 'string' + ? { + serviceDid: value.did, + name: + typeof value.displayName === 'string' ? value.displayName : feed, + } + : null + } catch { + return null + } +} + +export async function fetchFeedServiceDid( + agent: AtpAgent, + feed: string, +): Promise { + return (await fetchFeedGenerator(agent, feed))?.serviceDid ?? null +} + +function isCommunityFeedPermission( + value: unknown, +): value is CommunityFeedPermission { + return ( + typeof value === 'string' && + COMMUNITY_FEED_PERMISSIONS.includes(value as CommunityFeedPermission) + ) +} + +async function fetchFeedPermissionsFromService( + agent: AtpAgent, + feed: string, + serviceDid: string, +): Promise { + try { + const token = await getServiceAuthToken({ + agent, + aud: serviceDid, + lxm: CHECK_FEED_PERMISSIONS, + exp: Math.floor(Date.now() / 1000) + 60, + }) + const response = await agent.fetchHandler( + `/xrpc/${CHECK_FEED_PERMISSIONS}?${new URLSearchParams({feed})}`, + { + headers: { + Authorization: `Bearer ${token}`, + 'atproto-proxy': `${serviceDid}#bsky_fg`, + }, + }, + ) + if (!response.ok) return [] + const body = (await response.json()) as {permissions?: unknown} + return Array.isArray(body.permissions) + ? body.permissions.filter(isCommunityFeedPermission) + : [] + } catch { + return [] + } +} + +export async function fetchFeedPermissions( + agent: AtpAgent, + feed: string, +): Promise { + const config = await fetchCommunityFeedConfig(agent, feed) + if (!config) return [] + const serviceDid = await fetchFeedServiceDid(agent, feed) + return serviceDid + ? fetchFeedPermissionsFromService(agent, feed, serviceDid) + : [] +} + +export async function fetchCommunityFeedTarget( + agent: AtpAgent, + feed: string, +): Promise { + const [config, generator] = await Promise.all([ + fetchCommunityFeedConfig(agent, feed), + fetchFeedGenerator(agent, feed), + ]) + if (!config || !generator) return null + const permissions = await fetchFeedPermissionsFromService( + agent, + feed, + generator.serviceDid, + ) + return permissions.includes('canPost') + ? { + feed, + name: generator.name, + serviceDid: generator.serviceDid, + config, + } + : null +} + +export async function admitFeedPost( + agent: AtpAgent, + target: CommunityFeedTarget, + post: string, + cid: string, +): Promise { + const token = await getServiceAuthToken({ + agent, + aud: target.serviceDid, + lxm: ADMIT_FEED_POST, + exp: Math.floor(Date.now() / 1000) + 60, + }) + const response = await agent.fetchHandler(`/xrpc/${ADMIT_FEED_POST}`, { + method: 'POST', + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json', + 'atproto-proxy': `${target.serviceDid}#bsky_fg`, + }, + body: JSON.stringify({feed: target.feed, post, cid}), + }) + if (!response.ok) { + const body = (await response.json().catch(() => ({}))) as {message?: string} + throw new Error(body.message || `HTTP ${response.status}`) + } +} diff --git a/src/lib/api/community-post.ts b/src/lib/api/community-post.ts new file mode 100644 index 000000000..010e1743a --- /dev/null +++ b/src/lib/api/community-post.ts @@ -0,0 +1,21 @@ +import {type AppBskyFeedDefs, AtUri} from '@atproto/api' + +export type CommunityPostView = AppBskyFeedDefs.PostView & { + communityFeed?: string +} + +export function getCommunityFeedUri( + post: AppBskyFeedDefs.PostView | undefined, +): string | undefined { + const feed = (post as unknown as {communityFeed?: unknown} | undefined) + ?.communityFeed + if (typeof feed !== 'string') return undefined + try { + const uri = new AtUri(feed) + return uri.collection === 'app.bsky.feed.generator' && uri.rkey + ? feed + : undefined + } catch { + return undefined + } +} diff --git a/src/lib/api/community.ts b/src/lib/api/community.ts index cd0aa72f2..976482902 100644 --- a/src/lib/api/community.ts +++ b/src/lib/api/community.ts @@ -2,21 +2,13 @@ import {type BskyAgent} from '@atproto/api' import {HOME_PROXY_HEADER} from '#/lib/constants' -/** - * Make an XRPC call to a community.blacksky.feed.* endpoint. - * - * Calls through the PDS using the agent's session auth and atproto-proxy - * header. The PDS validates the user's credentials, creates a service auth - * JWT signed by the user's keypair, and forwards the request to the appview. - * - * Pinned: community.blacksky.* endpoints only exist on the home appview. - */ export async function communityXrpc( agent: BskyAgent, method: string, opts?: { params?: Record body?: unknown + serviceDid?: string }, ): Promise { const qs = opts?.params @@ -25,7 +17,9 @@ export async function communityXrpc( const path = `/xrpc/${method}${qs}` const headers: Record = { - 'atproto-proxy': HOME_PROXY_HEADER, + 'atproto-proxy': opts?.serviceDid + ? `${opts.serviceDid}#bsky_appview` + : HOME_PROXY_HEADER, } const init: RequestInit = { method: opts?.body ? 'POST' : 'GET', diff --git a/src/lib/api/feed/custom.ts b/src/lib/api/feed/custom.ts index d751629b3..0284f7503 100644 --- a/src/lib/api/feed/custom.ts +++ b/src/lib/api/feed/custom.ts @@ -5,6 +5,12 @@ import { jsonStringToLex, } from '@atproto/api' +import { + type CommunityFeedConfig, + fetchCommunityFeedConfig, + fetchFeedServiceDid, +} from '#/lib/api/community-feed' +import {getServiceAuthToken} from '#/lib/api/service-auth' import { getAppLanguageAsContentLanguage, getContentLanguages, @@ -20,6 +26,8 @@ export class CustomFeedAPI implements FeedAPI { agent: AtpAgent params: GetCustomFeed.QueryParams userInterests?: string + communityConfig: Promise + feedServiceDid: Promise constructor({ agent, @@ -33,10 +41,32 @@ export class CustomFeedAPI implements FeedAPI { this.agent = agent this.params = feedParams this.userInterests = userInterests + this.communityConfig = fetchCommunityFeedConfig(agent, feedParams.feed) + this.feedServiceDid = this.communityConfig.then(config => + config ? fetchFeedServiceDid(agent, feedParams.feed) : null, + ) + } + + async communityAuthHeaders(): Promise> { + const [config, serviceDid] = await Promise.all([ + this.communityConfig, + this.feedServiceDid, + ]) + if (!config || !serviceDid) return {} + const token = await getServiceAuthToken({ + agent: this.agent, + aud: serviceDid, + lxm: 'app.bsky.feed.getFeedSkeleton', + exp: Math.floor(Date.now() / 1000) + 60, + }) + return {Authorization: `Bearer ${token}`} } async peekLatest(): Promise { const contentLangs = getContentLanguages().join(',') + const communityAuthHeaders = this.agent.did + ? await this.communityAuthHeaders() + : {} const res = await this.agent.app.bsky.feed.getFeed( { ...this.params, @@ -45,6 +75,7 @@ export class CustomFeedAPI implements FeedAPI { { headers: { ...getProxyHeadersForFeed(this.params.feed), + ...communityAuthHeaders, 'Accept-Language': contentLangs, }, }, @@ -62,6 +93,9 @@ export class CustomFeedAPI implements FeedAPI { const contentLangs = getContentLanguages().join(',') const agent = this.agent const isBlueskyOwned = isBlueskyOwnedFeed(this.params.feed) + const communityAuthHeaders = agent.did + ? await this.communityAuthHeaders() + : {} const res = agent.did ? await this.agent.app.bsky.feed.getFeed( @@ -73,6 +107,7 @@ export class CustomFeedAPI implements FeedAPI { { headers: { ...getProxyHeadersForFeed(this.params.feed), + ...communityAuthHeaders, ...(isBlueskyOwned ? createBskyTopicsHeader(this.userInterests) : {}), diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index 46a2d8789..be0c9136e 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -26,6 +26,7 @@ import {CID} from 'multiformats/cid' import * as Hasher from 'multiformats/hashes/hasher' import {communityXrpc} from '#/lib/api/community' +import {admitFeedPost, fetchCommunityFeedTarget} from '#/lib/api/community-feed' import {IMAGE_SIZE_CONFIG_POSTS} from '#/lib/constants' import {isNetworkError} from '#/lib/strings/errors' import {shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip' @@ -64,7 +65,20 @@ export async function post( queryClient: QueryClient, opts: PostOpts, ) { - const thread = opts.thread + let thread = opts.thread + if (!opts.replyTo && !thread.communityFeed && thread.communityFeedUri) { + const target = await fetchCommunityFeedTarget( + agent, + thread.communityFeedUri, + ) + if (!target) { + throw new Error( + t`You no longer have permission to post to this community.`, + ) + } + thread = {...thread, communityFeed: target} + opts = {...opts, thread} + } opts.onStateChange?.(t`Processing...`) // Route to community post endpoint if the user explicitly toggled @@ -74,8 +88,15 @@ export async function post( const isQuoteOfCommunityPost = thread.posts.some(p => p.embed.quote?.uri?.includes(COMMUNITY_POST_COLLECTION), ) + const selectedCommunityRecordFeed = + thread.communityFeed?.config.contentType === 'communityRecord' - if (thread.blackskyOnly || isReplyToCommunityPost || isQuoteOfCommunityPost) { + if ( + thread.blackskyOnly || + selectedCommunityRecordFeed || + isReplyToCommunityPost || + isQuoteOfCommunityPost + ) { return postCommunity(agent, queryClient, opts) } @@ -108,6 +129,7 @@ export async function post( const did = agent.assertDid const writes: $Typed[] = [] const uris: string[] = [] + const admissions: Array<{post: string; cid: string}> = [] let now = new Date() let tid: TID | undefined @@ -196,6 +218,9 @@ export async function post( cid: await computeCid(record), uri, } + if (thread.communityFeed?.config.contentType === 'publicRecord') { + admissions.push({post: uri, cid: ref.cid}) + } replyPromise = { root: reply?.root ?? ref, parent: ref, @@ -222,6 +247,14 @@ export async function post( } } + if (thread.communityFeed?.config.contentType === 'publicRecord') { + await Promise.all( + admissions.map(({post, cid}) => + admitFeedPost(agent, thread.communityFeed!, post, cid), + ), + ) + } + return {uris} } @@ -248,6 +281,7 @@ async function postCommunity( const did = agent.assertDid const writes: $Typed[] = [] const uris: string[] = [] + const admissions: Array<{post: string; cid: string}> = [] let now = new Date() let tid: TID | undefined @@ -321,6 +355,9 @@ async function postCommunity( createdAt, expectedCid: cid, // Appview will verify this matches } + if (!reply && thread.communityFeed) { + submitBody.feed = thread.communityFeed.feed + } if (rt.facets?.length) { submitBody.facets = rt.facets } @@ -362,7 +399,10 @@ async function postCommunity( const submitRes = await communityXrpc( agent, 'community.blacksky.feed.submitPost', - {body: submitBody}, + { + body: submitBody, + serviceDid: thread.communityFeed?.config.contentStore, + }, ) if (!submitRes.ok) { const errBody = (await submitRes.json().catch(() => ({}))) as { @@ -419,6 +459,9 @@ async function postCommunity( cid: await computeCid(stubRecord as unknown as AppBskyFeedPost.Record), uri, } + if (thread.communityFeed) { + admissions.push({post: uri, cid: ref.cid}) + } replyPromise = { root: reply?.root ?? ref, parent: ref, @@ -445,6 +488,14 @@ async function postCommunity( } } + if (thread.communityFeed) { + await Promise.all( + admissions.map(({post, cid}) => + admitFeedPost(agent, thread.communityFeed!, post, cid), + ), + ) + } + void queryClient.invalidateQueries({queryKey: ['community-timeline']}) void queryClient.invalidateQueries({queryKey: ['community-feed']}) diff --git a/src/lib/api/service-auth.ts b/src/lib/api/service-auth.ts new file mode 100644 index 000000000..8806de5c3 --- /dev/null +++ b/src/lib/api/service-auth.ts @@ -0,0 +1,26 @@ +import {type AtpAgent} from '@atproto/api' + +import {getServiceAuthAudFromUrl} from '#/lib/strings/url-helpers' + +export async function getServiceAuthToken({ + agent, + aud, + lxm, + exp, +}: { + agent: AtpAgent + aud?: string + lxm: string + exp?: number +}) { + const pdsAud = getServiceAuthAudFromUrl(agent.dispatchUrl) + if (!pdsAud) { + throw new Error('Agent does not have a PDS URL') + } + const {data: serviceAuth} = await agent.com.atproto.server.getServiceAuth({ + aud: aud ?? pdsAud, + lxm, + exp, + }) + return serviceAuth.token +} diff --git a/src/lib/media/video/upload.shared.ts b/src/lib/media/video/upload.shared.ts index f8aaa1249..eb4c917b1 100644 --- a/src/lib/media/video/upload.shared.ts +++ b/src/lib/media/video/upload.shared.ts @@ -2,34 +2,11 @@ import {type AtpAgent} from '@atproto/api' import {type I18n} from '@lingui/core' import {msg} from '@lingui/core/macro' +import {getServiceAuthToken} from '#/lib/api/service-auth' import {VIDEO_SERVICE_DID} from '#/lib/constants' import {UploadLimitError} from '#/lib/media/video/errors' -import {getServiceAuthAudFromUrl} from '#/lib/strings/url-helpers' import {createVideoAgent} from './util' -export async function getServiceAuthToken({ - agent, - aud, - lxm, - exp, -}: { - agent: AtpAgent - aud?: string - lxm: string - exp?: number -}) { - const pdsAud = getServiceAuthAudFromUrl(agent.dispatchUrl) - if (!pdsAud) { - throw new Error('Agent does not have a PDS URL') - } - const {data: serviceAuth} = await agent.com.atproto.server.getServiceAuth({ - aud: aud ?? pdsAud, - lxm, - exp, - }) - return serviceAuth.token -} - export async function getVideoUploadLimits(agent: AtpAgent, i18n: I18n) { const token = await getServiceAuthToken({ agent, diff --git a/src/lib/media/video/upload.ts b/src/lib/media/video/upload.ts index 721ee7f94..c3504d379 100644 --- a/src/lib/media/video/upload.ts +++ b/src/lib/media/video/upload.ts @@ -4,10 +4,11 @@ import {type I18n} from '@lingui/core' import {msg} from '@lingui/core/macro' import {nanoid} from 'nanoid/non-secure' +import {getServiceAuthToken} from '#/lib/api/service-auth' import {AbortError} from '#/lib/async/cancelable' import {ServerError} from '#/lib/media/video/errors' import {type CompressedVideo} from '#/lib/media/video/types' -import {getServiceAuthToken, getVideoUploadLimits} from './upload.shared' +import {getVideoUploadLimits} from './upload.shared' import {createVideoEndpointUrl, mimeToExt} from './util' export async function uploadVideo({ diff --git a/src/lib/media/video/upload.web.ts b/src/lib/media/video/upload.web.ts index 59c6f6597..271827c5e 100644 --- a/src/lib/media/video/upload.web.ts +++ b/src/lib/media/video/upload.web.ts @@ -3,10 +3,11 @@ import {type I18n} from '@lingui/core' import {msg} from '@lingui/core/macro' import {nanoid} from 'nanoid/non-secure' +import {getServiceAuthToken} from '#/lib/api/service-auth' import {AbortError} from '#/lib/async/cancelable' import {ServerError} from '#/lib/media/video/errors' import {type CompressedVideo} from '#/lib/media/video/types' -import {getServiceAuthToken, getVideoUploadLimits} from './upload.shared' +import {getVideoUploadLimits} from './upload.shared' import {createVideoEndpointUrl, mimeToExt} from './util' export async function uploadVideo({ diff --git a/src/screens/PostThread/components/ThreadItemAnchor.tsx b/src/screens/PostThread/components/ThreadItemAnchor.tsx index 8e772da18..603844807 100644 --- a/src/screens/PostThread/components/ThreadItemAnchor.tsx +++ b/src/screens/PostThread/components/ThreadItemAnchor.tsx @@ -9,6 +9,7 @@ import { } from '@atproto/api' import {Plural, Trans, useLingui} from '@lingui/react/macro' +import {getCommunityFeedUri} from '#/lib/api/community-post' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' import {useOpenComposer} from '#/lib/hooks/useOpenComposer' import {makeProfileLink} from '#/lib/routes/links' @@ -258,6 +259,7 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({ embed: post.embed, moderation, langs: record.langs, + communityFeed: getCommunityFeedUri(post), }, onPostSuccess: onPostSuccess, logContext: 'PostReply', diff --git a/src/screens/PostThread/components/ThreadItemPost.tsx b/src/screens/PostThread/components/ThreadItemPost.tsx index 5ee7d85b2..9e4c5eb63 100644 --- a/src/screens/PostThread/components/ThreadItemPost.tsx +++ b/src/screens/PostThread/components/ThreadItemPost.tsx @@ -8,6 +8,7 @@ import { } from '@atproto/api' import {Trans} from '@lingui/react/macro' +import {getCommunityFeedUri} from '#/lib/api/community-post' import {MAX_POST_LINES} from '#/lib/constants' import {useOpenComposer} from '#/lib/hooks/useOpenComposer' import {makeProfileLink} from '#/lib/routes/links' @@ -244,6 +245,7 @@ const ThreadItemPostInner = memo(function ThreadItemPostInner({ embed: post.embed, moderation, langs: post.record.langs, + communityFeed: getCommunityFeedUri(post), }, onPostSuccess: onPostSuccess, logContext: 'PostReply', diff --git a/src/screens/PostThread/components/ThreadItemTreePost.tsx b/src/screens/PostThread/components/ThreadItemTreePost.tsx index c1125110b..c29931f2c 100644 --- a/src/screens/PostThread/components/ThreadItemTreePost.tsx +++ b/src/screens/PostThread/components/ThreadItemTreePost.tsx @@ -8,6 +8,7 @@ import { } from '@atproto/api' import {Trans} from '@lingui/react/macro' +import {getCommunityFeedUri} from '#/lib/api/community-post' import {MAX_POST_LINES} from '#/lib/constants' import {useOpenComposer} from '#/lib/hooks/useOpenComposer' import {makeProfileLink} from '#/lib/routes/links' @@ -306,6 +307,7 @@ const ThreadItemTreePostInner = memo(function ThreadItemTreePostInner({ embed: post.embed, moderation, langs: post.record.langs, + communityFeed: getCommunityFeedUri(post), }, onPostSuccess: onPostSuccess, logContext: 'PostReply', diff --git a/src/screens/PostThread/index.tsx b/src/screens/PostThread/index.tsx index 64d652972..909009699 100644 --- a/src/screens/PostThread/index.tsx +++ b/src/screens/PostThread/index.tsx @@ -10,6 +10,7 @@ import {useWindowDimensions, View} from 'react-native' import Animated, {useAnimatedStyle} from 'react-native-reanimated' import {Trans} from '@lingui/react/macro' +import {getCommunityFeedUri} from '#/lib/api/community-post' import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' import {useOpenComposer} from '#/lib/hooks/useOpenComposer' @@ -131,6 +132,7 @@ export function PostThread({uri}: {uri: string}) { embed: post.embed, moderation: anchor.moderation, langs: post.record.langs, + communityFeed: getCommunityFeedUri(post), }, onPostSuccess: optimisticOnPostReply, logContext: 'PostReply', diff --git a/src/screens/VideoFeed/index.tsx b/src/screens/VideoFeed/index.tsx index 7e760b88d..3efffd896 100644 --- a/src/screens/VideoFeed/index.tsx +++ b/src/screens/VideoFeed/index.tsx @@ -43,6 +43,7 @@ import { } from '@react-navigation/native' import {type NativeStackScreenProps} from '@react-navigation/native-stack' +import {getCommunityFeedUri} from '#/lib/api/community-post' import {HITSLOP_20} from '#/lib/constants' import {useHaptics} from '#/lib/haptics' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' @@ -772,6 +773,7 @@ function Overlay({ author: post.author, embed: post.embed, langs: record?.langs, + communityFeed: getCommunityFeedUri(post), }, logContext: 'PostReply', }) diff --git a/src/state/queries/community-feed-permissions.ts b/src/state/queries/community-feed-permissions.ts new file mode 100644 index 000000000..7479767b8 --- /dev/null +++ b/src/state/queries/community-feed-permissions.ts @@ -0,0 +1,23 @@ +import {useQuery} from '@tanstack/react-query' + +import { + type CommunityFeedPermission, + fetchFeedPermissions, +} from '#/lib/api/community-feed' +import {useAgent, useSession} from '#/state/session' + +export const feedPermissionsQueryKey = ( + did: string | undefined, + feed: string, +) => ['community-feed-permissions', did ?? '', feed] + +export function useFeedPermissionsQuery(feed: string) { + const agent = useAgent() + const {currentAccount} = useSession() + return useQuery({ + queryKey: feedPermissionsQueryKey(currentAccount?.did, feed), + enabled: !!currentAccount?.did && !!feed, + staleTime: 60 * 1000, + queryFn: () => fetchFeedPermissions(agent, feed), + }) +} diff --git a/src/state/queries/community-post-targets.ts b/src/state/queries/community-post-targets.ts new file mode 100644 index 000000000..172a904d3 --- /dev/null +++ b/src/state/queries/community-post-targets.ts @@ -0,0 +1,34 @@ +import {useQuery} from '@tanstack/react-query' + +import { + type CommunityFeedTarget, + fetchCommunityFeedTarget, +} from '#/lib/api/community-feed' +import {STALE} from '#/state/queries' +import {useSavedFeeds} from '#/state/queries/feed' +import {useAgent, useSession} from '#/state/session' + +export function useCommunityPostTargets() { + const agent = useAgent() + const {currentAccount} = useSession() + const {data, isLoading} = useSavedFeeds() + const feeds = (data?.feeds ?? []).filter(item => item.type === 'feed') + const feedUris = feeds.map(item => item.view.uri) + + return useQuery({ + queryKey: ['community-post-targets', currentAccount?.did ?? '', feedUris], + enabled: !!currentAccount?.did && !isLoading, + staleTime: STALE.MINUTES.FIVE, + queryFn: async () => { + const targets = await Promise.all( + feeds.map(async item => { + const target = await fetchCommunityFeedTarget(agent, item.view.uri) + return target ? {...target, name: item.view.displayName} : null + }), + ) + return targets.filter( + (target): target is CommunityFeedTarget => target !== null, + ) + }, + }) +} diff --git a/src/state/queries/feed.ts b/src/state/queries/feed.ts index 951d0f1a3..e31ed7f2f 100644 --- a/src/state/queries/feed.ts +++ b/src/state/queries/feed.ts @@ -21,6 +21,10 @@ import { useQueryClient, } from '@tanstack/react-query' +import { + type CommunityFeedConfig, + fetchCommunityFeedConfig, +} from '#/lib/api/community-feed' import {getProxyHeadersForFeed} from '#/lib/api/feed/utils' import {useBrand} from '#/lib/community/BrandContext' import {DEFAULT_DISCOVERY_FEEDS} from '#/lib/community/configGenerator' @@ -222,6 +226,20 @@ export function useFeedSourceInfoQuery({uri}: {uri: string}) { }) } +export const communityFeedConfigQueryKey = (uri: string) => [ + 'community-feed-config', + uri, +] + +export function useCommunityFeedConfigQuery({uri}: {uri: string}) { + const agent = useAgent() + return useQuery({ + queryKey: communityFeedConfigQueryKey(uri), + staleTime: STALE.INFINITY, + queryFn: () => fetchCommunityFeedConfig(agent, uri), + }) +} + // HACK // the protocol doesn't yet tell us which feeds are personalized // this list is used to filter out feed recommendations from logged out users diff --git a/src/state/shell/composer/index.tsx b/src/state/shell/composer/index.tsx index 9a1e212f4..e1c4cfa3d 100644 --- a/src/state/shell/composer/index.tsx +++ b/src/state/shell/composer/index.tsx @@ -27,6 +27,7 @@ export interface ComposerOptsPostRef { author: AppBskyActorDefs.ProfileViewBasic embed?: AppBskyFeedDefs.PostView['embed'] moderation?: ModerationDecision + communityFeed?: string } export type OnPostSuccessData = diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index e83db8211..c97f25d5e 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -60,6 +60,7 @@ import {Trans, useLingui} from '@lingui/react/macro' import {useNavigation} from '@react-navigation/native' import {useQueries, useQueryClient} from '@tanstack/react-query' +import {getCommunityFeedUri} from '#/lib/api/community-post' import * as apilib from '#/lib/api/index' import {EmbeddingDisabledError} from '#/lib/api/resolve' import {useAppState} from '#/lib/appState' @@ -119,6 +120,7 @@ import {LabelsBtn} from '#/view/com/composer/labels/LabelsBtn' import {Gallery} from '#/view/com/composer/photos/Gallery' import {OpenCameraBtn} from '#/view/com/composer/photos/OpenCameraBtn' import {SelectGifBtn} from '#/view/com/composer/photos/SelectGifBtn' +import {PostTargetSelect} from '#/view/com/composer/PostTargetSelect' import {SuggestedLanguage} from '#/view/com/composer/select-language/SuggestedLanguage' // TODO: Prevent naming components that coincide with RN primitives // due to linting false positives @@ -133,7 +135,6 @@ import {Admonition} from '#/components/Admonition' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {CommunityOnlyBadge} from '#/components/CommunityOnlyBadge' import * as EmojiPicker from '#/components/EmojiPicker' -import * as Toggle from '#/components/forms/Toggle' import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfoIcon} from '#/components/icons/CircleInfo' import {EmojiArc_Stroke2_Corner0_Rounded as EmojiSmileIcon} from '#/components/icons/Emoji' import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus' @@ -363,11 +364,16 @@ export const ComposePost = ({ const setBlackskyOnlyDefault = useSetBlackskyOnlyDefault() const {data: isCommunityMember = false} = useCommunityMembership() - // Force Blacksky-Only when the thread targets a community post — replies - // and quotes of a community post can only land in the community. + const isCommunityReply = + !!replyTo?.uri && replyTo.uri.includes('community.blacksky.feed.post') + const isCommunityQuote = + !!initQuote?.uri && initQuote.uri.includes('community.blacksky.feed.post') + const replyCommunityFeed = replyTo?.communityFeed + const quoteCommunityFeed = getCommunityFeedUri(initQuote) const isForcedBlackskyOnly = - (!!replyTo?.uri && replyTo.uri.includes('community.blacksky.feed.post')) || - (!!initQuote?.uri && initQuote.uri.includes('community.blacksky.feed.post')) + (isCommunityReply && !replyCommunityFeed) || + (isCommunityQuote && !quoteCommunityFeed) + const isForcedCommunityTarget = isCommunityReply || isCommunityQuote const [composerState, composerDispatch] = useReducer( composerReducer, @@ -377,6 +383,7 @@ export const ComposePost = ({ initText, initMention, initInteractionSettings: preferences?.postInteractionSettings, + initCommunityFeedUri: replyCommunityFeed ?? quoteCommunityFeed, // Replies inherit their parent's audience: forced on for community // parents, forced off for public parents. The sticky default only // applies to top-level posts, and only for community members. @@ -1326,6 +1333,7 @@ export const ComposePost = ({ dispatch={composerDispatch} bottomBarAnimatedStyle={bottomBarAnimatedStyle} isForcedBlackskyOnly={isForcedBlackskyOnly} + isForcedCommunityTarget={isForcedCommunityTarget} setBlackskyOnlyDefault={setBlackskyOnlyDefault} /> void bottomBarAnimatedStyle: StyleProp isForcedBlackskyOnly: boolean + isForcedCommunityTarget: boolean setBlackskyOnlyDefault: (v: boolean) => void }) { const t = useTheme() - const {t: l} = useLingui() const {data: isCommunityMember = false} = useCommunityMembership() const homeAppviewOutage = useHomeAppviewOutage() const media = post.embed.media @@ -2006,7 +2015,13 @@ function ComposerPills({ media?.type === 'video' const hasLink = !!post.embed.link - if (isReply && !hasMedia && !hasLink && !isForcedBlackskyOnly) { + if ( + isReply && + !hasMedia && + !hasLink && + !isForcedBlackskyOnly && + !thread.communityFeedUri + ) { return null } @@ -2036,27 +2051,14 @@ function ComposerPills({ style={bottomBarAnimatedStyle} /> )} - {!isCommunityMember || (isReply && !isForcedBlackskyOnly) ? null : ( - { - const next = !thread.blackskyOnly - dispatch({type: 'toggle_blacksky_only'}) - setBlackskyOnlyDefault(next) - }} - style={[a.flex_row, a.align_center, a.gap_xs]}> - - {homeAppviewOutage ? ( - Blacksky Only (temporarily unavailable) - ) : ( - Blacksky Only - )} - - - + {isReply || isForcedCommunityTarget ? null : ( + )} {hasMedia || hasLink ? ( ) : null} - {thread.blackskyOnly && ( + {(thread.blackskyOnly || thread.communityFeedUri) && ( - + )} diff --git a/src/view/com/composer/PostTargetSelect.tsx b/src/view/com/composer/PostTargetSelect.tsx new file mode 100644 index 000000000..3542ab872 --- /dev/null +++ b/src/view/com/composer/PostTargetSelect.tsx @@ -0,0 +1,95 @@ +import {View} from 'react-native' +import {useLingui} from '@lingui/react/macro' + +import {useCommunityPostTargets} from '#/state/queries/community-post-targets' +import { + type ComposerAction, + type ThreadDraft, +} from '#/view/com/composer/state/composer' +import {atoms as a} from '#/alf' +import * as Select from '#/components/Select' + +export function PostTargetSelect({ + thread, + dispatch, + isCommunityMember, + homeAppviewOutage, + setBlackskyOnlyDefault, +}: { + thread: ThreadDraft + dispatch: (action: ComposerAction) => void + isCommunityMember: boolean + homeAppviewOutage: boolean + setBlackskyOnlyDefault: (value: boolean) => void +}) { + const {t} = useLingui() + const {data: targets = []} = useCommunityPostTargets() + const options = [ + {value: 'public', label: t`Public`}, + ...(isCommunityMember + ? [ + { + value: 'blacksky', + label: homeAppviewOutage + ? t`Blacksky Only (temporarily unavailable)` + : t`Blacksky Only`, + }, + ] + : []), + ...targets.map(target => ({ + value: target.feed, + label: target.name, + target, + })), + ] + const value = + thread.communityFeed?.feed ?? + thread.communityFeedUri ?? + (thread.blackskyOnly ? 'blacksky' : 'public') + const selected = options.find(option => option.value === value) + + return ( + + { + if (next === 'blacksky') { + if (homeAppviewOutage) return + dispatch({type: 'set_post_target', target: 'blacksky'}) + setBlackskyOnlyDefault(true) + return + } + setBlackskyOnlyDefault(false) + if (next === 'public') { + dispatch({type: 'set_post_target', target: 'public'}) + return + } + const target = targets.find(candidate => candidate.feed === next) + if (target) dispatch({type: 'set_post_target', target}) + }}> + + + + + ( + + + + {option.label} + + + )} + /> + + + ) +} diff --git a/src/view/com/composer/state/composer.ts b/src/view/com/composer/state/composer.ts index b1a64ae71..a04b69af1 100644 --- a/src/view/com/composer/state/composer.ts +++ b/src/view/com/composer/state/composer.ts @@ -8,6 +8,7 @@ import { } from '@atproto/api' import {nanoid} from 'nanoid/non-secure' +import {type CommunityFeedTarget} from '#/lib/api/community-feed' import {type SelfLabel} from '#/lib/moderation' import {insertMentionAt} from '#/lib/strings/mention-manip' import {shortenLinks} from '#/lib/strings/rich-text-manip' @@ -103,6 +104,8 @@ export type ThreadDraft = { postgate: AppBskyFeedPostgate.Record threadgate: ThreadgateAllowUISetting[] blackskyOnly: boolean + communityFeed?: CommunityFeedTarget + communityFeedUri?: string } export type ComposerState = { @@ -123,6 +126,10 @@ export type ComposerAction = | {type: 'update_postgate'; postgate: AppBskyFeedPostgate.Record} | {type: 'update_threadgate'; threadgate: ThreadgateAllowUISetting[]} | {type: 'toggle_blacksky_only'} + | { + type: 'set_post_target' + target: 'public' | 'blacksky' | CommunityFeedTarget + } | { type: 'update_post' postId: string @@ -220,6 +227,22 @@ export function composerReducer( thread: { ...state.thread, blackskyOnly: !state.thread.blackskyOnly, + communityFeed: undefined, + communityFeedUri: undefined, + }, + } + } + case 'set_post_target': { + return { + ...state, + isDirty: true, + thread: { + ...state.thread, + blackskyOnly: action.target === 'blacksky', + communityFeed: + typeof action.target === 'string' ? undefined : action.target, + communityFeedUri: + typeof action.target === 'string' ? undefined : action.target.feed, }, } } @@ -631,6 +654,7 @@ export function createComposerState({ initQuoteUri, initInteractionSettings, initBlackskyOnly, + initCommunityFeedUri, }: { initText: string | undefined initMention: string | undefined @@ -640,6 +664,7 @@ export function createComposerState({ | AppBskyActorDefs.PostInteractionSettingsPref | undefined initBlackskyOnly?: boolean + initCommunityFeedUri?: string }): ComposerState { let media: ImagesMedia | GalleryMedia | undefined if (initImageUris?.length) { @@ -761,6 +786,7 @@ export function createComposerState({ allow: initInteractionSettings?.threadgateAllowRules, }), blackskyOnly: !!initBlackskyOnly, + communityFeedUri: initCommunityFeedUri, }, } } diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index 0e701312e..87107f23a 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -10,6 +10,7 @@ import { } from '@atproto/api' import {useQueryClient} from '@tanstack/react-query' +import {getCommunityFeedUri} from '#/lib/api/community-post' import {MAX_POST_LINES} from '#/lib/constants' import {useOpenComposer} from '#/lib/hooks/useOpenComposer' import {makeProfileLink} from '#/lib/routes/links' @@ -143,6 +144,7 @@ function PostInner({ embed: post.embed, moderation, langs: record.langs, + communityFeed: getCommunityFeedUri(post), }, logContext: 'PostReply', }) diff --git a/src/view/com/posts/PostFeedItem.tsx b/src/view/com/posts/PostFeedItem.tsx index 6fa693578..0897791fb 100644 --- a/src/view/com/posts/PostFeedItem.tsx +++ b/src/view/com/posts/PostFeedItem.tsx @@ -11,6 +11,7 @@ import { } from '@atproto/api' import {useQueryClient} from '@tanstack/react-query' +import {getCommunityFeedUri} from '#/lib/api/community-post' import {type ReasonFeedSource} from '#/lib/api/feed/types' import {MAX_POST_LINES} from '#/lib/constants' import {useOpenComposer} from '#/lib/hooks/useOpenComposer' @@ -200,6 +201,7 @@ let FeedItemInner = ({ embed: post.embed, moderation, langs: record.langs, + communityFeed: getCommunityFeedUri(post), }, logContext: 'PostReply', })