From b892674a3f86df6491372b559a78a281c48c34cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Thu, 25 Dec 2025 20:14:47 +0100 Subject: [PATCH] pl-fe: Accept posts without accounts (terrible workaround) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-api/lib/entities/status.ts | 5 +- packages/pl-fe/src/actions/importer.ts | 19 +------ .../pl-fe/src/components/quoted-status.tsx | 18 ++++--- packages/pl-fe/src/components/status.tsx | 54 ++++++++++--------- .../status/components/detailed-status.tsx | 20 +++---- packages/pl-fe/src/main.tsx | 1 + 6 files changed, 55 insertions(+), 62 deletions(-) diff --git a/packages/pl-api/lib/entities/status.ts b/packages/pl-api/lib/entities/status.ts index f5985ea8a..071b223a4 100644 --- a/packages/pl-api/lib/entities/status.ts +++ b/packages/pl-api/lib/entities/status.ts @@ -42,7 +42,10 @@ const baseStatusSchema = v.object({ id: v.string(), uri: v.fallback(v.pipe(v.string(), v.url()), ''), created_at: v.fallback(datetimeSchema, new Date().toISOString()), - account: accountSchema, + account: v.pipe(v.unknown(), v.transform((account) => { + if ((window as any).__PL_API_FALLBACK_ACCOUNT && JSON.stringify(account) === '{}') return (window as any).__PL_API_FALLBACK_ACCOUNT; + return account; + }), accountSchema), content: v.fallback(v.pipe(v.string(), v.transform((note => note === '

' ? '' : note))), ''), visibility: v.fallback(v.string(), 'public'), sensitive: v.pipe(v.unknown(), v.transform(Boolean)), diff --git a/packages/pl-fe/src/actions/importer.ts b/packages/pl-fe/src/actions/importer.ts index 944189815..391c708b5 100644 --- a/packages/pl-fe/src/actions/importer.ts +++ b/packages/pl-fe/src/actions/importer.ts @@ -10,23 +10,6 @@ const STATUS_IMPORT = 'STATUS_IMPORT' as const; const STATUSES_IMPORT = 'STATUSES_IMPORT' as const; const POLLS_IMPORT = 'POLLS_IMPORT' as const; -// Sometimes Pleroma can return an empty account, -// or a repost can appear of a deleted account. Skip these statuses. -const isBroken = (status: BaseStatus) => { - try { - if (status.scheduled_at !== null) return true; - // Skip empty accounts - // https://gitlab.com/soapbox-pub/soapbox/-/issues/424 - if (!status.account.id) return true; - // Skip broken reposts - // https://gitlab.com/soapbox-pub/rebased/-/issues/28 - if (status.reblog && !status.reblog.account.id) return true; - return false; - } catch (e) { - return true; - } -}; - const isEmpty = (object: Record) => !Object.values(object).some(value => value); interface ImportStatusAction { @@ -80,7 +63,7 @@ const importEntities = (entities: { const processStatus = (status: BaseStatus, withSelf = true) => { // Skip broken statuses - if (isBroken(status)) return; + if (status.scheduled_at !== null) return; if (withSelf) statuses[status.id] = status; diff --git a/packages/pl-fe/src/components/quoted-status.tsx b/packages/pl-fe/src/components/quoted-status.tsx index 0edbed4e1..264b3cbcc 100644 --- a/packages/pl-fe/src/components/quoted-status.tsx +++ b/packages/pl-fe/src/components/quoted-status.tsx @@ -83,14 +83,16 @@ const QuotedStatus: React.FC = ({ status, onCancel, compose }) => space={2} onClick={handleExpandClick} > - + {account.id && ( + + )} diff --git a/packages/pl-fe/src/components/status.tsx b/packages/pl-fe/src/components/status.tsx index 3564708b7..989dfac1f 100644 --- a/packages/pl-fe/src/components/status.tsx +++ b/packages/pl-fe/src/components/status.tsx @@ -382,33 +382,35 @@ const Status: React.FC = (props) => { > {statusInfo} -
- - event.stopPropagation()}> - - - - - {!!actualStatus.edited_at && ( - <> - + {actualStatus.account_id && ( +
+ + event.stopPropagation()}> + + + + + {!!actualStatus.edited_at && ( + <> + - - - )} -
- } - showAccountHoverCard={hoverable} - withLinkToProfile={hoverable} - approvalStatus={actualStatus.approval_status} - avatarSize={avatarSize} - actionAlignment='top' - /> -
+ + + )} + + } + showAccountHoverCard={hoverable} + withLinkToProfile={hoverable} + approvalStatus={actualStatus.approval_status} + avatarSize={avatarSize} + actionAlignment='top' + /> + + )}
diff --git a/packages/pl-fe/src/features/status/components/detailed-status.tsx b/packages/pl-fe/src/features/status/components/detailed-status.tsx index d86f180fe..c04b4eb6f 100644 --- a/packages/pl-fe/src/features/status/components/detailed-status.tsx +++ b/packages/pl-fe/src/features/status/components/detailed-status.tsx @@ -88,15 +88,17 @@ const DetailedStatus: React.FC = ({
{renderStatusInfo()} -
- -
+ {account.id && ( +
+ +
+ )} diff --git a/packages/pl-fe/src/main.tsx b/packages/pl-fe/src/main.tsx index 2b9c27e01..f380feae7 100644 --- a/packages/pl-fe/src/main.tsx +++ b/packages/pl-fe/src/main.tsx @@ -1,4 +1,5 @@ /// +(window as any).__PL_API_FALLBACK_ACCOUNT = { id: '', acct: 'undefined', url: location.host }; import './polyfills';