pleroma/app/soapbox/features/scheduled_statuses/builder.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

import { fromJS } from 'immutable';
2022-02-19 23:27:29 -08:00
import { normalizeStatus } from 'soapbox/normalizers/status';
2022-02-21 00:56:31 -08:00
import { calculateStatus } from 'soapbox/reducers/statuses';
import { makeGetAccount } from 'soapbox/selectors';
export const buildStatus = (state, scheduledStatus) => {
const getAccount = makeGetAccount();
const me = state.get('me');
const params = scheduledStatus.get('params');
const account = getAccount(state, me);
2022-02-19 23:27:29 -08:00
const status = {
account,
content: params.get('text', '').replace(new RegExp('\n', 'g'), '<br>'), /* eslint-disable-line no-control-regex */
created_at: params.get('scheduled_at'),
id: scheduledStatus.get('id'),
in_reply_to_id: params.get('in_reply_to_id'),
media_attachments: scheduledStatus.get('media_attachments'),
poll: params.get('poll'),
sensitive: params.get('sensitive'),
uri: `/scheduled_statuses/${scheduledStatus.get('id')}`,
url: `/scheduled_statuses/${scheduledStatus.get('id')}`,
visibility: params.get('visibility'),
2022-02-19 23:27:29 -08:00
};
2022-02-21 00:56:31 -08:00
return calculateStatus(normalizeStatus(fromJS(status)));
};