lint fixes

This commit is contained in:
syuilo 2022-06-14 18:01:23 +09:00
parent 90827ce4a8
commit 963f538728
90 changed files with 204 additions and 204 deletions

View file

@ -1,12 +1,12 @@
import Koa from 'koa';
import { performance } from 'perf_hooks'; import { performance } from 'perf_hooks';
import { limiter } from './limiter.js'; import Koa from 'koa';
import { CacheableLocalUser, User } from '@/models/entities/user.js'; import { CacheableLocalUser, User } from '@/models/entities/user.js';
import { AccessToken } from '@/models/entities/access-token.js';
import { getIpHash } from '@/misc/get-ip-hash.js';
import { limiter } from './limiter.js';
import endpoints, { IEndpointMeta } from './endpoints.js'; import endpoints, { IEndpointMeta } from './endpoints.js';
import { ApiError } from './error.js'; import { ApiError } from './error.js';
import { apiLogger } from './logger.js'; import { apiLogger } from './logger.js';
import { AccessToken } from '@/models/entities/access-token.js';
import { getIpHash } from '@/misc/get-ip-hash.js';
const accessDenied = { const accessDenied = {
message: 'Access denied.', message: 'Access denied.',
@ -120,20 +120,20 @@ export default async (endpoint: string, user: CacheableLocalUser | null | undefi
if (e instanceof ApiError) { if (e instanceof ApiError) {
throw e; throw e;
} else { } else {
apiLogger.error(`Internal error occurred in ${ep.name}: ${e?.message}`, { apiLogger.error(`Internal error occurred in ${ep.name}: ${e.message}`, {
ep: ep.name, ep: ep.name,
ps: data, ps: data,
e: { e: {
message: e?.message, message: e.message,
code: e?.name, code: e.name,
stack: e?.stack, stack: e.stack,
}, },
}); });
throw new ApiError(null, { throw new ApiError(null, {
e: { e: {
message: e?.message, message: e.message,
code: e?.name, code: e.name,
stack: e?.stack, stack: e.stack,
}, },
}); });
} }

View file

@ -1,5 +1,5 @@
import define from '../define.js';
import { Announcements, AnnouncementReads } from '@/models/index.js'; import { Announcements, AnnouncementReads } from '@/models/index.js';
import define from '../define.js';
import { makePaginationQuery } from '../common/make-pagination-query.js'; import { makePaginationQuery } from '../common/make-pagination-query.js';
export const meta = { export const meta = {

View file

@ -1,6 +1,6 @@
import define from '../define.js';
import { fetchMeta } from '@/misc/fetch-meta.js'; import { fetchMeta } from '@/misc/fetch-meta.js';
import { DriveFiles } from '@/models/index.js'; import { DriveFiles } from '@/models/index.js';
import define from '../define.js';
export const meta = { export const meta = {
tags: ['drive', 'account'], tags: ['drive', 'account'],

View file

@ -1,6 +1,6 @@
import define from '../define.js';
import { createExportCustomEmojisJob } from '@/queue/index.js';
import ms from 'ms'; import ms from 'ms';
import { createExportCustomEmojisJob } from '@/queue/index.js';
import define from '../define.js';
export const meta = { export const meta = {
secure: true, secure: true,

View file

@ -1,6 +1,6 @@
import { MoreThan } from 'typeorm';
import { USER_ONLINE_THRESHOLD } from '@/const.js'; import { USER_ONLINE_THRESHOLD } from '@/const.js';
import { Users } from '@/models/index.js'; import { Users } from '@/models/index.js';
import { MoreThan } from 'typeorm';
import define from '../define.js'; import define from '../define.js';
export const meta = { export const meta = {

View file

@ -1,5 +1,5 @@
import define from '../define.js';
import { Users } from '@/models/index.js'; import { Users } from '@/models/index.js';
import define from '../define.js';
export const meta = { export const meta = {
tags: ['account'], tags: ['account'],

View file

@ -1,11 +1,11 @@
import { Brackets } from 'typeorm';
import { Notifications, Followings, Mutings, Users } from '@/models/index.js';
import { notificationTypes } from '@/types.js';
import read from '@/services/note/read.js';
import { readNotification } from '../../common/read-notification.js'; import { readNotification } from '../../common/read-notification.js';
import define from '../../define.js'; import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { generateMutedInstanceNotificationQuery } from '../../common/generate-muted-instance-query.js'; import { generateMutedInstanceNotificationQuery } from '../../common/generate-muted-instance-query.js';
import { Notifications, Followings, Mutings, Users } from '@/models/index.js';
import { notificationTypes } from '@/types.js';
import read from '@/services/note/read.js';
import { Brackets } from 'typeorm';
export const meta = { export const meta = {
tags: ['account', 'notifications'], tags: ['account', 'notifications'],
@ -67,7 +67,7 @@ export default define(meta, paramDef, async (ps, user) => {
.where('users.isSuspended = TRUE'); .where('users.isSuspended = TRUE');
const query = makePaginationQuery(Notifications.createQueryBuilder('notification'), ps.sinceId, ps.untilId) const query = makePaginationQuery(Notifications.createQueryBuilder('notification'), ps.sinceId, ps.untilId)
.andWhere(`notification.notifieeId = :meId`, { meId: user.id }) .andWhere('notification.notifieeId = :meId', { meId: user.id })
.leftJoinAndSelect('notification.notifier', 'notifier') .leftJoinAndSelect('notification.notifier', 'notifier')
.leftJoinAndSelect('notification.note', 'note') .leftJoinAndSelect('notification.note', 'note')
.leftJoinAndSelect('notifier.avatar', 'notifierAvatar') .leftJoinAndSelect('notifier.avatar', 'notifierAvatar')
@ -103,13 +103,13 @@ export default define(meta, paramDef, async (ps, user) => {
} }
if (ps.includeTypes && ps.includeTypes.length > 0) { if (ps.includeTypes && ps.includeTypes.length > 0) {
query.andWhere(`notification.type IN (:...includeTypes)`, { includeTypes: ps.includeTypes }); query.andWhere('notification.type IN (:...includeTypes)', { includeTypes: ps.includeTypes });
} else if (ps.excludeTypes && ps.excludeTypes.length > 0) { } else if (ps.excludeTypes && ps.excludeTypes.length > 0) {
query.andWhere(`notification.type NOT IN (:...excludeTypes)`, { excludeTypes: ps.excludeTypes }); query.andWhere('notification.type NOT IN (:...excludeTypes)', { excludeTypes: ps.excludeTypes });
} }
if (ps.unreadOnly) { if (ps.unreadOnly) {
query.andWhere(`notification.isRead = false`); query.andWhere('notification.isRead = false');
} }
const notifications = await query.take(ps.limit).getMany(); const notifications = await query.take(ps.limit).getMany();

View file

@ -1,10 +1,10 @@
import { IsNull, MoreThan } from 'typeorm';
import config from '@/config/index.js'; import config from '@/config/index.js';
import define from '../define.js';
import { fetchMeta } from '@/misc/fetch-meta.js'; import { fetchMeta } from '@/misc/fetch-meta.js';
import { Ads, Emojis, Users } from '@/models/index.js'; import { Ads, Emojis, Users } from '@/models/index.js';
import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits.js'; import { DB_MAX_NOTE_TEXT_LENGTH } from '@/misc/hard-limits.js';
import { IsNull, MoreThan } from 'typeorm';
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js'; import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
import define from '../define.js';
export const meta = { export const meta = {
tags: ['meta'], tags: ['meta'],

View file

@ -1,6 +1,6 @@
import { Notes } from '@/models/index.js';
import define from '../define.js'; import define from '../define.js';
import { makePaginationQuery } from '../common/make-pagination-query.js'; import { makePaginationQuery } from '../common/make-pagination-query.js';
import { Notes } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],
@ -34,8 +34,8 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps) => { export default define(meta, paramDef, async (ps) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId) const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.visibility = 'public'`) .andWhere('note.visibility = \'public\'')
.andWhere(`note.localOnly = FALSE`) .andWhere('note.localOnly = FALSE')
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('user.avatar', 'avatar') .leftJoinAndSelect('user.avatar', 'avatar')
.leftJoinAndSelect('user.banner', 'banner') .leftJoinAndSelect('user.banner', 'banner')
@ -61,7 +61,7 @@ export default define(meta, paramDef, async (ps) => {
} }
if (ps.withFiles !== undefined) { if (ps.withFiles !== undefined) {
query.andWhere(ps.withFiles ? `note.fileIds != '{}'` : `note.fileIds = '{}'`); query.andWhere(ps.withFiles ? 'note.fileIds != \'{}\'' : 'note.fileIds = \'{}\'');
} }
if (ps.poll !== undefined) { if (ps.poll !== undefined) {

View file

@ -1,9 +1,9 @@
import { Brackets } from 'typeorm';
import { Notes } from '@/models/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { Brackets } from 'typeorm';
import { Notes } from '@/models/index.js';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js'; import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js'; import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';
@ -38,13 +38,13 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, user) => { export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId) const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => { qb
.where(`note.replyId = :noteId`, { noteId: ps.noteId }) .where('note.replyId = :noteId', { noteId: ps.noteId })
.orWhere(new Brackets(qb => { qb .orWhere(new Brackets(qb => { qb
.where(`note.renoteId = :noteId`, { noteId: ps.noteId }) .where('note.renoteId = :noteId', { noteId: ps.noteId })
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => { qb
.where(`note.text IS NOT NULL`) .where('note.text IS NOT NULL')
.orWhere(`note.fileIds != '{}'`) .orWhere('note.fileIds != \'{}\'')
.orWhere(`note.hasPoll = TRUE`); .orWhere('note.hasPoll = TRUE');
})); }));
})); }));
})) }))

View file

@ -1,8 +1,8 @@
import define from '../../define.js'; import { In } from 'typeorm';
import { ClipNotes, Clips } from '@/models/index.js'; import { ClipNotes, Clips } from '@/models/index.js';
import define from '../../define.js';
import { getNote } from '../../common/getters.js'; import { getNote } from '../../common/getters.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { In } from 'typeorm';
export const meta = { export const meta = {
tags: ['clips', 'notes'], tags: ['clips', 'notes'],

View file

@ -1,8 +1,8 @@
import { Note } from '@/models/entities/note.js';
import { Notes } from '@/models/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { getNote } from '../../common/getters.js'; import { getNote } from '../../common/getters.js';
import { Note } from '@/models/entities/note.js';
import { Notes } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],

View file

@ -1,9 +1,9 @@
import deleteNote from '@/services/note/delete.js';
import define from '../../define.js';
import ms from 'ms'; import ms from 'ms';
import deleteNote from '@/services/note/delete.js';
import { Users } from '@/models/index.js';
import define from '../../define.js';
import { getNote } from '../../common/getters.js'; import { getNote } from '../../common/getters.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { Users } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],

View file

@ -1,8 +1,8 @@
import { NoteFavorites } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { getNote } from '../../../common/getters.js'; import { getNote } from '../../../common/getters.js';
import { NoteFavorites } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js';
export const meta = { export const meta = {
tags: ['notes', 'favorites'], tags: ['notes', 'favorites'],

View file

@ -1,7 +1,7 @@
import { NoteFavorites } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { getNote } from '../../../common/getters.js'; import { getNote } from '../../../common/getters.js';
import { NoteFavorites } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['notes', 'favorites'], tags: ['notes', 'favorites'],

View file

@ -1,6 +1,6 @@
import { Notes } from '@/models/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { Notes } from '@/models/index.js';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js'; import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = { export const meta = {
@ -36,9 +36,9 @@ export default define(meta, paramDef, async (ps, user) => {
const query = Notes.createQueryBuilder('note') const query = Notes.createQueryBuilder('note')
.addSelect('note.score') .addSelect('note.score')
.where('note.userHost IS NULL') .where('note.userHost IS NULL')
.andWhere(`note.score > 0`) .andWhere('note.score > 0')
.andWhere(`note.createdAt > :date`, { date: new Date(Date.now() - day) }) .andWhere('note.createdAt > :date', { date: new Date(Date.now() - day) })
.andWhere(`note.visibility = 'public'`) .andWhere('note.visibility = \'public\'')
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('user.avatar', 'avatar') .leftJoinAndSelect('user.avatar', 'avatar')
.leftJoinAndSelect('user.banner', 'banner') .leftJoinAndSelect('user.banner', 'banner')

View file

@ -1,11 +1,11 @@
import define from '../../define.js';
import { fetchMeta } from '@/misc/fetch-meta.js'; import { fetchMeta } from '@/misc/fetch-meta.js';
import { Notes, Users } from '@/models/index.js';
import { activeUsersChart } from '@/services/chart/index.js';
import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { Notes, Users } from '@/models/index.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js'; import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';
import { activeUsersChart } from '@/services/chart/index.js';
import { generateRepliesQuery } from '../../common/generate-replies-query.js'; import { generateRepliesQuery } from '../../common/generate-replies-query.js';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js'; import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js'; import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
@ -60,7 +60,7 @@ export default define(meta, paramDef, async (ps, user) => {
//#region Construct query //#region Construct query
const query = makePaginationQuery(Notes.createQueryBuilder('note'), const query = makePaginationQuery(Notes.createQueryBuilder('note'),
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('note.visibility = \'public\'') .andWhere('note.visibility = \'public\'')
.andWhere('note.channelId IS NULL') .andWhere('note.channelId IS NULL')
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')

View file

@ -1,13 +1,13 @@
import define from '../../define.js'; import { Brackets } from 'typeorm';
import { fetchMeta } from '@/misc/fetch-meta.js'; import { fetchMeta } from '@/misc/fetch-meta.js';
import { Followings, Notes, Users } from '@/models/index.js';
import { activeUsersChart } from '@/services/chart/index.js';
import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { Followings, Notes, Users } from '@/models/index.js';
import { Brackets } from 'typeorm';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js'; import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';
import { activeUsersChart } from '@/services/chart/index.js';
import { generateRepliesQuery } from '../../common/generate-replies-query.js'; import { generateRepliesQuery } from '../../common/generate-replies-query.js';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js'; import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
import { generateChannelQuery } from '../../common/generate-channel-query.js'; import { generateChannelQuery } from '../../common/generate-channel-query.js';
@ -70,7 +70,7 @@ export default define(meta, paramDef, async (ps, user) => {
.where('following.followerId = :followerId', { followerId: user.id }); .where('following.followerId = :followerId', { followerId: user.id });
const query = makePaginationQuery(Notes.createQueryBuilder('note'), const query = makePaginationQuery(Notes.createQueryBuilder('note'),
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere(new Brackets(qb => { .andWhere(new Brackets(qb => {
qb.where(`((note.userId IN (${ followingQuery.getQuery() })) OR (note.userId = :meId))`, { meId: user.id }) qb.where(`((note.userId IN (${ followingQuery.getQuery() })) OR (note.userId = :meId))`, { meId: user.id })
.orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)'); .orWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)');

View file

@ -1,12 +1,12 @@
import define from '../../define.js'; import { Brackets } from 'typeorm';
import { fetchMeta } from '@/misc/fetch-meta.js'; import { fetchMeta } from '@/misc/fetch-meta.js';
import { ApiError } from '../../error.js';
import { Notes, Users } from '@/models/index.js'; import { Notes, Users } from '@/models/index.js';
import { activeUsersChart } from '@/services/chart/index.js';
import define from '../../define.js';
import { ApiError } from '../../error.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { activeUsersChart } from '@/services/chart/index.js';
import { Brackets } from 'typeorm';
import { generateRepliesQuery } from '../../common/generate-replies-query.js'; import { generateRepliesQuery } from '../../common/generate-replies-query.js';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js'; import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
import { generateChannelQuery } from '../../common/generate-channel-query.js'; import { generateChannelQuery } from '../../common/generate-channel-query.js';
@ -66,7 +66,7 @@ export default define(meta, paramDef, async (ps, user) => {
//#region Construct query //#region Construct query
const query = makePaginationQuery(Notes.createQueryBuilder('note'), const query = makePaginationQuery(Notes.createQueryBuilder('note'),
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)') .andWhere('(note.visibility = \'public\') AND (note.userHost IS NULL)')
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('user.avatar', 'avatar') .leftJoinAndSelect('user.avatar', 'avatar')

View file

@ -1,10 +1,10 @@
import define from '../../define.js'; import { Brackets } from 'typeorm';
import read from '@/services/note/read.js'; import read from '@/services/note/read.js';
import { Notes, Followings } from '@/models/index.js'; import { Notes, Followings } from '@/models/index.js';
import define from '../../define.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { Brackets } from 'typeorm';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js'; import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
import { generateMutedNoteThreadQuery } from '../../common/generate-muted-note-thread-query.js'; import { generateMutedNoteThreadQuery } from '../../common/generate-muted-note-thread-query.js';

View file

@ -1,6 +1,6 @@
import define from '../../../define.js';
import { Polls, Mutings, Notes, PollVotes } from '@/models/index.js';
import { Brackets, In } from 'typeorm'; import { Brackets, In } from 'typeorm';
import { Polls, Mutings, Notes, PollVotes } from '@/models/index.js';
import define from '../../../define.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],
@ -31,8 +31,8 @@ export const paramDef = {
export default define(meta, paramDef, async (ps, user) => { export default define(meta, paramDef, async (ps, user) => {
const query = Polls.createQueryBuilder('poll') const query = Polls.createQueryBuilder('poll')
.where('poll.userHost IS NULL') .where('poll.userHost IS NULL')
.andWhere(`poll.userId != :meId`, { meId: user.id }) .andWhere('poll.userId != :meId', { meId: user.id })
.andWhere(`poll.noteVisibility = 'public'`) .andWhere('poll.noteVisibility = \'public\'')
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => { qb
.where('poll.expiresAt IS NULL') .where('poll.expiresAt IS NULL')
.orWhere('poll.expiresAt > :now', { now: new Date() }); .orWhere('poll.expiresAt > :now', { now: new Date() });

View file

@ -1,16 +1,16 @@
import { Not } from 'typeorm';
import { publishNoteStream } from '@/services/stream.js'; import { publishNoteStream } from '@/services/stream.js';
import { createNotification } from '@/services/create-notification.js'; import { createNotification } from '@/services/create-notification.js';
import define from '../../../define.js';
import { ApiError } from '../../../error.js';
import { getNote } from '../../../common/getters.js';
import { deliver } from '@/queue/index.js'; import { deliver } from '@/queue/index.js';
import { renderActivity } from '@/remote/activitypub/renderer/index.js'; import { renderActivity } from '@/remote/activitypub/renderer/index.js';
import renderVote from '@/remote/activitypub/renderer/vote.js'; import renderVote from '@/remote/activitypub/renderer/vote.js';
import { deliverQuestionUpdate } from '@/services/note/polls/update.js'; import { deliverQuestionUpdate } from '@/services/note/polls/update.js';
import { PollVotes, NoteWatchings, Users, Polls, Blockings } from '@/models/index.js'; import { PollVotes, NoteWatchings, Users, Polls, Blockings } from '@/models/index.js';
import { Not } from 'typeorm';
import { IRemoteUser } from '@/models/entities/user.js'; import { IRemoteUser } from '@/models/entities/user.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { getNote } from '../../../common/getters.js';
import { ApiError } from '../../../error.js';
import define from '../../../define.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],

View file

@ -1,6 +1,6 @@
import define from '../../../define.js';
import ms from 'ms'; import ms from 'ms';
import deleteReaction from '@/services/note/reaction/delete.js'; import deleteReaction from '@/services/note/reaction/delete.js';
import define from '../../../define.js';
import { getNote } from '../../../common/getters.js'; import { getNote } from '../../../common/getters.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';

View file

@ -1,10 +1,10 @@
import { Notes } from '@/models/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { getNote } from '../../common/getters.js'; import { getNote } from '../../common/getters.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { Notes } from '@/models/index.js';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js'; import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = { export const meta = {
@ -50,7 +50,7 @@ export default define(meta, paramDef, async (ps, user) => {
}); });
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId) const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
.andWhere(`note.renoteId = :renoteId`, { renoteId: note.id }) .andWhere('note.renoteId = :renoteId', { renoteId: note.id })
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('user.avatar', 'avatar') .leftJoinAndSelect('user.avatar', 'avatar')
.leftJoinAndSelect('user.banner', 'banner') .leftJoinAndSelect('user.banner', 'banner')

View file

@ -1,5 +1,5 @@
import define from '../../define.js';
import { Notes } from '@/models/index.js'; import { Notes } from '@/models/index.js';
import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';

View file

@ -1,11 +1,11 @@
import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { Notes } from '@/models/index.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { Brackets } from 'typeorm'; import { Brackets } from 'typeorm';
import { Notes } from '@/models/index.js';
import { safeForSql } from '@/misc/safe-for-sql.js'; import { safeForSql } from '@/misc/safe-for-sql.js';
import { normalizeForSearch } from '@/misc/normalize-for-search.js'; import { normalizeForSearch } from '@/misc/normalize-for-search.js';
import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js'; import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
export const meta = { export const meta = {

View file

@ -1,8 +1,8 @@
import { In } from 'typeorm';
import { Notes } from '@/models/index.js';
import config from '@/config/index.js';
import es from '../../../../db/elasticsearch.js'; import es from '../../../../db/elasticsearch.js';
import define from '../../define.js'; import define from '../../define.js';
import { Notes } from '@/models/index.js';
import { In } from 'typeorm';
import config from '@/config/index.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
@ -99,7 +99,7 @@ export default define(meta, paramDef, async (ps, me) => {
userHost: ps.host, userHost: ps.host,
}, },
}] : [] }] : []
: []; : [];
const result = await es.search({ const result = await es.search({
index: config.elasticsearch.index || 'misskey_note', index: config.elasticsearch.index || 'misskey_note',

View file

@ -1,7 +1,7 @@
import { Notes } from '@/models/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { getNote } from '../../common/getters.js'; import { getNote } from '../../common/getters.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { Notes } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],

View file

@ -1,5 +1,5 @@
import define from '../../define.js';
import { NoteFavorites, Notes, NoteThreadMutings, NoteWatchings } from '@/models/index.js'; import { NoteFavorites, Notes, NoteThreadMutings, NoteWatchings } from '@/models/index.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],

View file

@ -1,9 +1,9 @@
import define from '../../../define.js';
import { getNote } from '../../../common/getters.js';
import { ApiError } from '../../../error.js';
import { Notes, NoteThreadMutings } from '@/models/index.js'; import { Notes, NoteThreadMutings } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import readNote from '@/services/note/read.js'; import readNote from '@/services/note/read.js';
import define from '../../../define.js';
import { getNote } from '../../../common/getters.js';
import { ApiError } from '../../../error.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],

View file

@ -1,7 +1,7 @@
import { NoteThreadMutings } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { getNote } from '../../../common/getters.js'; import { getNote } from '../../../common/getters.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { NoteThreadMutings } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],

View file

@ -1,11 +1,11 @@
import { Brackets } from 'typeorm';
import { Notes, Followings } from '@/models/index.js';
import { activeUsersChart } from '@/services/chart/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { Notes, Followings } from '@/models/index.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js'; import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';
import { activeUsersChart } from '@/services/chart/index.js';
import { Brackets } from 'typeorm';
import { generateRepliesQuery } from '../../common/generate-replies-query.js'; import { generateRepliesQuery } from '../../common/generate-replies-query.js';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js'; import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
import { generateChannelQuery } from '../../common/generate-channel-query.js'; import { generateChannelQuery } from '../../common/generate-channel-query.js';
@ -62,10 +62,10 @@ export default define(meta, paramDef, async (ps, user) => {
.where('following.followerId = :followerId', { followerId: user.id }); .where('following.followerId = :followerId', { followerId: user.id });
const query = makePaginationQuery(Notes.createQueryBuilder('note'), const query = makePaginationQuery(Notes.createQueryBuilder('note'),
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => { qb
.where('note.userId = :meId', { meId: user.id }); .where('note.userId = :meId', { meId: user.id });
if (hasFollowing) qb.orWhere(`note.userId IN (${ followingQuery.getQuery() })`); if (hasFollowing) qb.orWhere(`note.userId IN (${ followingQuery.getQuery() })`);
})) }))
.innerJoinAndSelect('note.user', 'user') .innerJoinAndSelect('note.user', 'user')
.leftJoinAndSelect('user.avatar', 'avatar') .leftJoinAndSelect('user.avatar', 'avatar')

View file

@ -1,9 +1,9 @@
import deleteNote from '@/services/note/delete.js';
import define from '../../define.js';
import ms from 'ms'; import ms from 'ms';
import deleteNote from '@/services/note/delete.js';
import { Notes, Users } from '@/models/index.js';
import define from '../../define.js';
import { getNote } from '../../common/getters.js'; import { getNote } from '../../common/getters.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { Notes, Users } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],

View file

@ -1,10 +1,10 @@
import { Brackets } from 'typeorm';
import { UserLists, UserListJoinings, Notes } from '@/models/index.js';
import { activeUsersChart } from '@/services/chart/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { UserLists, UserListJoinings, Notes } from '@/models/index.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { activeUsersChart } from '@/services/chart/index.js';
import { Brackets } from 'typeorm';
export const meta = { export const meta = {
tags: ['notes', 'lists'], tags: ['notes', 'lists'],

View file

@ -1,5 +1,5 @@
import define from '../../../define.js';
import watch from '@/services/note/watch.js'; import watch from '@/services/note/watch.js';
import define from '../../../define.js';
import { getNote } from '../../../common/getters.js'; import { getNote } from '../../../common/getters.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';

View file

@ -1,5 +1,5 @@
import define from '../../../define.js';
import unwatch from '@/services/note/unwatch.js'; import unwatch from '@/services/note/unwatch.js';
import define from '../../../define.js';
import { getNote } from '../../../common/getters.js'; import { getNote } from '../../../common/getters.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';

View file

@ -1,5 +1,5 @@
import define from '../../define.js';
import { createNotification } from '@/services/create-notification.js'; import { createNotification } from '@/services/create-notification.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['notifications'], tags: ['notifications'],

View file

@ -1,7 +1,7 @@
import { publishMainStream } from '@/services/stream.js'; import { publishMainStream } from '@/services/stream.js';
import { pushNotification } from '@/services/push-notification.js'; import { pushNotification } from '@/services/push-notification.js';
import define from '../../define.js';
import { Notifications } from '@/models/index.js'; import { Notifications } from '@/models/index.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['notifications', 'account'], tags: ['notifications', 'account'],

View file

@ -4,7 +4,7 @@ import { readNotification } from '../../common/read-notification.js';
export const meta = { export const meta = {
desc: { desc: {
'ja-JP': '通知を既読にします。', 'ja-JP': '通知を既読にします。',
'en-US': 'Mark a notification as read.' 'en-US': 'Mark a notification as read.',
}, },
tags: ['notifications', 'account'], tags: ['notifications', 'account'],

View file

@ -1,6 +1,6 @@
import define from '../define.js';
import { publishMainStream } from '@/services/stream.js'; import { publishMainStream } from '@/services/stream.js';
import { Users, Pages } from '@/models/index.js'; import { Users, Pages } from '@/models/index.js';
import define from '../define.js';
import { ApiError } from '../error.js'; import { ApiError } from '../error.js';
export const meta = { export const meta = {

View file

@ -1,8 +1,8 @@
import ms from 'ms'; import ms from 'ms';
import define from '../../define.js';
import { Pages, DriveFiles } from '@/models/index.js'; import { Pages, DriveFiles } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { Page } from '@/models/entities/page.js'; import { Page } from '@/models/entities/page.js';
import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
export const meta = { export const meta = {
@ -51,7 +51,7 @@ export const paramDef = {
} }, } },
script: { type: 'string' }, script: { type: 'string' },
eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true }, eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true },
font: { type: 'string', enum: ['serif', 'sans-serif'], default: "sans-serif" }, font: { type: 'string', enum: ['serif', 'sans-serif'], default: 'sans-serif' },
alignCenter: { type: 'boolean', default: false }, alignCenter: { type: 'boolean', default: false },
hideTitleWhenPinned: { type: 'boolean', default: false }, hideTitleWhenPinned: { type: 'boolean', default: false },
}, },

View file

@ -1,6 +1,6 @@
import { Pages } from '@/models/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { Pages } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['pages'], tags: ['pages'],

View file

@ -1,5 +1,5 @@
import define from '../../define.js';
import { Pages } from '@/models/index.js'; import { Pages } from '@/models/index.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['pages'], tags: ['pages'],

View file

@ -1,7 +1,7 @@
import define from '../../define.js';
import { ApiError } from '../../error.js';
import { Pages, PageLikes } from '@/models/index.js'; import { Pages, PageLikes } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import define from '../../define.js';
import { ApiError } from '../../error.js';
export const meta = { export const meta = {
tags: ['pages'], tags: ['pages'],

View file

@ -1,6 +1,6 @@
import { Pages, PageLikes } from '@/models/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { Pages, PageLikes } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['pages'], tags: ['pages'],

View file

@ -1,8 +1,8 @@
import ms from 'ms'; import ms from 'ms';
import { Not } from 'typeorm';
import { Pages, DriveFiles } from '@/models/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { Pages, DriveFiles } from '@/models/index.js';
import { Not } from 'typeorm';
export const meta = { export const meta = {
tags: ['pages'], tags: ['pages'],

View file

@ -1,9 +1,9 @@
import define from '../define.js'; import { IsNull } from 'typeorm';
import { Users } from '@/models/index.js'; import { Users } from '@/models/index.js';
import { fetchMeta } from '@/misc/fetch-meta.js'; import { fetchMeta } from '@/misc/fetch-meta.js';
import * as Acct from '@/misc/acct.js'; import * as Acct from '@/misc/acct.js';
import { User } from '@/models/entities/user.js'; import { User } from '@/models/entities/user.js';
import { IsNull } from 'typeorm'; import define from '../define.js';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],

View file

@ -1,8 +1,8 @@
import { PromoReads } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js';
import define from '../../define.js'; import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { getNote } from '../../common/getters.js'; import { getNote } from '../../common/getters.js';
import { PromoReads } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js';
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],

View file

@ -1,13 +1,13 @@
import { publishMainStream } from '@/services/stream.js';
import define from '../define.js';
import rndstr from 'rndstr'; import rndstr from 'rndstr';
import config from '@/config/index.js';
import ms from 'ms'; import ms from 'ms';
import { IsNull } from 'typeorm';
import { publishMainStream } from '@/services/stream.js';
import config from '@/config/index.js';
import { Users, UserProfiles, PasswordResetRequests } from '@/models/index.js'; import { Users, UserProfiles, PasswordResetRequests } from '@/models/index.js';
import { sendEmail } from '@/services/send-email.js'; import { sendEmail } from '@/services/send-email.js';
import { ApiError } from '../error.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { IsNull } from 'typeorm'; import { ApiError } from '../error.js';
import define from '../define.js';
export const meta = { export const meta = {
tags: ['reset password'], tags: ['reset password'],

View file

@ -1,6 +1,6 @@
import { resetDb } from '@/db/postgre.js';
import define from '../define.js'; import define from '../define.js';
import { ApiError } from '../error.js'; import { ApiError } from '../error.js';
import { resetDb } from '@/db/postgre.js';
export const meta = { export const meta = {
tags: ['non-productive'], tags: ['non-productive'],

View file

@ -1,7 +1,7 @@
import bcrypt from 'bcryptjs'; import bcrypt from 'bcryptjs';
import { publishMainStream } from '@/services/stream.js'; import { publishMainStream } from '@/services/stream.js';
import define from '../define.js';
import { Users, UserProfiles, PasswordResetRequests } from '@/models/index.js'; import { Users, UserProfiles, PasswordResetRequests } from '@/models/index.js';
import define from '../define.js';
import { ApiError } from '../error.js'; import { ApiError } from '../error.js';
export const meta = { export const meta = {

View file

@ -1,5 +1,5 @@
import define from '../define.js';
import { Instances, NoteReactions, Notes, Users } from '@/models/index.js'; import { Instances, NoteReactions, Notes, Users } from '@/models/index.js';
import define from '../define.js';
import { } from '@/services/chart/index.js'; import { } from '@/services/chart/index.js';
import { IsNull } from 'typeorm'; import { IsNull } from 'typeorm';

View file

@ -1,7 +1,7 @@
import define from '../../define.js';
import { fetchMeta } from '@/misc/fetch-meta.js'; import { fetchMeta } from '@/misc/fetch-meta.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { SwSubscriptions } from '@/models/index.js'; import { SwSubscriptions } from '@/models/index.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['account'], tags: ['account'],

View file

@ -1,5 +1,5 @@
import define from '../../define.js';
import { SwSubscriptions } from '@/models/index.js'; import { SwSubscriptions } from '@/models/index.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['account'], tags: ['account'],

View file

@ -1,6 +1,6 @@
import define from '../../define.js';
import { Users, UsedUsernames } from '@/models/index.js';
import { IsNull } from 'typeorm'; import { IsNull } from 'typeorm';
import { Users, UsedUsernames } from '@/models/index.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],

View file

@ -1,5 +1,5 @@
import define from '../define.js';
import { Users } from '@/models/index.js'; import { Users } from '@/models/index.js';
import define from '../define.js';
import { generateMutedUserQueryForUsers } from '../common/generate-muted-user-query.js'; import { generateMutedUserQueryForUsers } from '../common/generate-muted-user-query.js';
import { generateBlockQueryForUsers } from '../common/generate-block-query.js'; import { generateBlockQueryForUsers } from '../common/generate-block-query.js';
@ -25,8 +25,8 @@ export const paramDef = {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
offset: { type: 'integer', default: 0 }, offset: { type: 'integer', default: 0 },
sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt'] }, sort: { type: 'string', enum: ['+follower', '-follower', '+createdAt', '-createdAt', '+updatedAt', '-updatedAt'] },
state: { type: 'string', enum: ['all', 'admin', 'moderator', 'adminOrModerator', 'alive'], default: "all" }, state: { type: 'string', enum: ['all', 'admin', 'moderator', 'adminOrModerator', 'alive'], default: 'all' },
origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: "local" }, origin: { type: 'string', enum: ['combined', 'local', 'remote'], default: 'local' },
}, },
required: [], required: [],
} as const; } as const;

View file

@ -1,5 +1,5 @@
import define from '../../define.js';
import { Clips } from '@/models/index.js'; import { Clips } from '@/models/index.js';
import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = { export const meta = {
@ -32,7 +32,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => { export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(Clips.createQueryBuilder('clip'), ps.sinceId, ps.untilId) const query = makePaginationQuery(Clips.createQueryBuilder('clip'), ps.sinceId, ps.untilId)
.andWhere(`clip.userId = :userId`, { userId: ps.userId }) .andWhere('clip.userId = :userId', { userId: ps.userId })
.andWhere('clip.isPublic = true'); .andWhere('clip.isPublic = true');
const clips = await query const clips = await query

View file

@ -1,9 +1,9 @@
import { IsNull } from 'typeorm';
import { Users, Followings, UserProfiles } from '@/models/index.js';
import { toPunyNullable } from '@/misc/convert-host.js';
import define from '../../define.js'; import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { Users, Followings, UserProfiles } from '@/models/index.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { toPunyNullable } from '@/misc/convert-host.js';
import { IsNull } from 'typeorm';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],
@ -96,7 +96,7 @@ export default define(meta, paramDef, async (ps, me) => {
} }
const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId) const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId)
.andWhere(`following.followeeId = :userId`, { userId: user.id }) .andWhere('following.followeeId = :userId', { userId: user.id })
.innerJoinAndSelect('following.follower', 'follower'); .innerJoinAndSelect('following.follower', 'follower');
const followings = await query const followings = await query

View file

@ -1,9 +1,9 @@
import { IsNull } from 'typeorm';
import { Users, Followings, UserProfiles } from '@/models/index.js';
import { toPunyNullable } from '@/misc/convert-host.js';
import define from '../../define.js'; import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { Users, Followings, UserProfiles } from '@/models/index.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { toPunyNullable } from '@/misc/convert-host.js';
import { IsNull } from 'typeorm';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],
@ -96,7 +96,7 @@ export default define(meta, paramDef, async (ps, me) => {
} }
const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId) const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId)
.andWhere(`following.followerId = :userId`, { userId: user.id }) .andWhere('following.followerId = :userId', { userId: user.id })
.innerJoinAndSelect('following.followee', 'followee'); .innerJoinAndSelect('following.followee', 'followee');
const followings = await query const followings = await query

View file

@ -1,9 +1,9 @@
import define from '../../define.js'; import { Not, In, IsNull } from 'typeorm';
import { maximum } from '@/prelude/array.js'; import { maximum } from '@/prelude/array.js';
import { Notes, Users } from '@/models/index.js';
import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { getUser } from '../../common/getters.js'; import { getUser } from '../../common/getters.js';
import { Not, In, IsNull } from 'typeorm';
import { Notes, Users } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],

View file

@ -1,8 +1,8 @@
import define from '../../../define.js';
import { UserGroups, UserGroupJoinings } from '@/models/index.js'; import { UserGroups, UserGroupJoinings } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { UserGroup } from '@/models/entities/user-group.js'; import { UserGroup } from '@/models/entities/user-group.js';
import { UserGroupJoining } from '@/models/entities/user-group-joining.js'; import { UserGroupJoining } from '@/models/entities/user-group-joining.js';
import define from '../../../define.js';
export const meta = { export const meta = {
tags: ['groups'], tags: ['groups'],

View file

@ -1,6 +1,6 @@
import { UserGroups } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { UserGroups } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['groups'], tags: ['groups'],

View file

@ -1,8 +1,8 @@
import define from '../../../../define.js';
import { ApiError } from '../../../../error.js';
import { UserGroupJoinings, UserGroupInvitations } from '@/models/index.js'; import { UserGroupJoinings, UserGroupInvitations } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { UserGroupJoining } from '@/models/entities/user-group-joining.js'; import { UserGroupJoining } from '@/models/entities/user-group-joining.js';
import { ApiError } from '../../../../error.js';
import define from '../../../../define.js';
export const meta = { export const meta = {
tags: ['groups', 'users'], tags: ['groups', 'users'],

View file

@ -1,6 +1,6 @@
import { UserGroupInvitations } from '@/models/index.js';
import define from '../../../../define.js'; import define from '../../../../define.js';
import { ApiError } from '../../../../error.js'; import { ApiError } from '../../../../error.js';
import { UserGroupInvitations } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['groups', 'users'], tags: ['groups', 'users'],

View file

@ -1,10 +1,10 @@
import define from '../../../define.js';
import { ApiError } from '../../../error.js';
import { getUser } from '../../../common/getters.js';
import { UserGroups, UserGroupJoinings, UserGroupInvitations } from '@/models/index.js'; import { UserGroups, UserGroupJoinings, UserGroupInvitations } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { UserGroupInvitation } from '@/models/entities/user-group-invitation.js'; import { UserGroupInvitation } from '@/models/entities/user-group-invitation.js';
import { createNotification } from '@/services/create-notification.js'; import { createNotification } from '@/services/create-notification.js';
import { getUser } from '../../../common/getters.js';
import { ApiError } from '../../../error.js';
import define from '../../../define.js';
export const meta = { export const meta = {
tags: ['groups', 'users'], tags: ['groups', 'users'],

View file

@ -1,6 +1,6 @@
import define from '../../../define.js';
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
import { Not, In } from 'typeorm'; import { Not, In } from 'typeorm';
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
import define from '../../../define.js';
export const meta = { export const meta = {
tags: ['groups', 'account'], tags: ['groups', 'account'],

View file

@ -1,6 +1,6 @@
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['groups', 'users'], tags: ['groups', 'users'],

View file

@ -1,5 +1,5 @@
import define from '../../../define.js';
import { UserGroups } from '@/models/index.js'; import { UserGroups } from '@/models/index.js';
import define from '../../../define.js';
export const meta = { export const meta = {
tags: ['groups', 'account'], tags: ['groups', 'account'],

View file

@ -1,7 +1,7 @@
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { getUser } from '../../../common/getters.js'; import { getUser } from '../../../common/getters.js';
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['groups', 'users'], tags: ['groups', 'users'],

View file

@ -1,6 +1,6 @@
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['groups', 'account'], tags: ['groups', 'account'],

View file

@ -1,7 +1,7 @@
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { getUser } from '../../../common/getters.js'; import { getUser } from '../../../common/getters.js';
import { UserGroups, UserGroupJoinings } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['groups', 'users'], tags: ['groups', 'users'],

View file

@ -1,6 +1,6 @@
import { UserGroups } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { UserGroups } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['groups'], tags: ['groups'],

View file

@ -1,7 +1,7 @@
import define from '../../../define.js';
import { UserLists } from '@/models/index.js'; import { UserLists } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { UserList } from '@/models/entities/user-list.js'; import { UserList } from '@/models/entities/user-list.js';
import define from '../../../define.js';
export const meta = { export const meta = {
tags: ['lists'], tags: ['lists'],

View file

@ -1,6 +1,6 @@
import { UserLists } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { UserLists } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['lists'], tags: ['lists'],

View file

@ -1,5 +1,5 @@
import define from '../../../define.js';
import { UserLists } from '@/models/index.js'; import { UserLists } from '@/models/index.js';
import define from '../../../define.js';
export const meta = { export const meta = {
tags: ['lists', 'account'], tags: ['lists', 'account'],

View file

@ -1,8 +1,8 @@
import { publishUserListStream } from '@/services/stream.js'; import { publishUserListStream } from '@/services/stream.js';
import { UserLists, UserListJoinings, Users } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { getUser } from '../../../common/getters.js'; import { getUser } from '../../../common/getters.js';
import { UserLists, UserListJoinings, Users } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['lists', 'users'], tags: ['lists', 'users'],

View file

@ -1,8 +1,8 @@
import { pushUserToUserList } from '@/services/user-list/push.js';
import { UserLists, UserListJoinings, Blockings } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { getUser } from '../../../common/getters.js'; import { getUser } from '../../../common/getters.js';
import { pushUserToUserList } from '@/services/user-list/push.js';
import { UserLists, UserListJoinings, Blockings } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['lists', 'users'], tags: ['lists', 'users'],

View file

@ -1,6 +1,6 @@
import { UserLists } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { UserLists } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['lists', 'account'], tags: ['lists', 'account'],

View file

@ -1,6 +1,6 @@
import { UserLists } from '@/models/index.js';
import define from '../../../define.js'; import define from '../../../define.js';
import { ApiError } from '../../../error.js'; import { ApiError } from '../../../error.js';
import { UserLists } from '@/models/index.js';
export const meta = { export const meta = {
tags: ['lists'], tags: ['lists'],

View file

@ -1,11 +1,11 @@
import { Brackets } from 'typeorm';
import { Notes } from '@/models/index.js';
import define from '../../define.js'; import define from '../../define.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { getUser } from '../../common/getters.js'; import { getUser } from '../../common/getters.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { Notes } from '@/models/index.js';
import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQuery } from '../../common/generate-muted-user-query.js';
import { Brackets } from 'typeorm';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js'; import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js'; import { generateMutedInstanceQuery } from '../../common/generate-muted-instance-query.js';

View file

@ -1,5 +1,5 @@
import define from '../../define.js';
import { Pages } from '@/models/index.js'; import { Pages } from '@/models/index.js';
import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = { export const meta = {
@ -32,7 +32,7 @@ export const paramDef = {
// eslint-disable-next-line import/no-default-export // eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => { export default define(meta, paramDef, async (ps, user) => {
const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId) const query = makePaginationQuery(Pages.createQueryBuilder('page'), ps.sinceId, ps.untilId)
.andWhere(`page.userId = :userId`, { userId: ps.userId }) .andWhere('page.userId = :userId', { userId: ps.userId })
.andWhere('page.visibility = \'public\''); .andWhere('page.visibility = \'public\'');
const pages = await query const pages = await query

View file

@ -1,5 +1,5 @@
import define from '../../define.js';
import { NoteReactions, UserProfiles } from '@/models/index.js'; import { NoteReactions, UserProfiles } from '@/models/index.js';
import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js'; import { makePaginationQuery } from '../../common/make-pagination-query.js';
import { generateVisibilityQuery } from '../../common/generate-visibility-query.js'; import { generateVisibilityQuery } from '../../common/generate-visibility-query.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
@ -52,8 +52,8 @@ export default define(meta, paramDef, async (ps, me) => {
} }
const query = makePaginationQuery(NoteReactions.createQueryBuilder('reaction'), const query = makePaginationQuery(NoteReactions.createQueryBuilder('reaction'),
ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate) ps.sinceId, ps.untilId, ps.sinceDate, ps.untilDate)
.andWhere(`reaction.userId = :userId`, { userId: ps.userId }) .andWhere('reaction.userId = :userId', { userId: ps.userId })
.leftJoinAndSelect('reaction.note', 'note'); .leftJoinAndSelect('reaction.note', 'note');
generateVisibilityQuery(query, me); generateVisibilityQuery(query, me);

View file

@ -1,6 +1,6 @@
import ms from 'ms'; import ms from 'ms';
import define from '../../define.js';
import { Users, Followings } from '@/models/index.js'; import { Users, Followings } from '@/models/index.js';
import define from '../../define.js';
import { generateMutedUserQueryForUsers } from '../../common/generate-muted-user-query.js'; import { generateMutedUserQueryForUsers } from '../../common/generate-muted-user-query.js';
import { generateBlockedUserQuery, generateBlockQueryForUsers } from '../../common/generate-block-query.js'; import { generateBlockedUserQuery, generateBlockQueryForUsers } from '../../common/generate-block-query.js';

View file

@ -1,5 +1,5 @@
import define from '../../define.js';
import { Users } from '@/models/index.js'; import { Users } from '@/models/index.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],

View file

@ -1,12 +1,12 @@
import * as sanitizeHtml from 'sanitize-html'; import * as sanitizeHtml from 'sanitize-html';
import define from '../../define.js';
import { publishAdminStream } from '@/services/stream.js'; import { publishAdminStream } from '@/services/stream.js';
import { ApiError } from '../../error.js';
import { getUser } from '../../common/getters.js';
import { AbuseUserReports, Users } from '@/models/index.js'; import { AbuseUserReports, Users } from '@/models/index.js';
import { genId } from '@/misc/gen-id.js'; import { genId } from '@/misc/gen-id.js';
import { sendEmail } from '@/services/send-email.js'; import { sendEmail } from '@/services/send-email.js';
import { fetchMeta } from '@/misc/fetch-meta.js'; import { fetchMeta } from '@/misc/fetch-meta.js';
import { getUser } from '../../common/getters.js';
import { ApiError } from '../../error.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],

View file

@ -1,8 +1,8 @@
import define from '../../define.js';
import { Followings, Users } from '@/models/index.js';
import { Brackets } from 'typeorm'; import { Brackets } from 'typeorm';
import { Followings, Users } from '@/models/index.js';
import { USER_ACTIVE_THRESHOLD } from '@/const.js'; import { USER_ACTIVE_THRESHOLD } from '@/const.js';
import { User } from '@/models/entities/user.js'; import { User } from '@/models/entities/user.js';
import define from '../../define.js';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],
@ -67,7 +67,7 @@ export default define(meta, paramDef, async (ps, me) => {
const query = Users.createQueryBuilder('user') const query = Users.createQueryBuilder('user')
.where(`user.id IN (${ followingQuery.getQuery() })`) .where(`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('user.usernameLower LIKE :username', { username: ps.username.toLowerCase() + '%' }) .andWhere('user.usernameLower LIKE :username', { username: ps.username.toLowerCase() + '%' })
.andWhere(new Brackets(qb => { qb .andWhere(new Brackets(qb => { qb
@ -85,7 +85,7 @@ export default define(meta, paramDef, async (ps, me) => {
if (users.length < ps.limit) { if (users.length < ps.limit) {
const otherQuery = await Users.createQueryBuilder('user') const otherQuery = await Users.createQueryBuilder('user')
.where(`user.id NOT IN (${ followingQuery.getQuery() })`) .where(`user.id NOT 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('user.usernameLower LIKE :username', { username: ps.username.toLowerCase() + '%' }) .andWhere('user.usernameLower LIKE :username', { username: ps.username.toLowerCase() + '%' })
.andWhere('user.updatedAt IS NOT NULL'); .andWhere('user.updatedAt IS NOT NULL');

View file

@ -1,7 +1,7 @@
import define from '../../define.js'; import { Brackets } from 'typeorm';
import { UserProfiles, Users } from '@/models/index.js'; import { UserProfiles, Users } from '@/models/index.js';
import { User } from '@/models/entities/user.js'; import { User } from '@/models/entities/user.js';
import { Brackets } from 'typeorm'; import define from '../../define.js';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],
@ -27,7 +27,7 @@ export const paramDef = {
query: { type: 'string' }, query: { type: 'string' },
offset: { type: 'integer', default: 0 }, offset: { type: 'integer', default: 0 },
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
origin: { type: 'string', enum: ['local', 'remote', 'combined'], default: "combined" }, origin: { type: 'string', enum: ['local', 'remote', 'combined'], default: 'combined' },
detail: { type: 'boolean', default: true }, detail: { type: 'boolean', default: true },
}, },
required: ['query'], required: ['query'],
@ -113,7 +113,7 @@ export default define(meta, paramDef, async (ps, me) => {
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST') .orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
.take(ps.limit) .take(ps.limit)
.skip(ps.offset) .skip(ps.offset)
.getMany() .getMany(),
); );
} }
} }

View file

@ -1,10 +1,10 @@
import { FindOptionsWhere, In, IsNull } from 'typeorm';
import { resolveUser } from '@/remote/resolve-user.js'; import { resolveUser } from '@/remote/resolve-user.js';
import { Users } from '@/models/index.js';
import { User } from '@/models/entities/user.js';
import define from '../../define.js'; import define from '../../define.js';
import { apiLogger } from '../../logger.js'; import { apiLogger } from '../../logger.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import { Users } from '@/models/index.js';
import { FindOptionsWhere, In, IsNull } from 'typeorm';
import { User } from '@/models/entities/user.js';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],

View file

@ -1,7 +1,7 @@
import define from '../../define.js';
import { ApiError } from '../../error.js';
import { DriveFiles, Followings, NoteFavorites, NoteReactions, Notes, PageLikes, PollVotes, Users } from '@/models/index.js'; import { DriveFiles, Followings, NoteFavorites, NoteReactions, Notes, PageLikes, PollVotes, Users } from '@/models/index.js';
import { awaitAll } from '@/prelude/await-all.js'; import { awaitAll } from '@/prelude/await-all.js';
import define from '../../define.js';
import { ApiError } from '../../error.js';
export const meta = { export const meta = {
tags: ['users'], tags: ['users'],

View file

@ -1,8 +1,8 @@
import Limiter from 'ratelimiter'; import Limiter from 'ratelimiter';
import { redisClient } from '../../db/redis.js';
import { IEndpointMeta } from './endpoints.js';
import { CacheableLocalUser, User } from '@/models/entities/user.js'; import { CacheableLocalUser, User } from '@/models/entities/user.js';
import Logger from '@/services/logger.js'; import Logger from '@/services/logger.js';
import { redisClient } from '../../db/redis.js';
import { IEndpointMeta } from './endpoints.js';
const logger = new Logger('limiter'); const logger = new Logger('limiter');