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