From 542fb006603ec7a25f9f06ec27fd2d0a33bb6ad4 Mon Sep 17 00:00:00 2001 From: cutestnekoaqua Date: Thu, 8 Dec 2022 01:05:07 +0100 Subject: [PATCH] WIP move api call forgot to merge this --- .../src/server/api/endpoints/i/move.ts | 46 +++++++++++++++++++ .../src/server/api/endpoints/notes/create.ts | 2 +- packages/backend/src/services/note/create.ts | 22 ++++----- 3 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 packages/backend/src/server/api/endpoints/i/move.ts diff --git a/packages/backend/src/server/api/endpoints/i/move.ts b/packages/backend/src/server/api/endpoints/i/move.ts new file mode 100644 index 000000000..a1ee31d51 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/i/move.ts @@ -0,0 +1,46 @@ +import { In } from 'typeorm'; +import { User } from '@/models/entities/user.js'; +import { Users, DriveFiles, Notes, Channels, Blockings } from '@/models/index.js'; +import { ApiError } from '../../error.js'; +import define from '../../define.js'; +import { DAY } from '@/const.js'; + +export const meta = { + tags: ['notes'], + + secure: true, + requireCredential: true, + + limit: { + duration: DAY, + max: 1, + }, + + errors: { + noSuchMoveTarget: { + message: 'No such move target.', + code: 'NO_SUCH_MOVE_TARGET', + id: 'b5c90186-4ab0-49c8-9bba-a1f76c202ba4', + }, + remoteAccountForbids: { + message: 'Remote account doesn\'t have proper known As.', + code: 'REMOTE_ACCOUNT_FORBIDS', + id: 'b5c90186-4ab0-49c8-9bba-a1f766282ba4', + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + alsoKnownAs: { type: 'string' }, + }, + required: ['alsoKnownAs'], +} as const; + +// eslint-disable-next-line import/no-default-export +export default define(meta, paramDef, async (ps, user) => { + + + return; +}); diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 82540f96b..da34f3c8d 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -250,7 +250,7 @@ export default define(meta, paramDef, async (ps, user) => { } } - // 投稿を作成 + // Create a post const note = await create(user, { createdAt: new Date(), files: files, diff --git a/packages/backend/src/services/note/create.ts b/packages/backend/src/services/note/create.ts index 8ba2963d5..fa8ba6bf1 100644 --- a/packages/backend/src/services/note/create.ts +++ b/packages/backend/src/services/note/create.ts @@ -127,8 +127,8 @@ type Option = { }; export default async (user: { id: User['id']; username: User['username']; host: User['host']; isSilenced: User['isSilenced']; createdAt: User['createdAt']; }, data: Option, silent = false) => new Promise(async (res, rej) => { - // チャンネル外にリプライしたら対象のスコープに合わせる - // (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで) + // If you reply outside the channel, match the scope of the target. + // TODO (I think it's a process that could be done on the client side, but it's server side for now.) if (data.reply && data.channel && data.reply.channelId !== data.channel.id) { if (data.reply.channelId) { data.channel = await Channels.findOneBy({ id: data.reply.channelId }); @@ -137,8 +137,8 @@ export default async (user: { id: User['id']; username: User['username']; host: } } - // チャンネル内にリプライしたら対象のスコープに合わせる - // (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで) + // When you reply in a channel, match the scope of the target + // TODO (I think it's a process that could be done on the client side, but it's server side for now.) if (data.reply && (data.channel == null) && data.reply.channelId) { data.channel = await Channels.findOneBy({ id: data.reply.channelId }); } @@ -150,37 +150,37 @@ export default async (user: { id: User['id']; username: User['username']; host: if (data.channel != null) data.visibleUsers = []; if (data.channel != null) data.localOnly = true; - // サイレンス + // enforce silent clients on server if (user.isSilenced && data.visibility === 'public' && data.channel == null) { data.visibility = 'home'; } - // Renote対象が「ホームまたは全体」以外の公開範囲ならreject + // Reject if the target of the renote is a public range other than "Home or Entire". if (data.renote && data.renote.visibility !== 'public' && data.renote.visibility !== 'home' && data.renote.userId !== user.id) { return rej('Renote target is not public or home'); } - // Renote対象がpublicではないならhomeにする + // If the target of the renote is not public, make it home. if (data.renote && data.renote.visibility !== 'public' && data.visibility === 'public') { data.visibility = 'home'; } - // Renote対象がfollowersならfollowersにする + // If the target of Renote is followers, make it followers. if (data.renote && data.renote.visibility === 'followers') { data.visibility = 'followers'; } - // 返信対象がpublicではないならhomeにする + // If the reply target is not public, make it home. if (data.reply && data.reply.visibility !== 'public' && data.visibility === 'public') { data.visibility = 'home'; } - // ローカルのみをRenoteしたらローカルのみにする + // Renote local only if you Renote local only. if (data.renote && data.renote.localOnly && data.channel == null) { data.localOnly = true; } - // ローカルのみにリプライしたらローカルのみにする + // If you reply to local only, make it local only. if (data.reply && data.reply.localOnly && data.channel == null) { data.localOnly = true; }