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