pl-api: explicitly specify formdata

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-03-18 16:36:28 +01:00
parent c2c6846f98
commit cee7d9c065
8 changed files with 17 additions and 15 deletions

View File

@ -137,7 +137,7 @@ const ImportDataPage = () => {
.request('/api/pleroma/archive_import', {
method: 'POST',
body: form,
contentType: '',
formData: true,
})
.then(() => {
toast.success(messages.archiveSuccess);

View File

@ -1525,7 +1525,7 @@ const admin = (client: PlApiBaseClient) => {
const response = await client.request('/api/v1/admin/custom_emojis', {
method: 'POST',
body: params,
contentType: '',
formData: true,
});
return v.parse(adminCustomEmojiSchema, response.json);
@ -1535,7 +1535,7 @@ const admin = (client: PlApiBaseClient) => {
const response = await client.request(`/api/v1/admin/custom_emojis/${emojiId}`, {
method: 'PATCH',
body: params,
contentType: '',
formData: true,
});
return v.parse(adminCustomEmojiSchema, response.json);

View File

@ -81,7 +81,7 @@ const drive = (client: PlApiBaseClient) => ({
method: 'POST',
body: { file },
params: { folderId },
contentType: '',
formData: true,
});
return v.parse(driveFileSchema, response.json);

View File

@ -131,7 +131,7 @@ const events = (client: PlApiBaseClient) => ({
*/
getEventIcs: async (statusId: string) => {
const response = await client.request(`/api/v1/pleroma/events/${statusId}/ics`, {
contentType: '',
formData: true,
});
return response.data;

View File

@ -76,7 +76,7 @@ const oauth = (client: PlApiBaseClient) => ({
const response = await client.request('/oauth/token', {
method: 'POST',
body: params,
contentType: '',
formData: true,
});
return v.parse(tokenSchema, { scope: params.scope || '', ...response.json });
@ -91,7 +91,7 @@ const oauth = (client: PlApiBaseClient) => ({
const response = await client.request<EmptyObject>('/oauth/revoke', {
method: 'POST',
body: params,
contentType: '',
formData: true,
});
client.socket?.close();

View File

@ -559,7 +559,7 @@ const settings = (client: PlApiBaseClient) => ({
response = await client.request('/api/v1/import', {
method: 'POST',
body: { data: list, type: 'following', mode },
contentType: '',
formData: true,
});
break;
case MITRA:
@ -572,7 +572,7 @@ const settings = (client: PlApiBaseClient) => ({
response = await client.request('/api/pleroma/follow_import', {
method: 'POST',
body: { list },
contentType: '',
formData: true,
});
}
@ -611,14 +611,14 @@ const settings = (client: PlApiBaseClient) => ({
response = await client.request('/api/v1/import', {
method: 'POST',
body: { data: list, type: 'blocks', mode },
contentType: '',
formData: true,
});
break;
default:
response = await client.request('/api/pleroma/blocks_import', {
method: 'POST',
body: { list },
contentType: '',
formData: true,
});
}
@ -640,14 +640,14 @@ const settings = (client: PlApiBaseClient) => ({
response = await client.request('/api/v1/import', {
method: 'POST',
body: { data: list, type: 'blocks', mode },
contentType: '',
formData: true,
});
break;
default:
response = await client.request('/api/pleroma/mutes_import', {
method: 'POST',
body: { list },
contentType: '',
formData: true,
});
}

View File

@ -110,7 +110,7 @@ const stories = (client: PlApiBaseClient) => ({
const response = await client.request('/api/web/stories/v1/add', {
method: 'POST',
body: { file },
contentType: '',
formData: true,
});
return v.parse(storyMediaSchema, response.json);

View File

@ -78,6 +78,7 @@ interface RequestBody<Params = Record<string, any>> {
onUploadProgress?: (e: ProgressEvent) => void;
signal?: AbortSignal;
contentType?: string;
formData?: boolean;
idempotencyKey?: string;
}
@ -96,6 +97,7 @@ function request<T = any>(
onUploadProgress,
signal,
contentType = 'application/json',
formData,
idempotencyKey,
}: RequestBody = {},
) {
@ -108,7 +110,7 @@ function request<T = any>(
else if (this.accessToken) headers.set('Authorization', `Bearer ${this.accessToken}`);
else if (this.customAuthorizationToken)
headers.set('Authorization', this.customAuthorizationToken);
if (contentType !== '' && body) headers.set('Content-Type', contentType);
if (!formData) headers.set('Content-Type', contentType);
if (idempotencyKey) headers.set('Idempotency-Key', idempotencyKey);
body = body && contentType === '' ? serialize(body, { indices: true }) : JSON.stringify(body);