pl-fe: Accept posts without accounts (terrible workaround)
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -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 === '<p></p>' ? '' : note))), ''),
|
||||
visibility: v.fallback(v.string(), 'public'),
|
||||
sensitive: v.pipe(v.unknown(), v.transform(Boolean)),
|
||||
|
||||
@ -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<string, any>) => !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;
|
||||
|
||||
|
||||
@ -83,6 +83,7 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
||||
space={2}
|
||||
onClick={handleExpandClick}
|
||||
>
|
||||
{account.id && (
|
||||
<AccountContainer
|
||||
{...actions}
|
||||
id={account.id}
|
||||
@ -91,6 +92,7 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
||||
showAccountHoverCard={!compose}
|
||||
withLinkToProfile={!compose}
|
||||
/>
|
||||
)}
|
||||
|
||||
<StatusReplyMentions status={status} hoverable={false} />
|
||||
|
||||
|
||||
@ -382,6 +382,7 @@ const Status: React.FC<IStatus> = (props) => {
|
||||
>
|
||||
{statusInfo}
|
||||
|
||||
{actualStatus.account_id && (
|
||||
<div className='flex'>
|
||||
<AccountContainer
|
||||
key={actualStatus.account_id}
|
||||
@ -409,6 +410,7 @@ const Status: React.FC<IStatus> = (props) => {
|
||||
actionAlignment='top'
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className='status__content-wrapper'>
|
||||
<StatusReplyMentions status={actualStatus} hoverable={hoverable} />
|
||||
|
||||
@ -88,6 +88,7 @@ const DetailedStatus: React.FC<IDetailedStatus> = ({
|
||||
<div ref={node} className='detailed-actualStatus' tabIndex={-1}>
|
||||
{renderStatusInfo()}
|
||||
|
||||
{account.id && (
|
||||
<div className='mb-4'>
|
||||
<Account
|
||||
key={account.id}
|
||||
@ -97,6 +98,7 @@ const DetailedStatus: React.FC<IDetailedStatus> = ({
|
||||
approvalStatus={actualStatus.approval_status}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<StatusReplyMentions status={actualStatus} />
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
/// <reference path="../node_modules/@types/dom-chromium-ai/index.d.ts" />
|
||||
(window as any).__PL_API_FALLBACK_ACCOUNT = { id: '', acct: 'undefined', url: location.host };
|
||||
|
||||
import './polyfills';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user