lint fixes

This commit is contained in:
syuilo 2023-10-09 13:32:41 +09:00
parent a2d3544a08
commit 4f20c87186
16 changed files with 124 additions and 92 deletions

View File

@ -76,13 +76,15 @@ export class QueryService {
// 投稿の引用元の作者にブロックされていない // 投稿の引用元の作者にブロックされていない
q q
.andWhere(`note.userId NOT IN (${ blockingQuery.getQuery() })`) .andWhere(`note.userId NOT IN (${ blockingQuery.getQuery() })`)
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('note.replyUserId IS NULL') qb
.orWhere(`note.replyUserId NOT IN (${ blockingQuery.getQuery() })`); .where('note.replyUserId IS NULL')
.orWhere(`note.replyUserId NOT IN (${ blockingQuery.getQuery() })`);
})) }))
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('note.renoteUserId IS NULL') qb
.orWhere(`note.renoteUserId NOT IN (${ blockingQuery.getQuery() })`); .where('note.renoteUserId IS NULL')
.orWhere(`note.renoteUserId NOT IN (${ blockingQuery.getQuery() })`);
})); }));
q.setParameters(blockingQuery.getParameters()); q.setParameters(blockingQuery.getParameters());
@ -112,9 +114,10 @@ export class QueryService {
.where('threadMuted.userId = :userId', { userId: me.id }); .where('threadMuted.userId = :userId', { userId: me.id });
q.andWhere(`note.id NOT IN (${ mutedQuery.getQuery() })`); q.andWhere(`note.id NOT IN (${ mutedQuery.getQuery() })`);
q.andWhere(new Brackets(qb => { qb q.andWhere(new Brackets(qb => {
.where('note.threadId IS NULL') qb
.orWhere(`note.threadId NOT IN (${ mutedQuery.getQuery() })`); .where('note.threadId IS NULL')
.orWhere(`note.threadId NOT IN (${ mutedQuery.getQuery() })`);
})); }));
q.setParameters(mutedQuery.getParameters()); q.setParameters(mutedQuery.getParameters());
@ -139,26 +142,31 @@ export class QueryService {
// 投稿の引用元の作者をミュートしていない // 投稿の引用元の作者をミュートしていない
q q
.andWhere(`note.userId NOT IN (${ mutingQuery.getQuery() })`) .andWhere(`note.userId NOT IN (${ mutingQuery.getQuery() })`)
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('note.replyUserId IS NULL') qb
.orWhere(`note.replyUserId NOT IN (${ mutingQuery.getQuery() })`); .where('note.replyUserId IS NULL')
.orWhere(`note.replyUserId NOT IN (${ mutingQuery.getQuery() })`);
})) }))
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('note.renoteUserId IS NULL') qb
.orWhere(`note.renoteUserId NOT IN (${ mutingQuery.getQuery() })`); .where('note.renoteUserId IS NULL')
.orWhere(`note.renoteUserId NOT IN (${ mutingQuery.getQuery() })`);
})) }))
// mute instances // mute instances
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.andWhere('note.userHost IS NULL') qb
.orWhere(`NOT ((${ mutingInstanceQuery.getQuery() })::jsonb ? note.userHost)`); .andWhere('note.userHost IS NULL')
.orWhere(`NOT ((${ mutingInstanceQuery.getQuery() })::jsonb ? note.userHost)`);
})) }))
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('note.replyUserHost IS NULL') qb
.orWhere(`NOT ((${ mutingInstanceQuery.getQuery() })::jsonb ? note.replyUserHost)`); .where('note.replyUserHost IS NULL')
.orWhere(`NOT ((${ mutingInstanceQuery.getQuery() })::jsonb ? note.replyUserHost)`);
})) }))
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('note.renoteUserHost IS NULL') qb
.orWhere(`NOT ((${ mutingInstanceQuery.getQuery() })::jsonb ? note.renoteUserHost)`); .where('note.renoteUserHost IS NULL')
.orWhere(`NOT ((${ mutingInstanceQuery.getQuery() })::jsonb ? note.renoteUserHost)`);
})); }));
q.setParameters(mutingQuery.getParameters()); q.setParameters(mutingQuery.getParameters());
@ -180,36 +188,41 @@ export class QueryService {
public generateVisibilityQuery(q: SelectQueryBuilder<any>, me?: { id: MiUser['id'] } | null): void { public generateVisibilityQuery(q: SelectQueryBuilder<any>, me?: { id: MiUser['id'] } | null): void {
// This code must always be synchronized with the checks in Notes.isVisibleForMe. // This code must always be synchronized with the checks in Notes.isVisibleForMe.
if (me == null) { if (me == null) {
q.andWhere(new Brackets(qb => { qb q.andWhere(new Brackets(qb => {
.where('note.visibility = \'public\'') qb
.orWhere('note.visibility = \'home\''); .where('note.visibility = \'public\'')
.orWhere('note.visibility = \'home\'');
})); }));
} else { } else {
const followingQuery = this.followingsRepository.createQueryBuilder('following') const followingQuery = this.followingsRepository.createQueryBuilder('following')
.select('following.followeeId') .select('following.followeeId')
.where('following.followerId = :meId'); .where('following.followerId = :meId');
q.andWhere(new Brackets(qb => { qb q.andWhere(new Brackets(qb => {
qb
// 公開投稿である // 公開投稿である
.where(new Brackets(qb => { qb .where(new Brackets(qb => {
.where('note.visibility = \'public\'') qb
.orWhere('note.visibility = \'home\''); .where('note.visibility = \'public\'')
})) .orWhere('note.visibility = \'home\'');
}))
// または 自分自身 // または 自分自身
.orWhere('note.userId = :meId') .orWhere('note.userId = :meId')
// または 自分宛て // または 自分宛て
.orWhere(':meId = ANY(note.visibleUserIds)') .orWhere(':meId = ANY(note.visibleUserIds)')
.orWhere(':meId = ANY(note.mentions)') .orWhere(':meId = ANY(note.mentions)')
.orWhere(new Brackets(qb => { qb .orWhere(new Brackets(qb => {
// または フォロワー宛ての投稿であり、 qb
.where('note.visibility = \'followers\'') // または フォロワー宛ての投稿であり、
.andWhere(new Brackets(qb => { qb .where('note.visibility = \'followers\'')
// 自分がフォロワーである .andWhere(new Brackets(qb => {
.where(`note.userId IN (${ followingQuery.getQuery() })`) qb
// または 自分の投稿へのリプライ // 自分がフォロワーである
.orWhere('note.replyUserId = :meId'); .where(`note.userId IN (${ followingQuery.getQuery() })`)
// または 自分の投稿へのリプライ
.orWhere('note.replyUserId = :meId');
}));
})); }));
}));
})); }));
q.setParameters({ meId: me.id }); q.setParameters({ meId: me.id });

View File

@ -33,9 +33,10 @@ export class RoleEntityService {
const assignedCount = await this.roleAssignmentsRepository.createQueryBuilder('assign') const assignedCount = await this.roleAssignmentsRepository.createQueryBuilder('assign')
.where('assign.roleId = :roleId', { roleId: role.id }) .where('assign.roleId = :roleId', { roleId: role.id })
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('assign.expiresAt IS NULL') qb
.orWhere('assign.expiresAt > :now', { now: new Date() }); .where('assign.expiresAt IS NULL')
.orWhere('assign.expiresAt > :now', { now: new Date() });
})) }))
.getCount(); .getCount();

