bigbuffet-rw/packages/pl-fe/src/normalizers/notification.ts

21 lines
685 B
TypeScript
Raw Normal View History

import omit from 'lodash/omit';
import type { Notification as BaseNotification, NotificationGroup } from 'pl-api';
const normalizeNotification = (notification: BaseNotification): NotificationGroup => ({
...(omit(notification, ['account', 'status', 'target'])),
group_key: notification.id,
notifications_count: 1,
most_recent_notification_id: notification.id,
page_min_id: notification.id,
page_max_id: notification.id,
latest_page_notification_at: notification.created_at,
sample_account_ids: [notification.account.id],
// @ts-ignore
status_id: notification.status?.id,
// @ts-ignore
target_id: notification.target?.id,
2022-03-11 10:13:36 -08:00
});
export { normalizeNotification };