summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/notes
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/server/api/endpoints/notes')
-rw-r--r--packages/backend/src/server/api/endpoints/notes/create.ts72
-rw-r--r--packages/backend/src/server/api/endpoints/notes/global-timeline.ts6
-rw-r--r--packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts6
-rw-r--r--packages/backend/src/server/api/endpoints/notes/local-timeline.ts6
-rw-r--r--packages/backend/src/server/api/endpoints/notes/search-by-tag.ts39
-rw-r--r--packages/backend/src/server/api/endpoints/notes/search.ts6
-rw-r--r--packages/backend/src/server/api/endpoints/notes/timeline.ts6
-rw-r--r--packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts6
8 files changed, 38 insertions, 109 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts
index 4b18ab6023..961983f5f4 100644
--- a/packages/backend/src/server/api/endpoints/notes/create.ts
+++ b/packages/backend/src/server/api/endpoints/notes/create.ts
@@ -59,6 +59,12 @@ export const meta = {
id: '3ac74a84-8fd5-4bb0-870f-01804f82ce15',
},
+ contentRequired: {
+ message: 'Content required. You need to set text, fileIds, renoteId or poll.',
+ code: 'CONTENT_REQUIRED',
+ id: '6f57e42b-c348-439b-bc45-993995cc515a',
+ },
+
cannotCreateAlreadyExpiredPoll: {
message: 'Poll is already expired.',
code: 'CANNOT_CREATE_ALREADY_EXPIRED_POLL',
@@ -86,41 +92,29 @@ export const paramDef = {
visibleUserIds: { type: 'array', uniqueItems: true, items: {
type: 'string', format: 'misskey:id',
} },
- text: { type: 'string', maxLength: MAX_NOTE_TEXT_LENGTH, nullable: true },
+ text: { type: 'string', nullable: true, maxLength: MAX_NOTE_TEXT_LENGTH, default: null },
cw: { type: 'string', nullable: true, maxLength: 100 },
localOnly: { type: 'boolean', default: false },
noExtractMentions: { type: 'boolean', default: false },
noExtractHashtags: { type: 'boolean', default: false },
noExtractEmojis: { type: 'boolean', default: false },
- fileIds: {
- type: 'array',
- uniqueItems: true,
- minItems: 1,
- maxItems: 16,
- items: { type: 'string', format: 'misskey:id' },
- },
- mediaIds: {
- deprecated: true,
- description: 'Use `fileIds` instead. If both are specified, this property is discarded.',
- type: 'array',
- uniqueItems: true,
- minItems: 1,
- maxItems: 16,
- items: { type: 'string', format: 'misskey:id' },
- },
+ fileIds: { type: 'array', uniqueItems: true, minItems: 1, maxItems: 16, items: {
+ type: 'string', format: 'misskey:id',
+ } },
+ mediaIds: { type: 'array', uniqueItems: true, minItems: 1, maxItems: 16, items: {
+ type: 'string', format: 'misskey:id',
+ } },
replyId: { type: 'string', format: 'misskey:id', nullable: true },
renoteId: { type: 'string', format: 'misskey:id', nullable: true },
channelId: { type: 'string', format: 'misskey:id', nullable: true },
poll: {
- type: 'object',
- nullable: true,
+ type: 'object', nullable: true,
properties: {
choices: {
- type: 'array',
- uniqueItems: true,
- minItems: 2,
- maxItems: 10,
- items: { type: 'string', minLength: 1, maxLength: 50 },
+ type: 'array', uniqueItems: true, minItems: 2, maxItems: 10,
+ items: {
+ type: 'string', minLength: 1, maxLength: 50,
+ },
},
multiple: { type: 'boolean', default: false },
expiresAt: { type: 'integer', nullable: true },
@@ -129,30 +123,7 @@ export const paramDef = {
required: ['choices'],
},
},
- anyOf: [
- {
- // (re)note with text, files and poll are optional
- properties: {
- text: { type: 'string', maxLength: MAX_NOTE_TEXT_LENGTH, nullable: false },
- },
- required: ['text'],
- },
- {
- // (re)note with files, text and poll are optional
- required: ['fileIds'],
- },
- {
- // (re)note with files, text and poll are optional
- required: ['mediaIds'],
- },
- {
- // (re)note with poll, text and files are optional
- properties: {
- poll: { type: 'object', nullable: false, },
- },
- required: ['poll'],
- },
- ],
+ required: [],
} as const;
// eslint-disable-next-line import/no-default-export
@@ -233,6 +204,11 @@ export default define(meta, paramDef, async (ps, user) => {
}
}
+ // テキストが無いかつ添付ファイルが無いかつRenoteも無いかつ投票も無かったらエラー
+ if (!(ps.text || files.length || renote || ps.poll)) {
+ throw new ApiError(meta.errors.contentRequired);
+ }
+
let channel: Channel | undefined;
if (ps.channelId != null) {
channel = await Channels.findOneBy({ id: ps.channelId });
diff --git a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
index cb402ecaa1..09a8194665 100644
--- a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts
@@ -35,11 +35,7 @@ export const meta = {
export const paramDef = {
type: 'object',
properties: {
- withFiles: {
- type: 'boolean',
- default: false,
- description: 'Only show notes that have attached files.',
- },
+ withFiles: { type: 'boolean' },
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
index f9893527e0..7c9c122963 100644
--- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts
@@ -48,11 +48,7 @@ export const paramDef = {
includeMyRenotes: { type: 'boolean', default: true },
includeRenotedMyNotes: { type: 'boolean', default: true },
includeLocalRenotes: { type: 'boolean', default: true },
- withFiles: {
- type: 'boolean',
- default: false,
- description: 'Only show notes that have attached files.',
- },
+ withFiles: { type: 'boolean' },
},
required: [],
} as const;
diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
index 03edf30b31..bb0bbe2a20 100644
--- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts
@@ -37,11 +37,7 @@ export const meta = {
export const paramDef = {
type: 'object',
properties: {
- withFiles: {
- type: 'boolean',
- default: false,
- description: 'Only show notes that have attached files.',
- },
+ withFiles: { type: 'boolean' },
fileType: { type: 'array', items: {
type: 'string',
} },
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 bb85c92008..c6503eb057 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
@@ -25,44 +25,21 @@ export const meta = {
export const paramDef = {
type: 'object',
properties: {
+ tag: { type: 'string' },
+ query: { type: 'array', items: {
+ type: 'array', items: {
+ type: 'string',
+ },
+ } },
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.',
- },
+ withFiles: { type: 'boolean' },
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 },
},
- anyOf: [
- {
- properties: {
- tag: { type: 'string', minLength: 1 },
- },
- required: ['tag'],
- },
- {
- 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'],
- },
- ],
+ required: [],
} as const;
// eslint-disable-next-line import/no-default-export
diff --git a/packages/backend/src/server/api/endpoints/notes/search.ts b/packages/backend/src/server/api/endpoints/notes/search.ts
index af9b5f0a10..e77892b150 100644
--- a/packages/backend/src/server/api/endpoints/notes/search.ts
+++ b/packages/backend/src/server/api/endpoints/notes/search.ts
@@ -35,11 +35,7 @@ export const paramDef = {
untilId: { type: 'string', format: 'misskey:id' },
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
offset: { type: 'integer', default: 0 },
- host: {
- type: 'string',
- nullable: true,
- description: 'The local host is represented with `null`.',
- },
+ host: { type: 'string', nullable: true },
userId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
channelId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
},
diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts
index 0f976d18be..fde66b241b 100644
--- a/packages/backend/src/server/api/endpoints/notes/timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts
@@ -38,11 +38,7 @@ export const paramDef = {
includeMyRenotes: { type: 'boolean', default: true },
includeRenotedMyNotes: { type: 'boolean', default: true },
includeLocalRenotes: { type: 'boolean', default: true },
- withFiles: {
- type: 'boolean',
- default: false,
- description: 'Only show notes that have attached files.',
- },
+ withFiles: { type: 'boolean' },
},
required: [],
} as const;
diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
index 6c6402603a..866e306d8d 100644
--- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
+++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts
@@ -42,11 +42,7 @@ export const paramDef = {
includeMyRenotes: { type: 'boolean', default: true },
includeRenotedMyNotes: { type: 'boolean', default: true },
includeLocalRenotes: { type: 'boolean', default: true },
- withFiles: {
- type: 'boolean',
- default: false,
- description: 'Only show notes that have attached files.',
- },
+ withFiles: { type: 'boolean' },
},
required: ['listId'],
} as const;