2022-03-12 13:01:00 -08:00
|
|
|
/**
|
|
|
|
* Notification normalizer:
|
|
|
|
* Converts API notifications into our internal format.
|
|
|
|
* @see {@link https://docs.joinmastodon.org/entities/notification/}
|
|
|
|
*/
|
2022-03-11 10:13:36 -08:00
|
|
|
import {
|
|
|
|
Map as ImmutableMap,
|
|
|
|
Record as ImmutableRecord,
|
2022-03-16 19:33:09 -07:00
|
|
|
fromJS,
|
2022-03-11 10:13:36 -08:00
|
|
|
} from 'immutable';
|
|
|
|
|
|
|
|
// https://docs.joinmastodon.org/entities/notification/
|
2022-03-16 19:15:38 -07:00
|
|
|
export const NotificationRecord = ImmutableRecord({
|
2022-03-11 10:13:36 -08:00
|
|
|
account: null,
|
|
|
|
chat_message: null, // pleroma:chat_mention
|
|
|
|
created_at: new Date(),
|
|
|
|
emoji: null, // pleroma:emoji_reaction
|
|
|
|
id: '',
|
|
|
|
status: null,
|
|
|
|
target: null, // move
|
|
|
|
type: '',
|
|
|
|
});
|
|
|
|
|
2022-03-16 19:33:09 -07:00
|
|
|
export const normalizeNotification = (notification: Record<string, any>) => {
|
|
|
|
return NotificationRecord(
|
|
|
|
ImmutableMap(fromJS(notification)),
|
|
|
|
);
|
2022-03-11 10:13:36 -08:00
|
|
|
};
|