normalizeStatus: normalize quote post
This commit is contained in:
parent
2d00c404d3
commit
34ba2505bd
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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']));
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue