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