fix lint "quotes"
Some checks failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/test Pipeline failed

This commit is contained in:
Johann150 2022-08-02 23:25:36 +02:00
parent 4122d90f56
commit a6df127d3b
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1
68 changed files with 156 additions and 155 deletions

View file

@ -154,7 +154,7 @@ function spawnWorker(): Promise<void> {
const worker = cluster.fork();
worker.on('message', message => {
if (message === 'listenFailed') {
bootLogger.error(`The server Listen failed due to the previous error.`);
bootLogger.error('The server Listen failed due to the previous error.');
process.exit(1);
}
if (message !== 'ready') return;

View file

@ -58,7 +58,7 @@ export async function getFileInfo(path: string): Promise<FileInfo> {
// うまく判定できない画像は octet-stream にする
if (!imageSize) {
warnings.push(`cannot detect image dimensions`);
warnings.push('cannot detect image dimensions');
type = TYPE_OCTET_STREAM;
} else if (imageSize.wUnits === 'px') {
width = imageSize.width;
@ -67,7 +67,7 @@ export async function getFileInfo(path: string): Promise<FileInfo> {
// 制限を超えている画像は octet-stream にする
if (imageSize.width > 16383 || imageSize.height > 16383) {
warnings.push(`image dimensions exceeds limits`);
warnings.push('image dimensions exceeds limits');
type = TYPE_OCTET_STREAM;
}
} else {

View file

@ -6,7 +6,7 @@ import { Packed } from './schema.js';
*/
export const getNoteSummary = (note: Packed<'Note'>): string => {
if (note.deletedAt) {
return `(❌⛔)`;
return '(❌⛔)';
}
let summary = '';
@ -25,7 +25,7 @@ export const getNoteSummary = (note: Packed<'Note'>): string => {
// 投票が添付されているとき
if (note.poll) {
summary += ` (📊)`;
summary += ' (📊)';
}
// 返信のとき

View file

@ -42,7 +42,7 @@ export async function deleteAccount(job: Bull.Job<DbUserDeleteJobData>): Promise
await Notes.delete(notes.map(note => note.id));
}
logger.succ(`All of notes deleted`);
logger.succ('All of notes deleted');
}
{ // Delete files
@ -71,15 +71,15 @@ export async function deleteAccount(job: Bull.Job<DbUserDeleteJobData>): Promise
}
}
logger.succ(`All of files deleted`);
logger.succ('All of files deleted');
}
{ // Send email notification
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
if (profile.email && profile.emailVerified) {
sendEmail(profile.email, 'Account deleted',
`Your account has been deleted.`,
`Your account has been deleted.`);
'Your account has been deleted.',
'Your account has been deleted.');
}
}

View file

@ -16,7 +16,7 @@ import { IsNull } from 'typeorm';
const logger = queueLogger.createSubLogger('export-custom-emojis');
export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promise<void> {
logger.info(`Exporting custom emojis ...`);
logger.info('Exporting custom emojis ...');
const user = await Users.findOneBy({ id: job.data.user.id });
if (user == null) {

View file

@ -15,7 +15,7 @@ const logger = queueLogger.createSubLogger('import-custom-emojis');
// TODO: 名前衝突時の動作を選べるようにする
export async function importCustomEmojis(job: Bull.Job<DbUserImportJobData>, done: any): Promise<void> {
logger.info(`Importing custom emojis ...`);
logger.info('Importing custom emojis ...');
const file = await DriveFiles.findOneBy({
id: job.data.fileId,

View file

@ -69,12 +69,12 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
// それでもわからなければ終了
if (authUser == null) {
return `skip: failed to resolve user`;
return 'skip: failed to resolve user';
}
// publicKey がなくても終了
if (authUser.key == null) {
return `skip: failed to resolve user publicKey`;
return 'skip: failed to resolve user publicKey';
}
// HTTP-Signatureの検証
@ -98,18 +98,18 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
// keyIdからLD-Signatureのユーザーを取得
authUser = await dbResolver.getAuthUserFromKeyId(activity.signature.creator);
if (authUser == null) {
return `skip: LD-Signatureのユーザーが取得できませんでした`;
return 'skip: LD-Signatureのユーザーが取得できませんでした';
}
if (authUser.key == null) {
return `skip: LD-SignatureのユーザーはpublicKeyを持っていませんでした`;
return 'skip: LD-SignatureのユーザーはpublicKeyを持っていませんでした';
}
// LD-Signature検証
const ldSignature = new LdSignature();
const verified = await ldSignature.verifyRsaSignature2017(activity, authUser.key.keyPem).catch(() => false);
if (!verified) {
return `skip: LD-Signatureの検証に失敗しました`;
return 'skip: LD-Signatureの検証に失敗しました';
}
// もう一度actorチェック
@ -153,5 +153,5 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
// アクティビティを処理
await perform(authUser.user, activity);
return `ok`;
return 'ok';
};

View file

@ -8,7 +8,7 @@ import { MoreThan, Not, IsNull } from 'typeorm';
const logger = queueLogger.createSubLogger('clean-remote-files');
export default async function cleanRemoteFiles(job: Bull.Job<Record<string, unknown>>, done: any): Promise<void> {
logger.info(`Deleting cached remote files...`);
logger.info('Deleting cached remote files...');
let deletedCount = 0;
let cursor: any = null;
@ -45,6 +45,6 @@ export default async function cleanRemoteFiles(job: Bull.Job<Record<string, unkn
job.progress(deletedCount / total);
}
logger.succ(`All cahced remote files has been deleted.`);
logger.succ('All cahced remote files has been deleted.');
done();
}

View file

@ -7,7 +7,7 @@ import { publishUserEvent } from '@/services/stream.js';
const logger = queueLogger.createSubLogger('check-expired-mutings');
export async function checkExpiredMutings(job: Bull.Job<Record<string, unknown>>, done: any): Promise<void> {
logger.info(`Checking expired mutings...`);
logger.info('Checking expired mutings...');
const expired = await Mutings.createQueryBuilder('muting')
.where('muting.expiresAt IS NOT NULL')
@ -25,6 +25,6 @@ export async function checkExpiredMutings(job: Bull.Job<Record<string, unknown>>
}
}
logger.succ(`All expired mutings checked.`);
logger.succ('All expired mutings checked.');
done();
}

View file

@ -6,7 +6,7 @@ import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceCh
const logger = queueLogger.createSubLogger('clean-charts');
export async function cleanCharts(job: Bull.Job<Record<string, unknown>>, done: any): Promise<void> {
logger.info(`Clean charts...`);
logger.info('Clean charts...');
await Promise.all([
federationChart.clean(),
@ -23,6 +23,6 @@ export async function cleanCharts(job: Bull.Job<Record<string, unknown>>, done:
apRequestChart.clean(),
]);
logger.succ(`All charts successfully cleaned.`);
logger.succ('All charts successfully cleaned.');
done();
}

View file

@ -6,7 +6,7 @@ import { driveChart, notesChart, usersChart } from '@/services/chart/index.js';
const logger = queueLogger.createSubLogger('resync-charts');
export async function resyncCharts(job: Bull.Job<Record<string, unknown>>, done: any): Promise<void> {
logger.info(`Resync charts...`);
logger.info('Resync charts...');
// TODO: ユーザーごとのチャートも更新する
// TODO: インスタンスごとのチャートも更新する
@ -16,6 +16,6 @@ export async function resyncCharts(job: Bull.Job<Record<string, unknown>>, done:
usersChart.resync(),
]);
logger.succ(`All charts successfully resynced.`);
logger.succ('All charts successfully resynced.');
done();
}

View file

@ -6,7 +6,7 @@ import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceCh
const logger = queueLogger.createSubLogger('tick-charts');
export async function tickCharts(job: Bull.Job<Record<string, unknown>>, done: any): Promise<void> {
logger.info(`Tick charts...`);
logger.info('Tick charts...');
await Promise.all([
federationChart.tick(false),
@ -23,6 +23,6 @@ export async function tickCharts(job: Bull.Job<Record<string, unknown>>, done: a
apRequestChart.tick(false),
]);
logger.succ(`All charts successfully ticked.`);
logger.succ('All charts successfully ticked.');
done();
}

View file

@ -11,11 +11,11 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise<st
const follower = await dbResolver.getUserFromApId(activity.actor);
if (follower == null) {
return `skip: follower not found`;
return 'skip: follower not found';
}
if (follower.host != null) {
return `skip: follower is not a local user`;
return 'skip: follower is not a local user';
}
// relay
@ -25,5 +25,5 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise<st
}
await accept(actor, follower);
return `ok`;
return 'ok';
};

View file

@ -11,13 +11,13 @@ export default async (actor: CacheableRemoteUser, activity: IBlock): Promise<str
const blockee = await dbResolver.getUserFromApId(activity.object);
if (blockee == null) {
return `skip: blockee not found`;
return 'skip: blockee not found';
}
if (blockee.host != null) {
return `skip: ブロックしようとしているユーザーはローカルユーザーではありません`;
return 'skip: ブロックしようとしているユーザーはローカルユーザーではありません';
}
await block(await Users.findOneByOrFail({ id: actor.id }), await Users.findOneByOrFail({ id: blockee.id }));
return `ok`;
return 'ok';
};

View file

@ -14,12 +14,12 @@ export default async function(resolver: Resolver, actor: CacheableRemoteUser, no
if (typeof note === 'object') {
if (actor.uri !== note.attributedTo) {
return `skip: actor.uri !== note.attributedTo`;
return 'skip: actor.uri !== note.attributedTo';
}
if (typeof note.id === 'string') {
if (extractDbHost(actor.uri) !== extractDbHost(note.id)) {
return `skip: host in actor.uri !== note.id`;
return 'skip: host in actor.uri !== note.id';
}
}
}

View file

@ -14,7 +14,7 @@ export async function deleteActor(actor: CacheableRemoteUser, uri: string): Prom
const user = await Users.findOneByOrFail({ id: actor.id });
if (user.isDeleted) {
logger.info(`skip: already deleted`);
logger.info('skip: already deleted');
}
const job = await createDeleteAccountJob(actor);

View file

@ -14,7 +14,7 @@ export default async (actor: CacheableRemoteUser, activity: IFlag): Promise<stri
const users = await Users.findBy({
id: In(userIds),
});
if (users.length < 1) return `skip`;
if (users.length < 1) return 'skip';
await AbuseUserReports.insert({
id: genId(),
@ -27,5 +27,5 @@ export default async (actor: CacheableRemoteUser, activity: IFlag): Promise<stri
urls: uris.filter(uri => !uri.startsWith(config.url + '/users/')),
});
return `ok`;
return 'ok';
};

View file

@ -8,13 +8,13 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise<st
const followee = await dbResolver.getUserFromApId(activity.object);
if (followee == null) {
return `skip: followee not found`;
return 'skip: followee not found';
}
if (followee.host != null) {
return `skip: フォローしようとしているユーザーはローカルユーザーではありません`;
return 'skip: フォローしようとしているユーザーはローカルユーザーではありません';
}
await follow(actor, followee, activity.id);
return `ok`;
return 'ok';
};

View file

@ -15,11 +15,11 @@ export const performReadActivity = async (actor: CacheableRemoteUser, activity:
const message = await MessagingMessages.findOneBy({ id: messageId });
if (message == null) {
return `skip: message not found`;
return 'skip: message not found';
}
if (actor.id !== message.recipientId) {
return `skip: actor is not a message recipient`;
return 'skip: actor is not a message recipient';
}
await readUserMessagingMessage(message.recipientId!, message.userId, [message.id]);

View file

@ -12,11 +12,11 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise<st
const follower = await dbResolver.getUserFromApId(activity.actor);
if (follower == null) {
return `skip: follower not found`;
return 'skip: follower not found';
}
if (!Users.isLocalUser(follower)) {
return `skip: follower is not a local user`;
return 'skip: follower is not a local user';
}
// relay
@ -26,5 +26,5 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise<st
}
await remoteReject(actor, follower);
return `ok`;
return 'ok';
};

View file

@ -9,7 +9,7 @@ export default async (actor: CacheableRemoteUser, activity: IAccept): Promise<st
const follower = await dbResolver.getUserFromApId(activity.object);
if (follower == null) {
return `skip: follower not found`;
return 'skip: follower not found';
}
const following = await Followings.findOneBy({
@ -19,8 +19,8 @@ export default async (actor: CacheableRemoteUser, activity: IAccept): Promise<st
if (following) {
await unfollow(follower, actor);
return `ok: unfollowed`;
return 'ok: unfollowed';
}
return `skip: フォローされていない`;
return 'skip: フォローされていない';
};

View file

@ -9,13 +9,13 @@ export default async (actor: CacheableRemoteUser, activity: IBlock): Promise<str
const blockee = await dbResolver.getUserFromApId(activity.object);
if (blockee == null) {
return `skip: blockee not found`;
return 'skip: blockee not found';
}
if (blockee.host != null) {
return `skip: ブロック解除しようとしているユーザーはローカルユーザーではありません`;
return 'skip: ブロック解除しようとしているユーザーはローカルユーザーではありません';
}
await unblock(await Users.findOneByOrFail({ id: actor.id }), blockee);
return `ok`;
return 'ok';
};

View file

@ -10,11 +10,11 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise<st
const followee = await dbResolver.getUserFromApId(activity.object);
if (followee == null) {
return `skip: followee not found`;
return 'skip: followee not found';
}
if (followee.host != null) {
return `skip: フォロー解除しようとしているユーザーはローカルユーザーではありません`;
return 'skip: フォロー解除しようとしているユーザーはローカルユーザーではありません';
}
const req = await FollowRequests.findOneBy({
@ -29,13 +29,13 @@ export default async (actor: CacheableRemoteUser, activity: IFollow): Promise<st
if (req) {
await cancelRequest(followee, actor);
return `ok: follow request canceled`;
return 'ok: follow request canceled';
}
if (following) {
await unfollow(actor, followee);
return `ok: unfollowed`;
return 'ok: unfollowed';
}
return `skip: リクエストもフォローもされていない`;
return 'skip: リクエストもフォローもされていない';
};

View file

@ -17,5 +17,5 @@ export default async (actor: CacheableRemoteUser, activity: ILike) => {
throw e;
});
return `ok`;
return 'ok';
};

View file

@ -10,7 +10,7 @@ import { updatePerson } from '../../models/person.js';
*/
export default async (actor: CacheableRemoteUser, activity: IUpdate): Promise<string> => {
if ('actor' in activity && actor.uri !== activity.actor) {
return `skip: invalid actor`;
return 'skip: invalid actor';
}
apLogger.debug('Update');
@ -24,10 +24,10 @@ export default async (actor: CacheableRemoteUser, activity: IUpdate): Promise<st
if (isActor(object)) {
await updatePerson(actor.uri!, resolver, object);
return `ok: Person updated`;
return 'ok: Person updated';
} else if (getApType(object) === 'Question') {
await updateQuestion(object).catch(e => console.log(e));
return `ok: Question updated`;
return 'ok: Question updated';
} else {
return `skip: Unknown type: ${getApType(object)}`;
}

View file

@ -131,7 +131,7 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
const reply: Note | null = note.inReplyTo
? await resolveNote(note.inReplyTo, resolver).then(x => {
if (x == null) {
logger.warn(`Specified inReplyTo, but nout found`);
logger.warn('Specified inReplyTo, but nout found');
throw new Error('inReplyTo not found');
} else {
return x;

View file

@ -139,7 +139,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
_misskey_content: text,
source: {
content: text,
mediaType: "text/x.misskeymarkdown",
mediaType: 'text/x.misskeymarkdown',
},
_misskey_quote: quote,
quoteUrl: quote,

View file

@ -72,7 +72,7 @@ export async function renderPerson(user: ILocalUser) {
tag,
manuallyApprovesFollowers: user.isLocked,
discoverable: !!user.isExplorable,
publicKey: renderKey(user, keypair, `#main-key`),
publicKey: renderKey(user, keypair, '#main-key'),
isCat: user.isCat,
attachment: attachment.length ? attachment : undefined,
} as any;

View file

@ -67,7 +67,7 @@ export async function resolveUser(username: string, host: string | null): Promis
// validate uri
const uri = new URL(self.href);
if (uri.hostname !== host) {
throw new Error(`Invalid uri`);
throw new Error('Invalid uri');
}
await Users.update({

View file

@ -14,11 +14,11 @@ export function generateBlockedUserQuery(q: SelectQueryBuilder<any>, me: { id: U
q
.andWhere(`note.userId NOT IN (${ blockingQuery.getQuery() })`)
.andWhere(new Brackets(qb => { qb
.where(`note.replyUserId IS NULL`)
.where('note.replyUserId IS NULL')
.orWhere(`note.replyUserId NOT IN (${ blockingQuery.getQuery() })`);
}))
.andWhere(new Brackets(qb => { qb
.where(`note.renoteUserId IS NULL`)
.where('note.renoteUserId IS NULL')
.orWhere(`note.renoteUserId NOT IN (${ blockingQuery.getQuery() })`);
}));

View file

@ -9,7 +9,7 @@ export function generateMutedNoteThreadQuery(q: SelectQueryBuilder<any>, me: { i
q.andWhere(`note.id NOT IN (${ mutedQuery.getQuery() })`);
q.andWhere(new Brackets(qb => { qb
.where(`note.threadId IS NULL`)
.where('note.threadId IS NULL')
.orWhere(`note.threadId NOT IN (${ mutedQuery.getQuery() })`);
}));

View file

@ -4,22 +4,22 @@ import { Brackets, SelectQueryBuilder } from 'typeorm';
export function generateRepliesQuery(q: SelectQueryBuilder<any>, me?: Pick<User, 'id' | 'showTimelineReplies'> | null) {
if (me == null) {
q.andWhere(new Brackets(qb => { qb
.where(`note.replyId IS NULL`) // 返信ではない
.where('note.replyId IS NULL') // 返信ではない
.orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信
.where(`note.replyId IS NOT NULL`)
.where('note.replyId IS NOT NULL')
.andWhere('note.replyUserId = note.userId');
}));
}));
} else if (!me.showTimelineReplies) {
q.andWhere(new Brackets(qb => { qb
.where(`note.replyId IS NULL`) // 返信ではない
.where('note.replyId IS NULL') // 返信ではない
.orWhere('note.replyUserId = :meId', { meId: me.id }) // 返信だけど自分のノートへの返信
.orWhere(new Brackets(qb => { qb // 返信だけど自分の行った返信
.where(`note.replyId IS NOT NULL`)
.where('note.replyId IS NOT NULL')
.andWhere('note.userId = :meId', { meId: me.id });
}))
.orWhere(new Brackets(qb => { qb // 返信だけど投稿者自身への返信
.where(`note.replyId IS NOT NULL`)
.where('note.replyId IS NOT NULL')
.andWhere('note.replyUserId = note.userId');
}));
}));

View file

@ -6,8 +6,8 @@ export function generateVisibilityQuery(q: SelectQueryBuilder<any>, me?: { id: U
// This code must always be synchronized with the checks in Notes.isVisibleForMe.
if (me == null) {
q.andWhere(new Brackets(qb => { qb
.where(`note.visibility = 'public'`)
.orWhere(`note.visibility = 'home'`);
.where("note.visibility = 'public'")
.orWhere("note.visibility = 'home'");
}));
} else {
const followingQuery = Followings.createQueryBuilder('following')
@ -17,8 +17,8 @@ export function generateVisibilityQuery(q: SelectQueryBuilder<any>, me?: { id: U
q.andWhere(new Brackets(qb => { qb
// 公開投稿である
.where(new Brackets(qb => { qb
.where(`note.visibility = 'public'`)
.orWhere(`note.visibility = 'home'`);
.where("note.visibility = 'public'")
.orWhere("note.visibility = 'home'");
}))
// または 自分自身
.orWhere('note.userId = :meId')
@ -27,7 +27,7 @@ export function generateVisibilityQuery(q: SelectQueryBuilder<any>, me?: { id: U
.orWhere(':meId = ANY(note.mentions)')
.orWhere(new Brackets(qb => { qb
// または フォロワー宛ての投稿であり、
.where(`note.visibility = 'followers'`)
.where("note.visibility = 'followers'")
.andWhere(new Brackets(qb => { qb
// 自分がフォロワーである
.where(`note.userId IN (${ followingQuery.getQuery() })`)

View file

@ -9,7 +9,7 @@ import { generateVisibilityQuery } from './generate-visibility-query.js';
*/
export async function getNote(noteId: Note['id'], me: { id: User['id'] } | null) {
const query = Notes.createQueryBuilder('note')
.where("note.id = :id", {
.where('note.id = :id', {
id: noteId,
});

View file

@ -21,9 +21,9 @@ export async function injectFeatured(timeline: Note[], user?: User | null) {
const query = Notes.createQueryBuilder('note')
.addSelect('note.score')
.where('note.userHost IS NULL')
.andWhere(`note.score > 0`)
.andWhere(`note.createdAt > :date`, { date: new Date(Date.now() - day) })
.andWhere(`note.visibility = 'public'`)
.andWhere('note.score > 0')
.andWhere('note.createdAt > :date', { date: new Date(Date.now() - day) })
.andWhere("note.visibility = 'public'")
.innerJoinAndSelect('note.user', 'user');
if (user) {

View file

@ -124,7 +124,7 @@ export async function readGroupMessagingMessage(
} else {
// そのグループにおいて未読がなければイベント発行
const unreadExist = await MessagingMessages.createQueryBuilder('message')
.where(`message.groupId = :groupId`, { groupId: groupId })
.where('message.groupId = :groupId', { groupId: groupId })
.andWhere('message.userId != :userId', { userId: userId })
.andWhere('NOT (:userId = ANY(message.reads))', { userId: userId })
.andWhere('message.createdAt > :joinedAt', { joinedAt: joining.createdAt }) // 自分が加入する前の会話については、未読扱いしない

View file

@ -82,8 +82,8 @@ export const paramDef = {
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
state: { type: 'string', nullable: true, default: null },
reporterOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "combined" },
targetUserOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "combined" },
reporterOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' },
targetUserOrigin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'combined' },
},
required: [],
} as const;

View file

@ -73,9 +73,9 @@ export default define(meta, paramDef, async (ps) => {
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId);
if (ps.host == null) {
q.andWhere(`emoji.host IS NOT NULL`);
q.andWhere('emoji.host IS NOT NULL');
} else {
q.andWhere(`emoji.host = :host`, { host: toPuny(ps.host) });
q.andWhere('emoji.host = :host', { host: toPuny(ps.host) });
}
if (ps.query) {

View file

@ -65,7 +65,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps) => {
const q = makePaginationQuery(Emojis.createQueryBuilder('emoji'), ps.sinceId, ps.untilId)
.andWhere(`emoji.host IS NULL`);
.andWhere('emoji.host IS NULL');
let emojis: Emoji[];

View file

@ -16,7 +16,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async () => {
const stats = await db.query(`SELECT * FROM pg_indexes;`).then(recs => {
const stats = await db.query('SELECT * FROM pg_indexes;').then(recs => {
const res = [] as { tablename: string; indexname: string; }[];
for (const rec of recs) {
res.push(rec);

View file

@ -33,7 +33,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, me) => {
const query = makePaginationQuery(Blockings.createQueryBuilder('blocking'), ps.sinceId, ps.untilId)
.andWhere(`blocking.blockerId = :meId`, { meId: me.id });
.andWhere('blocking.blockerId = :meId', { meId: me.id });
const blockings = await query
.take(ps.limit)

View file

@ -29,7 +29,7 @@ export const meta = {
export const paramDef = {
type: 'object',
properties: {
name: { type: 'string', default: "Untitled", maxLength: 200 },
name: { type: 'string', default: 'Untitled', maxLength: 200 },
parentId: { type: 'string', format: 'misskey:id', nullable: true },
},
required: [],

View file

@ -32,7 +32,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, me) => {
const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId)
.andWhere(`following.followeeHost = :host`, { host: ps.host });
.andWhere('following.followeeHost = :host', { host: ps.host });
const followings = await query
.take(ps.limit)

View file

@ -32,7 +32,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, me) => {
const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId)
.andWhere(`following.followerHost = :host`, { host: ps.host });
.andWhere('following.followerHost = :host', { host: ps.host });
const followings = await query
.take(ps.limit)

View file

@ -32,7 +32,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, me) => {
const query = makePaginationQuery(Users.createQueryBuilder('user'), ps.sinceId, ps.untilId)
.andWhere(`user.host = :host`, { host: ps.host });
.andWhere('user.host = :host', { host: ps.host });
const users = await query
.take(ps.limit)

View file

@ -68,12 +68,12 @@ export default define(meta, paramDef, async () => {
now.setMinutes(Math.round(now.getMinutes() / 5) * 5, 0, 0);
const tagNotes = await Notes.createQueryBuilder('note')
.where(`note.createdAt > :date`, { date: new Date(now.getTime() - rangeA) })
.where('note.createdAt > :date', { date: new Date(now.getTime() - rangeA) })
.andWhere(new Brackets(qb => { qb
.where(`note.visibility = 'public'`)
.orWhere(`note.visibility = 'home'`);
.where("note.visibility = 'public'")
.orWhere("note.visibility = 'home'");
}))
.andWhere(`note.tags != '{}'`)
.andWhere("note.tags != '{}'")
.select(['note.tags', 'note.userId'])
.cache(60000) // 1 min
.getMany();

View file

@ -24,8 +24,8 @@ export const paramDef = {
tag: { type: 'string' },
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt'] },
state: { type: 'string', enum: ['all', 'alive'], default: "all" },
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "local" },
state: { type: 'string', enum: ['all', 'alive'], default: 'all' },
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'local' },
},
required: ['tag', 'sort'],
} as const;

View file

@ -12,7 +12,7 @@ export const paramDef = {
properties: {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
offset: { type: 'integer', default: 0 },
sort: { type: 'string', enum: ['desc', 'asc'], default: "desc" },
sort: { type: 'string', enum: ['desc', 'asc'], default: 'desc' },
},
required: [],
} as const;

View file

@ -33,7 +33,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(NoteFavorites.createQueryBuilder('favorite'), ps.sinceId, ps.untilId)
.andWhere(`favorite.userId = :meId`, { meId: user.id })
.andWhere('favorite.userId = :meId', { meId: user.id })
.leftJoinAndSelect('favorite.note', 'note');
const favorites = await query

View file

@ -44,7 +44,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(GalleryLikes.createQueryBuilder('like'), ps.sinceId, ps.untilId)
.andWhere(`like.userId = :meId`, { meId: user.id })
.andWhere('like.userId = :meId', { meId: user.id })
.leftJoinAndSelect('like.post', 'post');
const likes = await query

View file

@ -33,7 +33,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId)
.andWhere(`post.userId = :meId`, { meId: user.id });
.andWhere('post.userId = :meId', { meId: user.id });
const posts = await query
.take(ps.limit)

View file

@ -43,7 +43,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(PageLikes.createQueryBuilder('like'), ps.sinceId, ps.untilId)
.andWhere(`like.userId = :meId`, { meId: user.id })
.andWhere('like.userId = :meId', { meId: user.id })
.leftJoinAndSelect('like.page', 'page');
const likes = await query

View file

@ -33,7 +33,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId)
.andWhere(`page.userId = :meId`, { meId: user.id });
.andWhere('page.userId = :meId', { meId: user.id });
const pages = await query
.take(ps.limit)

View file

@ -32,7 +32,7 @@ export default define(meta, paramDef, async (ps, user) => {
.set({
reads: (() => `array_append("reads", '${user.id}')`) as any,
})
.where(`groupId = :groupId`, { groupId: j.userGroupId })
.where('groupId = :groupId', { groupId: j.userGroupId })
.andWhere('userId != :userId', { userId: user.id })
.andWhere('NOT (:userId = ANY(reads))', { userId: user.id })
.execute()));

View file

@ -21,7 +21,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(Signins.createQueryBuilder('signin'), ps.sinceId, ps.untilId)
.andWhere(`signin.userId = :meId`, { meId: user.id });
.andWhere('signin.userId = :meId', { meId: user.id });
const history = await query.take(ps.limit).getMany();

View file

@ -44,7 +44,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(UserGroupInvitations.createQueryBuilder('invitation'), ps.sinceId, ps.untilId)
.andWhere(`invitation.userId = :meId`, { meId: user.id })
.andWhere('invitation.userId = :meId', { meId: user.id })
.leftJoinAndSelect('invitation.userGroup', 'user_group');
const invitations = await query

View file

@ -55,26 +55,26 @@ export default define(meta, paramDef, async (ps, user) => {
.orderBy('message.createdAt', 'DESC');
if (ps.group) {
query.where(`message.groupId IN (:...groups)`, { groups: groups });
query.where('message.groupId IN (:...groups)', { groups: groups });
if (found.length > 0) {
query.andWhere(`message.groupId NOT IN (:...found)`, { found: found });
query.andWhere('message.groupId NOT IN (:...found)', { found: found });
}
} else {
query.where(new Brackets(qb => { qb
.where(`message.userId = :userId`, { userId: user.id })
.orWhere(`message.recipientId = :userId`, { userId: user.id });
.where('message.userId = :userId', { userId: user.id })
.orWhere('message.recipientId = :userId', { userId: user.id });
}));
query.andWhere(`message.groupId IS NULL`);
query.andWhere('message.groupId IS NULL');
if (found.length > 0) {
query.andWhere(`message.userId NOT IN (:...found)`, { found: found });
query.andWhere(`message.recipientId NOT IN (:...found)`, { found: found });
query.andWhere('message.userId NOT IN (:...found)', { found: found });
query.andWhere('message.recipientId NOT IN (:...found)', { found: found });
}
if (mute.length > 0) {
query.andWhere(`message.userId NOT IN (:...mute)`, { mute: mute.map(m => m.muteeId) });
query.andWhere(`message.recipientId NOT IN (:...mute)`, { mute: mute.map(m => m.muteeId) });
query.andWhere('message.userId NOT IN (:...mute)', { mute: mute.map(m => m.muteeId) });
query.andWhere('message.recipientId NOT IN (:...mute)', { mute: mute.map(m => m.muteeId) });
}
}

View file

@ -125,7 +125,7 @@ export default define(meta, paramDef, async (ps, user) => {
}
const query = makePaginationQuery(MessagingMessages.createQueryBuilder('message'), ps.sinceId, ps.untilId)
.andWhere(`message.groupId = :groupId`, { groupId: recipientGroup.id });
.andWhere('message.groupId = :groupId', { groupId: recipientGroup.id });
const messages = await query.take(ps.limit).getMany();

View file

@ -33,7 +33,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, me) => {
const query = makePaginationQuery(Mutings.createQueryBuilder('muting'), ps.sinceId, ps.untilId)
.andWhere(`muting.muterId = :meId`, { meId: me.id });
.andWhere('muting.muterId = :meId', { meId: me.id });
const mutings = await query
.take(ps.limit)

View file

@ -32,7 +32,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(GalleryPosts.createQueryBuilder('post'), ps.sinceId, ps.untilId)
.andWhere(`post.userId = :userId`, { userId: ps.userId });
.andWhere('post.userId = :userId', { userId: ps.userId });
const posts = await query
.take(ps.limit)

View file

@ -17,7 +17,7 @@ const _dirname = dirname(_filename);
const app = new Koa();
app.use(cors());
app.use(async (ctx, next) => {
ctx.set('Content-Security-Policy', `default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'`);
ctx.set('Content-Security-Policy', "default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'");
await next();
});

View file

@ -11,7 +11,7 @@ import { proxyMedia } from './proxy-media.js';
const app = new Koa();
app.use(cors());
app.use(async (ctx, next) => {
ctx.set('Content-Security-Policy', `default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'`);
ctx.set('Content-Security-Policy', "default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'");
await next();
});

View file

@ -185,8 +185,8 @@ router.get('/twemoji-badge/(.*)', async ctx => {
});
// ServiceWorker
router.get(`/sw.js`, async ctx => {
await send(ctx as any, `/sw.js`, {
router.get('/sw.js', async ctx => {
await send(ctx as any, '/sw.js', {
root: swAssets,
maxage: 10 * MINUTE,
});

View file

@ -40,21 +40,21 @@ export default class FederationChart extends Chart<typeof schema> {
Followings.createQueryBuilder('following')
.select('COUNT(DISTINCT following.followeeHost)')
.where('following.followeeHost IS NOT NULL')
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : `following.followeeHost NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'following.followeeHost NOT IN (:...blocked)', { blocked: meta.blockedHosts })
.andWhere(`following.followeeHost NOT IN (${ suspendedInstancesQuery.getQuery() })`)
.getRawOne()
.then(x => parseInt(x.count, 10)),
Followings.createQueryBuilder('following')
.select('COUNT(DISTINCT following.followerHost)')
.where('following.followerHost IS NOT NULL')
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : `following.followerHost NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'following.followerHost NOT IN (:...blocked)', { blocked: meta.blockedHosts })
.andWhere(`following.followerHost NOT IN (${ suspendedInstancesQuery.getQuery() })`)
.getRawOne()
.then(x => parseInt(x.count, 10)),
Followings.createQueryBuilder('following')
.select('COUNT(DISTINCT following.followeeHost)')
.where('following.followeeHost IS NOT NULL')
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : `following.followeeHost NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'following.followeeHost NOT IN (:...blocked)', { blocked: meta.blockedHosts })
.andWhere(`following.followeeHost NOT IN (${ suspendedInstancesQuery.getQuery() })`)
.andWhere(`following.followeeHost IN (${ pubsubSubQuery.getQuery() })`)
.setParameters(pubsubSubQuery.getParameters())
@ -63,17 +63,17 @@ export default class FederationChart extends Chart<typeof schema> {
Instances.createQueryBuilder('instance')
.select('COUNT(instance.id)')
.where(`instance.host IN (${ subInstancesQuery.getQuery() })`)
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : `instance.host NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
.andWhere(`instance.isSuspended = false`)
.andWhere(`instance.lastCommunicatedAt > :gt`, { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) })
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'instance.host NOT IN (:...blocked)', { blocked: meta.blockedHosts })
.andWhere('instance.isSuspended = false')
.andWhere('instance.lastCommunicatedAt > :gt', { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) })
.getRawOne()
.then(x => parseInt(x.count, 10)),
Instances.createQueryBuilder('instance')
.select('COUNT(instance.id)')
.where(`instance.host IN (${ pubInstancesQuery.getQuery() })`)
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : `instance.host NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
.andWhere(`instance.isSuspended = false`)
.andWhere(`instance.lastCommunicatedAt > :gt`, { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) })
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'instance.host NOT IN (:...blocked)', { blocked: meta.blockedHosts })
.andWhere('instance.isSuspended = false')
.andWhere('instance.lastCommunicatedAt > :gt', { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) })
.getRawOne()
.then(x => parseInt(x.count, 10)),
]);

View file

@ -171,7 +171,7 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
}
if (!['image/jpeg', 'image/png', 'image/webp', 'image/svg+xml'].includes(type)) {
logger.debug(`web image and thumbnail not created (not an required file)`);
logger.debug('web image and thumbnail not created (not an required file)');
return {
webpublic: null,
thumbnail: null,
@ -212,7 +212,7 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
let webpublic: IImage | null = null;
if (generateWeb && !satisfyWebpublic) {
logger.info(`creating web image`);
logger.info('creating web image');
try {
if (['image/jpeg', 'image/webp'].includes(type)) {
@ -222,14 +222,14 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
} else if (['image/svg+xml'].includes(type)) {
webpublic = await convertSharpToPng(img, 2048, 2048);
} else {
logger.debug(`web image not created (not an required image)`);
logger.debug('web image not created (not an required image)');
}
} catch (err) {
logger.warn(`web image not created (an error occured)`, err as Error);
logger.warn('web image not created (an error occured)', err as Error);
}
} else {
if (satisfyWebpublic) logger.info(`web image not created (original satisfies webpublic)`);
else logger.info(`web image not created (from remote)`);
if (satisfyWebpublic) logger.info('web image not created (original satisfies webpublic)');
else logger.info('web image not created (from remote)');
}
// #endregion webpublic
@ -240,10 +240,10 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
if (['image/jpeg', 'image/webp', 'image/png', 'image/svg+xml'].includes(type)) {
thumbnail = await convertSharpToWebp(img, 498, 280);
} else {
logger.debug(`thumbnail not created (not an required file)`);
logger.debug('thumbnail not created (not an required file)');
}
} catch (err) {
logger.warn(`thumbnail not created (an error occured)`, err as Error);
logger.warn('thumbnail not created (an error occured)', err as Error);
}
// #endregion thumbnail

View file

@ -94,8 +94,8 @@ export async function insertFollowingDoc(followee: { id: User['id']; host: User[
Users.pack(followee.id, follower, {
detail: true,
}).then(async packed => {
publishUserEvent(follower.id, 'follow', packed as Packed<"UserDetailedNotMe">);
publishMainStream(follower.id, 'follow', packed as Packed<"UserDetailedNotMe">);
publishUserEvent(follower.id, 'follow', packed as Packed<'UserDetailedNotMe'>);
publishMainStream(follower.id, 'follow', packed as Packed<'UserDetailedNotMe'>);
const webhooks = (await getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('follow'));
for (const webhook of webhooks) {

View file

@ -39,44 +39,44 @@ export async function updateHashtag(user: { id: User['id']; host: User['host'];
// 自分が初めてこのタグを使ったなら
if (!index.attachedUserIds.some(id => id === user.id)) {
set.attachedUserIds = () => `array_append("attachedUserIds", '${user.id}')`;
set.attachedUsersCount = () => `"attachedUsersCount" + 1`;
set.attachedUsersCount = () => '"attachedUsersCount" + 1';
}
// 自分が(ローカル内で)初めてこのタグを使ったなら
if (Users.isLocalUser(user) && !index.attachedLocalUserIds.some(id => id === user.id)) {
set.attachedLocalUserIds = () => `array_append("attachedLocalUserIds", '${user.id}')`;
set.attachedLocalUsersCount = () => `"attachedLocalUsersCount" + 1`;
set.attachedLocalUsersCount = () => '"attachedLocalUsersCount" + 1';
}
// 自分が(リモートで)初めてこのタグを使ったなら
if (Users.isRemoteUser(user) && !index.attachedRemoteUserIds.some(id => id === user.id)) {
set.attachedRemoteUserIds = () => `array_append("attachedRemoteUserIds", '${user.id}')`;
set.attachedRemoteUsersCount = () => `"attachedRemoteUsersCount" + 1`;
set.attachedRemoteUsersCount = () => '"attachedRemoteUsersCount" + 1';
}
} else {
set.attachedUserIds = () => `array_remove("attachedUserIds", '${user.id}')`;
set.attachedUsersCount = () => `"attachedUsersCount" - 1`;
set.attachedUsersCount = () => '"attachedUsersCount" - 1';
if (Users.isLocalUser(user)) {
set.attachedLocalUserIds = () => `array_remove("attachedLocalUserIds", '${user.id}')`;
set.attachedLocalUsersCount = () => `"attachedLocalUsersCount" - 1`;
set.attachedLocalUsersCount = () => '"attachedLocalUsersCount" - 1';
} else {
set.attachedRemoteUserIds = () => `array_remove("attachedRemoteUserIds", '${user.id}')`;
set.attachedRemoteUsersCount = () => `"attachedRemoteUsersCount" - 1`;
set.attachedRemoteUsersCount = () => '"attachedRemoteUsersCount" - 1';
}
}
} else {
// 自分が初めてこのタグを使ったなら
if (!index.mentionedUserIds.some(id => id === user.id)) {
set.mentionedUserIds = () => `array_append("mentionedUserIds", '${user.id}')`;
set.mentionedUsersCount = () => `"mentionedUsersCount" + 1`;
set.mentionedUsersCount = () => '"mentionedUsersCount" + 1';
}
// 自分が(ローカル内で)初めてこのタグを使ったなら
if (Users.isLocalUser(user) && !index.mentionedLocalUserIds.some(id => id === user.id)) {
set.mentionedLocalUserIds = () => `array_append("mentionedLocalUserIds", '${user.id}')`;
set.mentionedLocalUsersCount = () => `"mentionedLocalUsersCount" + 1`;
set.mentionedLocalUsersCount = () => '"mentionedLocalUsersCount" + 1';
}
// 自分が(リモートで)初めてこのタグを使ったなら
if (Users.isRemoteUser(user) && !index.mentionedRemoteUserIds.some(id => id === user.id)) {
set.mentionedRemoteUserIds = () => `array_append("mentionedRemoteUserIds", '${user.id}')`;
set.mentionedRemoteUsersCount = () => `"mentionedRemoteUsersCount" + 1`;
set.mentionedRemoteUsersCount = () => '"mentionedRemoteUsersCount" + 1';
}
}

View file

@ -22,7 +22,7 @@ module.exports = {
'eol-last': ['error', 'always'],
'semi': ['error', 'always'],
'semi-spacing': ['error', { 'before': false, 'after': true }],
'quotes': ['warn', 'single'],
'quotes': ['error', 'single', { 'avoidEscape': true }],
'comma-dangle': ['warn', 'always-multiline'],
'keyword-spacing': ['error', {
'before': true,
@ -76,6 +76,7 @@ module.exports = {
'import/no-default-export': ['warn'],
'import/order': ['warn', {
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
}]
}],
'object-shorthand': ['warn', 'consistent-as-needed'],
},
};