View File

@ -379,9 +379,10 @@ export class ActivityPubServerService {
if (page) { if (page) {
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), sinceId, untilId) const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), sinceId, untilId)
.andWhere('note.userId = :userId', { userId: user.id }) .andWhere('note.userId = :userId', { userId: user.id })
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('note.visibility = \'public\'') qb
.orWhere('note.visibility = \'home\''); .where('note.visibility = \'public\'')
.orWhere('note.visibility = \'home\'');
})) }))
.andWhere('note.localOnly = FALSE'); .andWhere('note.localOnly = FALSE');

View File

@ -61,9 +61,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const query = this.queryService.makePaginationQuery(this.roleAssignmentsRepository.createQueryBuilder('assign'), ps.sinceId, ps.untilId) const query = this.queryService.makePaginationQuery(this.roleAssignmentsRepository.createQueryBuilder('assign'), ps.sinceId, ps.untilId)
.andWhere('assign.roleId = :roleId', { roleId: role.id }) .andWhere('assign.roleId = :roleId', { roleId: role.id })
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('assign.expiresAt IS NULL') qb
.orWhere('assign.expiresAt > :now', { now: new Date() }); .where('assign.expiresAt IS NULL')
.orWhere('assign.expiresAt > :now', { now: new Date() });
})) }))
.innerJoinAndSelect('assign.user', 'user'); .innerJoinAndSelect('assign.user', 'user');

