summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/notes
diff options
context:
space:
mode:
authorzyoshoka <107108195+zyoshoka@users.noreply.github.com>2025-05-27 08:57:09 +0900
committerGitHub <noreply@github.com>2025-05-27 08:57:09 +0900
commitd27075c5f536a86a6c81cb3c3cec92b302663e2e (patch)
treec9ab17782c4bc77da1f534c8731bbad5a0000849 /packages/backend/src/server/api/endpoints/notes
parentfix(backend): add response schema for `notes/show-partial-bulk` endpoint (#16... (diff)
downloadmisskey-d27075c5f536a86a6c81cb3c3cec92b302663e2e.tar.gz
misskey-d27075c5f536a86a6c81cb3c3cec92b302663e2e.tar.bz2
misskey-d27075c5f536a86a6c81cb3c3cec92b302663e2e.zip
fix(backend): correct invalid schema format specifying only `required` for `anyOf` (#16089)
* fix(backend): correct invalid schema format specifying only `required` for `anyOf` * refactor(backend): make types derived from `allOf` or `anyOf` more strong
Diffstat (limited to 'packages/backend/src/server/api/endpoints/notes')
-rw-r--r--packages/backend/src/server/api/endpoints/notes/search-by-tag.ts75
1 files changed, 45 insertions, 30 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts
index d0781bd8dd..3e41b33d03 100644
--- a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts
+++ b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts
@@ -28,38 +28,53 @@ export const meta = {
} as const;
export const paramDef = {
- type: 'object',
- properties: {
- reply: { type: 'boolean', nullable: true, default: null },
- renote: { type: 'boolean', nullable: true, default: null },
- withFiles: {
- type: 'boolean',
- default: false,
- description: 'Only show notes that have attached files.',
+ allOf: [
+ {
+ anyOf: [
+ {
+ type: 'object',
+ properties: {
+ tag: { type: 'string', minLength: 1 },
+ },
+ required: ['tag'],
+ },
+ {
+ type: 'object',
+ properties: {
+ query: {
+ type: 'array',
+ description: 'The outer arrays are chained with OR, the inner arrays are chained with AND.',
+ items: {
+ type: 'array',
+ items: {
+ type: 'string',
+ minLength: 1,
+ },
+ minItems: 1,
+ },
+ minItems: 1,
+ },
+ },
+ required: ['query'],
+ },
+ ],
},
- poll: { type: 'boolean', nullable: true, default: null },
- sinceId: { type: 'string', format: 'misskey:id' },
- untilId: { type: 'string', format: 'misskey:id' },
- limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
-
- tag: { type: 'string', minLength: 1 },
- query: {
- type: 'array',
- description: 'The outer arrays are chained with OR, the inner arrays are chained with AND.',
- items: {
- type: 'array',
- items: {
- type: 'string',
- minLength: 1,
+ {
+ type: 'object',
+ properties: {
+ reply: { type: 'boolean', nullable: true, default: null },
+ renote: { type: 'boolean', nullable: true, default: null },
+ withFiles: {
+ type: 'boolean',
+ default: false,
+ description: 'Only show notes that have attached files.',
},
- minItems: 1,
+ poll: { type: 'boolean', nullable: true, default: null },
+ sinceId: { type: 'string', format: 'misskey:id' },
+ untilId: { type: 'string', format: 'misskey:id' },
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
},
- minItems: 1,
},
- },
- anyOf: [
- { required: ['tag'] },
- { required: ['query'] },
],
} as const;
@@ -87,12 +102,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (me) this.queryService.generateBlockedUserQueryForNotes(query, me);
try {
- if (ps.tag) {
+ if ('tag' in ps) {
if (!safeForSql(normalizeForSearch(ps.tag))) throw new Error('Injection');
query.andWhere(':tag <@ note.tags', { tag: [normalizeForSearch(ps.tag)] });
} else {
query.andWhere(new Brackets(qb => {
- for (const tags of ps.query!) {
+ for (const tags of ps.query) {
qb.orWhere(new Brackets(qb => {
for (const tag of tags) {
if (!safeForSql(normalizeForSearch(tag))) throw new Error('Injection');