parent
ccb1269991
commit
421553b8cd
|
@ -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;
|
||||||
|
});
|
|
@ -250,7 +250,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 投稿を作成
|
// Create a post
|
||||||
const note = await create(user, {
|
const note = await create(user, {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
files: files,
|
files: files,
|
||||||
|
|
|
@ -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<Note>(async (res, rej) => {
|
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<Note>(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 && data.channel && data.reply.channelId !== data.channel.id) {
|
||||||
if (data.reply.channelId) {
|
if (data.reply.channelId) {
|
||||||
data.channel = await Channels.findOneBy({ id: 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) {
|
if (data.reply && (data.channel == null) && data.reply.channelId) {
|
||||||
data.channel = await Channels.findOneBy({ id: 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.visibleUsers = [];
|
||||||
if (data.channel != null) data.localOnly = true;
|
if (data.channel != null) data.localOnly = true;
|
||||||
|
|
||||||
// サイレンス
|
// enforce silent clients on server
|
||||||
if (user.isSilenced && data.visibility === 'public' && data.channel == null) {
|
if (user.isSilenced && data.visibility === 'public' && data.channel == null) {
|
||||||
data.visibility = 'home';
|
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) {
|
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');
|
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') {
|
if (data.renote && data.renote.visibility !== 'public' && data.visibility === 'public') {
|
||||||
data.visibility = 'home';
|
data.visibility = 'home';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renote対象がfollowersならfollowersにする
|
// If the target of Renote is followers, make it followers.
|
||||||
if (data.renote && data.renote.visibility === 'followers') {
|
if (data.renote && data.renote.visibility === 'followers') {
|
||||||
data.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') {
|
if (data.reply && data.reply.visibility !== 'public' && data.visibility === 'public') {
|
||||||
data.visibility = 'home';
|
data.visibility = 'home';
|
||||||
}
|
}
|
||||||
|
|
||||||
// ローカルのみをRenoteしたらローカルのみにする
|
// Renote local only if you Renote local only.
|
||||||
if (data.renote && data.renote.localOnly && data.channel == null) {
|
if (data.renote && data.renote.localOnly && data.channel == null) {
|
||||||
data.localOnly = true;
|
data.localOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ローカルのみにリプライしたらローカルのみにする
|
// If you reply to local only, make it local only.
|
||||||
if (data.reply && data.reply.localOnly && data.channel == null) {
|
if (data.reply && data.reply.localOnly && data.channel == null) {
|
||||||
data.localOnly = true;
|
data.localOnly = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue