2024-07-18 14:36:09 +00:00
|
|
|
import api, { apiRequest, getLinks } from 'mastodon/api';
|
2024-07-31 10:50:13 +00:00
|
|
|
import type { ApiNotificationGroupsResultJSON } from 'mastodon/api_types/notifications';
|
2024-07-18 14:36:09 +00:00
|
|
|
|
|
|
|
export const apiFetchNotifications = async (params?: {
|
|
|
|
exclude_types?: string[];
|
|
|
|
max_id?: string;
|
2024-08-21 14:41:31 +00:00
|
|
|
since_id?: string;
|
2024-07-18 14:36:09 +00:00
|
|
|
}) => {
|
2024-07-31 10:50:13 +00:00
|
|
|
const response = await api().request<ApiNotificationGroupsResultJSON>({
|
2024-07-18 14:36:09 +00:00
|
|
|
method: 'GET',
|
|
|
|
url: '/api/v2_alpha/notifications',
|
|
|
|
params,
|
|
|
|
});
|
|
|
|
|
2024-07-31 10:50:13 +00:00
|
|
|
const { statuses, accounts, notification_groups } = response.data;
|
|
|
|
|
|
|
|
return {
|
|
|
|
statuses,
|
|
|
|
accounts,
|
|
|
|
notifications: notification_groups,
|
|
|
|
links: getLinks(response),
|
|
|
|
};
|
2024-07-18 14:36:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const apiClearNotifications = () =>
|
|
|
|
apiRequest<undefined>('POST', 'v1/notifications/clear');
|