Merge remote-tracking branch 'parent/main' into upstream-20240918
This commit is contained in:
commit
4ce35dd837
188 changed files with 1994 additions and 980 deletions
|
@ -1,7 +1,14 @@
|
|||
import api, { apiRequest, getLinks } from 'mastodon/api';
|
||||
import api, {
|
||||
apiRequest,
|
||||
getLinks,
|
||||
apiRequestGet,
|
||||
apiRequestPost,
|
||||
} from 'mastodon/api';
|
||||
import type {
|
||||
ApiNotificationGroupsResultJSON,
|
||||
ApiNotificationGroupJSON,
|
||||
ApiNotificationRequestJSON,
|
||||
ApiNotificationJSON,
|
||||
} from 'mastodon/api_types/notifications';
|
||||
import type { ApiStatusJSON } from 'mastodon/api_types/statuses';
|
||||
|
||||
|
@ -16,14 +23,34 @@ const exceptInvalidNotifications = (
|
|||
});
|
||||
};
|
||||
|
||||
export const apiFetchNotifications = async (params?: {
|
||||
export const apiFetchNotifications = async (
|
||||
params?: {
|
||||
account_id?: string;
|
||||
since_id?: string;
|
||||
},
|
||||
url?: string,
|
||||
) => {
|
||||
const response = await api().request<ApiNotificationJSON[]>({
|
||||
method: 'GET',
|
||||
url: url ?? '/api/v1/notifications',
|
||||
params,
|
||||
});
|
||||
|
||||
return {
|
||||
notifications: response.data,
|
||||
links: getLinks(response),
|
||||
};
|
||||
};
|
||||
|
||||
export const apiFetchNotificationGroups = async (params?: {
|
||||
url?: string;
|
||||
exclude_types?: string[];
|
||||
max_id?: string;
|
||||
since_id?: string;
|
||||
}) => {
|
||||
const response = await api().request<ApiNotificationGroupsResultJSON>({
|
||||
method: 'GET',
|
||||
url: '/api/v2_alpha/notifications',
|
||||
url: '/api/v2/notifications',
|
||||
params,
|
||||
});
|
||||
|
||||
|
@ -39,3 +66,43 @@ export const apiFetchNotifications = async (params?: {
|
|||
|
||||
export const apiClearNotifications = () =>
|
||||
apiRequest<undefined>('POST', 'v1/notifications/clear');
|
||||
|
||||
export const apiFetchNotificationRequests = async (
|
||||
params?: {
|
||||
since_id?: string;
|
||||
},
|
||||
url?: string,
|
||||
) => {
|
||||
const response = await api().request<ApiNotificationRequestJSON[]>({
|
||||
method: 'GET',
|
||||
url: url ?? '/api/v1/notifications/requests',
|
||||
params,
|
||||
});
|
||||
|
||||
return {
|
||||
requests: response.data,
|
||||
links: getLinks(response),
|
||||
};
|
||||
};
|
||||
|
||||
export const apiFetchNotificationRequest = async (id: string) => {
|
||||
return apiRequestGet<ApiNotificationRequestJSON>(
|
||||
`v1/notifications/requests/${id}`,
|
||||
);
|
||||
};
|
||||
|
||||
export const apiAcceptNotificationRequest = async (id: string) => {
|
||||
return apiRequestPost(`v1/notifications/requests/${id}/accept`);
|
||||
};
|
||||
|
||||
export const apiDismissNotificationRequest = async (id: string) => {
|
||||
return apiRequestPost(`v1/notifications/requests/${id}/dismiss`);
|
||||
};
|
||||
|
||||
export const apiAcceptNotificationRequests = async (id: string[]) => {
|
||||
return apiRequestPost('v1/notifications/requests/accept', { id });
|
||||
};
|
||||
|
||||
export const apiDismissNotificationRequests = async (id: string[]) => {
|
||||
return apiRequestPost('v1/notifications/dismiss/dismiss', { id });
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue