mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-11-27 14:28:08 +09:00
[mastodon-client] Fix request body handling for polls
This commit is contained in:
parent
fb8b2ce0df
commit
0f497f7fec
@ -13,8 +13,6 @@ import { Cache } from "@/misc/cache.js";
|
||||
import AsyncLock from "async-lock";
|
||||
import { ILocalUser } from "@/models/entities/user.js";
|
||||
import { PollHelpers } from "@/server/api/mastodon/helpers/poll.js";
|
||||
import querystring from "node:querystring";
|
||||
import qs from "qs";
|
||||
|
||||
const postIdempotencyCache = new Cache<{status?: MastodonEntity.Status}>('postIdempotencyCache', 60 * 60);
|
||||
const postIdempotencyLocks = new AsyncLock();
|
||||
@ -617,7 +615,7 @@ export function setupEndpointsStatus(router: Router): void {
|
||||
return;
|
||||
}
|
||||
|
||||
const body: any = qs.parse(querystring.stringify(ctx.request.body as any));
|
||||
const body: any = ctx.request.body;
|
||||
const choices = NoteHelpers.normalizeToArray(body.choices ?? []).map(p => parseInt(p));
|
||||
if (choices.length < 1) {
|
||||
ctx.status = 400;
|
||||
|
@ -5,9 +5,7 @@ import {
|
||||
NoteFavorites,
|
||||
NoteReactions,
|
||||
Notes,
|
||||
RegistryItems,
|
||||
UserNotePinings,
|
||||
Users
|
||||
UserNotePinings
|
||||
} from "@/models/index.js";
|
||||
import { generateVisibilityQuery } from "@/server/api/common/generate-visibility-query.js";
|
||||
import { generateMutedUserQuery } from "@/server/api/common/generate-muted-user-query.js";
|
||||
@ -23,14 +21,11 @@ import deleteNote from "@/services/note/delete.js";
|
||||
import { genId } from "@/misc/gen-id.js";
|
||||
import { PaginationHelpers } from "@/server/api/mastodon/helpers/pagination.js";
|
||||
import { UserConverter } from "@/server/api/mastodon/converters/user.js";
|
||||
import { AccountCache, LinkPaginationObject, UserHelpers } from "@/server/api/mastodon/helpers/user.js";
|
||||
import { LinkPaginationObject, UserHelpers } from "@/server/api/mastodon/helpers/user.js";
|
||||
import { addPinned, removePinned } from "@/services/i/pin.js";
|
||||
import { NoteConverter } from "@/server/api/mastodon/converters/note.js";
|
||||
import { convertId, IdType } from "@/misc/convert-id.js";
|
||||
import querystring from "node:querystring";
|
||||
import qs from "qs";
|
||||
import { awaitAll } from "@/prelude/await-all.js";
|
||||
import { IsNull } from "typeorm";
|
||||
import { VisibilityConverter } from "@/server/api/mastodon/converters/visibility.js";
|
||||
import mfm from "mfm-js";
|
||||
import { FileConverter } from "@/server/api/mastodon/converters/file.js";
|
||||
@ -321,8 +316,6 @@ export class NoteHelpers {
|
||||
public static normalizeComposeOptions(body: any): MastodonEntity.StatusCreationRequest {
|
||||
const result: MastodonEntity.StatusCreationRequest = {};
|
||||
|
||||
body = qs.parse(querystring.stringify(body));
|
||||
|
||||
if (body.status !== null)
|
||||
result.text = body.status;
|
||||
if (body.spoiler_text !== null)
|
||||
@ -357,8 +350,6 @@ export class NoteHelpers {
|
||||
public static normalizeEditOptions(body: any): MastodonEntity.StatusEditRequest {
|
||||
const result: MastodonEntity.StatusEditRequest = {};
|
||||
|
||||
body = qs.parse(querystring.stringify(body));
|
||||
|
||||
if (body.status !== null)
|
||||
result.text = body.status;
|
||||
if (body.spoiler_text !== null)
|
||||
|
Loading…
Reference in New Issue
Block a user