diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-08-18 22:44:21 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-18 22:44:21 +0900 |
| commit | 9855405b8989713b81709fc1700e2ead97423467 (patch) | |
| tree | 54254d2159378d1903e962f0fb37c799bb0f4464 /src/server/api/endpoints/notes/create.ts | |
| parent | Sign (request-target) Fix #6652 (#6656) (diff) | |
| download | sharkey-9855405b8989713b81709fc1700e2ead97423467.tar.gz sharkey-9855405b8989713b81709fc1700e2ead97423467.tar.bz2 sharkey-9855405b8989713b81709fc1700e2ead97423467.zip | |
Channel (#6621)
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wop
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* add notes
* wip
* wip
* wip
* wip
* sound
* wip
* add kick_gaba2
* wip
Diffstat (limited to 'src/server/api/endpoints/notes/create.ts')
| -rw-r--r-- | src/server/api/endpoints/notes/create.ts | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/server/api/endpoints/notes/create.ts b/src/server/api/endpoints/notes/create.ts index 5076dad82a..b8c4900af7 100644 --- a/src/server/api/endpoints/notes/create.ts +++ b/src/server/api/endpoints/notes/create.ts @@ -7,11 +7,12 @@ import { fetchMeta } from '../../../../misc/fetch-meta'; import { ApiError } from '../../error'; import { ID } from '../../../../misc/cafy-id'; import { User } from '../../../../models/entities/user'; -import { Users, DriveFiles, Notes } from '../../../../models'; +import { Users, DriveFiles, Notes, Channels } from '../../../../models'; import { DriveFile } from '../../../../models/entities/drive-file'; import { Note } from '../../../../models/entities/note'; import { DB_MAX_NOTE_TEXT_LENGTH } from '../../../../misc/hard-limits'; import { noteVisibilities } from '../../../../types'; +import { Channel } from '../../../../models/entities/channel'; let maxNoteTextLength = 500; @@ -128,19 +129,26 @@ export const meta = { }, replyId: { - validator: $.optional.type(ID), + validator: $.optional.nullable.type(ID), desc: { 'ja-JP': '返信対象' } }, renoteId: { - validator: $.optional.type(ID), + validator: $.optional.nullable.type(ID), desc: { 'ja-JP': 'Renote対象' } }, + channelId: { + validator: $.optional.nullable.type(ID), + desc: { + 'ja-JP': 'チャンネル' + } + }, + poll: { validator: $.optional.obj({ choices: $.arr($.str) @@ -206,7 +214,13 @@ export const meta = { message: 'Poll is already expired.', code: 'CANNOT_CREATE_ALREADY_EXPIRED_POLL', id: '04da457d-b083-4055-9082-955525eda5a5' - } + }, + + noSuchChannel: { + message: 'No such channel.', + code: 'NO_SUCH_CHANNEL', + id: 'b1653923-5453-4edc-b786-7c4f39bb0bbb' + }, } }; @@ -269,6 +283,15 @@ export default define(meta, async (ps, user) => { throw new ApiError(meta.errors.contentRequired); } + let channel: Channel | undefined; + if (ps.channelId != null) { + channel = await Channels.findOne(ps.channelId); + + if (channel == null) { + throw new ApiError(meta.errors.noSuchChannel); + } + } + // 投稿を作成 const note = await create(user, { createdAt: new Date(), @@ -286,6 +309,7 @@ export default define(meta, async (ps, user) => { localOnly: ps.localOnly, visibility: ps.visibility, visibleUsers, + channel, apMentions: ps.noExtractMentions ? [] : undefined, apHashtags: ps.noExtractHashtags ? [] : undefined, apEmojis: ps.noExtractEmojis ? [] : undefined, |