View File

@ -55,9 +55,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (ps.query !== '') { if (ps.query !== '') {
if (ps.type === 'nameAndDescription') { if (ps.type === 'nameAndDescription') {
query.andWhere(new Brackets(qb => { qb query.andWhere(new Brackets(qb => {
.where('channel.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` }) qb
.orWhere('channel.description ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` }); .where('channel.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` })
.orWhere('channel.description ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` });
})); }));
} else { } else {
query.andWhere('channel.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` }); query.andWhere('channel.name ILIKE :q', { q: `%${ sqlLikeEscape(ps.query) }%` });

View File

@ -49,16 +49,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
) { ) {
super(meta, paramDef, async (ps, me) => { super(meta, paramDef, async (ps, me) => {
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('note.replyId = :noteId', { noteId: ps.noteId }) qb
.orWhere(new Brackets(qb => { qb .where('note.replyId = :noteId', { noteId: ps.noteId })
.where('note.renoteId = :noteId', { noteId: ps.noteId }) .orWhere(new Brackets(qb => {
.andWhere(new Brackets(qb => { qb qb
.where('note.text IS NOT NULL') .where('note.renoteId = :noteId', { noteId: ps.noteId })
.orWhere('note.fileIds != \'{}\'') .andWhere(new Brackets(qb => {
.orWhere('note.hasPoll = TRUE'); qb
.where('note.text IS NOT NULL')
.orWhere('note.fileIds != \'{}\'')
.orWhere('note.hasPoll = TRUE');
}));
})); }));
}));
})) }))
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('note.reply', 'reply') .leftJoinAndSelect('note.reply', 'reply')

View File

@ -59,9 +59,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.where('following.followerId = :followerId', { followerId: me.id }); .where('following.followerId = :followerId', { followerId: me.id });
const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where(`'{"${me.id}"}' <@ note.mentions`) qb
.orWhere(`'{"${me.id}"}' <@ note.visibleUserIds`); .where(`'{"${me.id}"}' <@ note.mentions`)
.orWhere(`'{"${me.id}"}' <@ note.visibleUserIds`);
})) }))
// Avoid scanning primary key index // Avoid scanning primary key index
.orderBy('CONCAT(note.id)', 'DESC') .orderBy('CONCAT(note.id)', 'DESC')

View File

@ -57,9 +57,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.where('poll.userHost IS NULL') .where('poll.userHost IS NULL')
.andWhere('poll.userId != :meId', { meId: me.id }) .andWhere('poll.userId != :meId', { meId: me.id })
.andWhere('poll.noteVisibility = \'public\'') .andWhere('poll.noteVisibility = \'public\'')
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('poll.expiresAt IS NULL') qb
.orWhere('poll.expiresAt > :now', { now: new Date() }); .where('poll.expiresAt IS NULL')
.orWhere('poll.expiresAt > :now', { now: new Date() });
})); }));
//#region exclude arleady voted polls //#region exclude arleady voted polls

View File

