normalizeStatus: normalize quote post

This commit is contained in:
Alex Gleason 2022-02-23 18:25:38 -05:00
parent 2d00c404d3
commit 34ba2505bd
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 19 additions and 1 deletions

View File

@ -71,4 +71,12 @@ describe('normalizeStatus', () => {
expect(status.get('media_attachments')).toEqual(result.get('media_attachments'));
});
it('normalizes Pleroma quote post', () => {
const status = fromJS(require('soapbox/__fixtures__/pleroma-quote-post.json'));
const result = normalizeStatus(status);
expect(result.get('quote')).toEqual(status.getIn(['pleroma', 'quote']));
expect(result.getIn(['pleroma', 'quote'])).toBe(undefined);
});
});

View File

@ -73,10 +73,19 @@ const addSelfMention = status => {
}
};
// Move the quote to the top-level
const fixQuote = status => {
return status.withMutations(status => {
status.update('quote', quote => quote || status.getIn(['pleroma', 'quote']) || null);
status.deleteIn(['pleroma', 'quote']);
});
};
export const normalizeStatus = status => {
return status.withMutations(status => {
setRequiredFields(status);
fixMentions(status);
fixQuote(status);
addSelfMention(status);
normalizeAttachments(status);
});

View File

@ -42,7 +42,7 @@ const minifyStatus = status => {
account: status.getIn(['account', 'id']),
reblog: status.getIn(['reblog', 'id']),
poll: status.getIn(['poll', 'id']),
quote: status.getIn(['quote', 'id']) || status.getIn(['pleroma', 'quote', 'id']),
quote: status.getIn(['quote', 'id']),
});
};
@ -70,6 +70,7 @@ export const calculateStatus = (status, oldStatus, expandSpoilers = false) => {
}
};
// Check whether a status is a quote by secondary characteristics
const isQuote = status => {
return Boolean(status.get('quote_id') || status.getIn(['pleroma', 'quote_url']));
};