@ -62,9 +62,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const query = this.queryService.makePaginationQuery(this.roleAssignmentsRepository.createQueryBuilder('assign'), ps.sinceId, ps.untilId) const query = this.queryService.makePaginationQuery(this.roleAssignmentsRepository.createQueryBuilder('assign'), ps.sinceId, ps.untilId)
.andWhere('assign.roleId = :roleId', { roleId: role.id }) .andWhere('assign.roleId = :roleId', { roleId: role.id })
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('assign.expiresAt IS NULL') qb
.orWhere('assign.expiresAt > :now', { now: new Date() }); .where('assign.expiresAt IS NULL')
.orWhere('assign.expiresAt > :now', { now: new Date() });
})) }))
.innerJoinAndSelect('assign.user', 'user'); .innerJoinAndSelect('assign.user', 'user');

View File

@ -92,9 +92,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.andWhere(`user.id IN (${ followingQuery.getQuery() })`) .andWhere(`user.id IN (${ followingQuery.getQuery() })`)
.andWhere('user.id != :meId', { meId: me.id }) .andWhere('user.id != :meId', { meId: me.id })
.andWhere('user.isSuspended = FALSE') .andWhere('user.isSuspended = FALSE')
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('user.updatedAt IS NULL') qb
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold }); .where('user.updatedAt IS NULL')
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
})); }));
query.setParameters(followingQuery.getParameters()); query.setParameters(followingQuery.getParameters());

View File

@ -64,9 +64,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
if (isUsername) { if (isUsername) {
const usernameQuery = this.usersRepository.createQueryBuilder('user') const usernameQuery = this.usersRepository.createQueryBuilder('user')
.where('user.usernameLower LIKE :username', { username: sqlLikeEscape(ps.query.replace('@', '').toLowerCase()) + '%' }) .where('user.usernameLower LIKE :username', { username: sqlLikeEscape(ps.query.replace('@', '').toLowerCase()) + '%' })
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('user.updatedAt IS NULL') qb
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold }); .where('user.updatedAt IS NULL')
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
})) }))
.andWhere('user.isSuspended = FALSE'); .andWhere('user.isSuspended = FALSE');
@ -91,9 +92,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
qb.orWhere('user.usernameLower LIKE :username', { username: '%' + sqlLikeEscape(ps.query.toLowerCase()) + '%' }); qb.orWhere('user.usernameLower LIKE :username', { username: '%' + sqlLikeEscape(ps.query.toLowerCase()) + '%' });
} }
})) }))
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('user.updatedAt IS NULL') qb
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold }); .where('user.updatedAt IS NULL')
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
})) }))
.andWhere('user.isSuspended = FALSE'); .andWhere('user.isSuspended = FALSE');
@ -122,9 +124,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const query = this.usersRepository.createQueryBuilder('user') const query = this.usersRepository.createQueryBuilder('user')
.where(`user.id IN (${ profQuery.getQuery() })`) .where(`user.id IN (${ profQuery.getQuery() })`)
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => {
.where('user.updatedAt IS NULL') qb
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold }); .where('user.updatedAt IS NULL')
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
})) }))
.andWhere('user.isSuspended = FALSE') .andWhere('user.isSuspended = FALSE')
.setParameters(profQuery.getParameters()); .setParameters(profQuery.getParameters());

View File

@ -2755,6 +2755,9 @@ type Notification_2 = {
invitation: UserGroup; invitation: UserGroup;
user: User; user: User;
userId: User['id']; userId: User['id'];
} | {
type: 'achievementEarned';
achievement: string;
} | { } | {
type: 'app'; type: 'app';
header?: string | null; header?: string | null;
@ -2765,7 +2768,7 @@ type Notification_2 = {
}); });
// @public (undocumented) // @public (undocumented)
export const notificationTypes: readonly ["note", "follow", "mention", "reply", "renote", "quote", "reaction", "pollVote", "pollEnded", "receiveFollowRequest", "followRequestAccepted", "groupInvited", "app"]; export const notificationTypes: readonly ["note", "follow", "mention", "reply", "renote", "quote", "reaction", "pollVote", "pollEnded", "receiveFollowRequest", "followRequestAccepted", "groupInvited", "app", "achievementEarned"];
// @public (undocumented) // @public (undocumented)
type OriginType = 'combined' | 'local' | 'remote'; type OriginType = 'combined' | 'local' | 'remote';
@ -2981,7 +2984,7 @@ type UserSorting = '+follower' | '-follower' | '+createdAt' | '-createdAt' | '+u
// src/api.types.ts:18:25 - (ae-forgotten-export) The symbol "NoParams" needs to be exported by the entry point index.d.ts // src/api.types.ts:18:25 - (ae-forgotten-export) The symbol "NoParams" needs to be exported by the entry point index.d.ts
// src/api.types.ts:630:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts // src/api.types.ts:630:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts
// src/entities.ts:107:2 - (ae-forgotten-export) The symbol "notificationTypes_2" needs to be exported by the entry point index.d.ts // src/entities.ts:107:2 - (ae-forgotten-export) The symbol "notificationTypes_2" needs to be exported by the entry point index.d.ts
// src/entities.ts:597:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts // src/entities.ts:600:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts
// src/streaming.types.ts:33:4 - (ae-forgotten-export) The symbol "FIXME" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:33:4 - (ae-forgotten-export) The symbol "FIXME" needs to be exported by the entry point index.d.ts
// (No @packageDocumentation comment for this package) // (No @packageDocumentation comment for this package)

View File

@ -67,8 +67,7 @@ export class APIClient {
IsCaseMatched<E, P, 8> extends true ? GetCaseResult<E, P, 8> : IsCaseMatched<E, P, 8> extends true ? GetCaseResult<E, P, 8> :
IsCaseMatched<E, P, 9> extends true ? GetCaseResult<E, P, 9> : IsCaseMatched<E, P, 9> extends true ? GetCaseResult<E, P, 9> :
Endpoints[E]['res']['$switch']['$default'] Endpoints[E]['res']['$switch']['$default']
: Endpoints[E]['res']> : Endpoints[E]['res']> {
{
const promise = new Promise((resolve, reject) => { const promise = new Promise((resolve, reject) => {
this.fetch(`${this.origin}/api/${endpoint}`, { this.fetch(`${this.origin}/api/${endpoint}`, {
method: 'POST', method: 'POST',

View File

@ -1,4 +1,4 @@
export const notificationTypes = ['note', 'follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app'] as const; export const notificationTypes = ['note', 'follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app', 'achievementEarned'] as const;
export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as const; export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as const;

View File

@ -277,6 +277,9 @@ export type Notification = {
invitation: UserGroup; invitation: UserGroup;
user: User; user: User;
userId: User['id']; userId: User['id'];
} | {
type: 'achievementEarned';
achievement: string;
} | { } | {
type: 'app'; type: 'app';
header?: string | null; header?: string | null;

View File

@ -15,7 +15,7 @@ import { getUrlWithLoginId } from '@/scripts/login-id.js';
export const cli = new Misskey.api.APIClient({ origin, fetch: (...args): Promise<Response> => fetch(...args) }); export const cli = new Misskey.api.APIClient({ origin, fetch: (...args): Promise<Response> => fetch(...args) });
export async function api<E extends keyof Misskey.Endpoints, O extends Misskey.Endpoints[E]['req']>(endpoint: E, userId?: string, options?: O): Promise<void | ReturnType<typeof cli.request<E, O>>> { export async function api<E extends keyof Misskey.Endpoints, O extends Misskey.Endpoints[E]['req']>(endpoint: E, userId?: string, options?: O): Promise<void | ReturnType<typeof cli.request<E, O>>> {
let account: { token: string; id: string } | void; let account: { token: string; id: string } | void = undefined;
if (userId) { if (userId) {
account = await getAccountFromId(userId); account = await getAccountFromId(userId);