fix lint "object-shorthand"

This commit is contained in:
Johann150 2022-08-03 14:49:55 +02:00
parent 37e47a257e
commit c8f49bae76
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1
57 changed files with 140 additions and 156 deletions

View file

@ -202,7 +202,7 @@ export const db = new DataSource({
logging: log,
logger: log ? new MyCustomLogger() : undefined,
maxQueryExecutionTime: 300,
entities: entities,
entities,
migrations: ['../../migration/*.js'],
});

View file

@ -6,5 +6,5 @@ import { Cache } from './cache.js';
const cache = new Cache<UserKeypair>(Infinity);
export async function getUserKeypair(userId: User['id']): Promise<UserKeypair> {
return await cache.fetch(userId, () => UserKeypairs.findOneByOrFail({ userId: userId }));
return await cache.fetch(userId, () => UserKeypairs.findOneByOrFail({ userId }));
}

View file

@ -68,7 +68,7 @@ export const DriveFileRepository = db.getRepository(DriveFile).extend({
const { sum } = await this
.createQueryBuilder('file')
.where('file.userId = :id', { id: id })
.where('file.userId = :id', { id })
.andWhere('file.isLink = FALSE')
.select('SUM(file.size)', 'sum')
.getRawOne();

View file

@ -172,7 +172,7 @@ export const NoteRepository = db.getRepository(Note).extend({
user: Users.pack(note.user ?? note.userId, me, {
detail: false,
}),
text: text,
text,
cw: note.cw,
visibility: note.visibility,
localOnly: note.localOnly || undefined,

View file

@ -120,12 +120,12 @@ export const UserRepository = db.getRepository(User).extend({
muterId: userId,
});
const joinings = await UserGroupJoinings.findBy({ userId: userId });
const joinings = await UserGroupJoinings.findBy({ userId });
const groupQs = Promise.all(joinings.map(j => MessagingMessages.createQueryBuilder('message')
.where('message.groupId = :groupId', { groupId: j.userGroupId })
.andWhere('message.userId != :userId', { userId: userId })
.andWhere('NOT (:userId = ANY(message.reads))', { userId: userId })
.andWhere('message.userId != :userId', { userId })
.andWhere('NOT (:userId = ANY(message.reads))', { userId })
.andWhere('message.createdAt > :joinedAt', { joinedAt: j.createdAt }) // 自分が加入する前の会話については、未読扱いしない
.getOne().then(x => x != null)));
@ -146,7 +146,7 @@ export const UserRepository = db.getRepository(User).extend({
async getHasUnreadAnnouncement(userId: User['id']): Promise<boolean> {
const reads = await AnnouncementReads.findBy({
userId: userId,
userId,
});
const count = await Announcements.countBy(reads.length > 0 ? {
@ -171,7 +171,7 @@ export const UserRepository = db.getRepository(User).extend({
const channels = await ChannelFollowings.findBy({ followerId: userId });
const unread = channels.length > 0 ? await NoteUnreads.findOneBy({
userId: userId,
userId,
noteChannelId: In(channels.map(x => x.followeeId)),
}) : null;

View file

@ -107,7 +107,7 @@ export function deliver(user: ThinUser, content: unknown, to: string | null) {
export function inbox(activity: IActivity, signature: httpSignature.IParsedSignature) {
const data = {
activity: activity,
activity,
signature,
};
@ -124,7 +124,7 @@ export function inbox(activity: IActivity, signature: httpSignature.IParsedSigna
export function createDeleteDriveFilesJob(user: ThinUser) {
return dbQueue.add('deleteDriveFiles', {
user: user,
user,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -133,7 +133,7 @@ export function createDeleteDriveFilesJob(user: ThinUser) {
export function createExportCustomEmojisJob(user: ThinUser) {
return dbQueue.add('exportCustomEmojis', {
user: user,
user,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -142,7 +142,7 @@ export function createExportCustomEmojisJob(user: ThinUser) {
export function createExportNotesJob(user: ThinUser) {
return dbQueue.add('exportNotes', {
user: user,
user,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -151,7 +151,7 @@ export function createExportNotesJob(user: ThinUser) {
export function createExportFollowingJob(user: ThinUser, excludeMuting = false, excludeInactive = false) {
return dbQueue.add('exportFollowing', {
user: user,
user,
excludeMuting,
excludeInactive,
}, {
@ -162,7 +162,7 @@ export function createExportFollowingJob(user: ThinUser, excludeMuting = false,
export function createExportMuteJob(user: ThinUser) {
return dbQueue.add('exportMute', {
user: user,
user,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -171,7 +171,7 @@ export function createExportMuteJob(user: ThinUser) {
export function createExportBlockingJob(user: ThinUser) {
return dbQueue.add('exportBlocking', {
user: user,
user,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -180,7 +180,7 @@ export function createExportBlockingJob(user: ThinUser) {
export function createExportUserListsJob(user: ThinUser) {
return dbQueue.add('exportUserLists', {
user: user,
user,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -189,8 +189,8 @@ export function createExportUserListsJob(user: ThinUser) {
export function createImportFollowingJob(user: ThinUser, fileId: DriveFile['id']) {
return dbQueue.add('importFollowing', {
user: user,
fileId: fileId,
user,
fileId,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -199,8 +199,8 @@ export function createImportFollowingJob(user: ThinUser, fileId: DriveFile['id']
export function createImportMutingJob(user: ThinUser, fileId: DriveFile['id']) {
return dbQueue.add('importMuting', {
user: user,
fileId: fileId,
user,
fileId,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -209,8 +209,8 @@ export function createImportMutingJob(user: ThinUser, fileId: DriveFile['id']) {
export function createImportBlockingJob(user: ThinUser, fileId: DriveFile['id']) {
return dbQueue.add('importBlocking', {
user: user,
fileId: fileId,
user,
fileId,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -219,8 +219,8 @@ export function createImportBlockingJob(user: ThinUser, fileId: DriveFile['id'])
export function createImportUserListsJob(user: ThinUser, fileId: DriveFile['id']) {
return dbQueue.add('importUserLists', {
user: user,
fileId: fileId,
user,
fileId,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -229,8 +229,8 @@ export function createImportUserListsJob(user: ThinUser, fileId: DriveFile['id']
export function createImportCustomEmojisJob(user: ThinUser, fileId: DriveFile['id']) {
return dbQueue.add('importCustomEmojis', {
user: user,
fileId: fileId,
user,
fileId,
}, {
removeOnComplete: true,
removeOnFail: true,
@ -239,7 +239,7 @@ export function createImportCustomEmojisJob(user: ThinUser, fileId: DriveFile['i
export function createDeleteAccountJob(user: ThinUser, opts: { soft?: boolean; } = {}) {
return dbQueue.add('deleteAccount', {
user: user,
user,
soft: opts.soft,
}, {
removeOnComplete: true,
@ -249,7 +249,7 @@ export function createDeleteAccountJob(user: ThinUser, opts: { soft?: boolean; }
export function createDeleteObjectStorageFileJob(key: string) {
return objectStorageQueue.add('deleteFile', {
key: key,
key,
}, {
removeOnComplete: true,
removeOnFail: true,

View file

@ -76,9 +76,9 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi
}
const content = JSON.stringify({
fileName: fileName,
downloaded: downloaded,
emoji: emoji,
fileName,
downloaded,
emoji,
});
const isFirst = customEmojis.indexOf(emoji) === 0;

View file

@ -109,7 +109,7 @@ function serialize(note: Note, poll: Poll | null = null): Record<string, unknown
fileIds: note.fileIds,
replyId: note.replyId,
renoteId: note.renoteId,
poll: poll,
poll,
cw: note.cw,
visibility: note.visibility,
visibleUserIds: note.visibleUserIds,

View file

@ -102,7 +102,7 @@ export class LdSignature {
const document = await this.fetchDocument(url);
return {
contextUrl: null,
document: document,
document,
documentUrl: url,
};
};

View file

@ -77,8 +77,8 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
resolver: {
history: resolver.getHistory(),
},
value: value,
object: object,
value,
object,
});
throw new Error('invalid note');
}

View file

@ -7,6 +7,6 @@ import { User } from '@/models/entities/user.js';
* @param id Follower|Followee ID
*/
export default async function renderFollowUser(id: User['id']): Promise<any> {
const user = await Users.findOneByOrFail({ id: id });
const user = await Users.findOneByOrFail({ id });
return Users.isLocalUser(user) ? `${config.url}/users/${user.id}` : user.uri;
}

View file

@ -112,9 +112,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
const asPoll = poll ? {
type: 'Question',
content: toHtml(Object.assign({}, note, {
text: text,
})),
content: toHtml(Object.assign({}, note, { text })),
[poll.expiresAt && poll.expiresAt < new Date() ? 'closed' : 'endTime']: poll.expiresAt,
[poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({
type: 'Note',

View file

@ -72,7 +72,7 @@ export async function resolveUser(username: string, host: string | null): Promis
await Users.update({
usernameLower,
host: host,
host,
}, {
uri: self.href,
});

View file

@ -51,7 +51,7 @@ export default async (authorization: string | null | undefined, bodyToken: strin
where: [{
hash: token.toLowerCase(), // app
}, {
token: token, // miauth
token, // miauth
}],
});

View file

@ -2,14 +2,14 @@ import { SelectQueryBuilder } from 'typeorm';
export function makePaginationQuery<T>(q: SelectQueryBuilder<T>, sinceId?: string, untilId?: string, sinceDate?: number, untilDate?: number) {
if (sinceId && untilId) {
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: sinceId });
q.andWhere(`${q.alias}.id < :untilId`, { untilId: untilId });
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId });
q.andWhere(`${q.alias}.id < :untilId`, { untilId });
q.orderBy(`${q.alias}.id`, 'DESC');
} else if (sinceId) {
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: sinceId });
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId });
q.orderBy(`${q.alias}.id`, 'ASC');
} else if (untilId) {
q.andWhere(`${q.alias}.id < :untilId`, { untilId: untilId });
q.andWhere(`${q.alias}.id < :untilId`, { untilId });
q.orderBy(`${q.alias}.id`, 'DESC');
} else if (sinceDate && untilDate) {
q.andWhere(`${q.alias}.createdAt > :sinceDate`, { sinceDate: new Date(sinceDate) });

View file

@ -79,7 +79,7 @@ export async function readGroupMessagingMessage(
// check joined
const joining = await UserGroupJoinings.findOneBy({
userId: userId,
userId,
userGroupId: groupId,
});
@ -111,7 +111,7 @@ export async function readGroupMessagingMessage(
// Publish event
publishGroupMessagingStream(groupId, 'read', {
ids: reads,
userId: userId,
userId,
});
publishMessagingIndexStream(userId, 'read', reads);
@ -122,9 +122,9 @@ export async function readGroupMessagingMessage(
} else {
// そのグループにおいて未読がなければイベント発行
const unreadExist = await MessagingMessages.createQueryBuilder('message')
.where('message.groupId = :groupId', { groupId: groupId })
.andWhere('message.userId != :userId', { userId: userId })
.andWhere('NOT (:userId = ANY(message.reads))', { userId: userId })
.where('message.groupId = :groupId', { groupId })
.andWhere('message.userId != :userId', { userId })
.andWhere('NOT (:userId = ANY(message.reads))', { userId })
.andWhere('message.createdAt > :joinedAt', { joinedAt: joining.createdAt }) // 自分が加入する前の会話については、未読扱いしない
.getOne().then(x => x != null);

View file

@ -81,7 +81,7 @@ export async function signup(opts: {
account = await transactionalEntityManager.save(new User({
id: genId(),
createdAt: new Date(),
username: username,
username,
usernameLower: username.toLowerCase(),
host: toPunyNullable(host),
token: secret,

View file

@ -718,7 +718,7 @@ export interface IEndpoint {
const endpoints: IEndpoint[] = eps.map(([name, ep]) => {
return {
name: name,
name,
exec: ep.default,
meta: ep.meta || {},
params: ep.paramDef,

View file

@ -41,7 +41,7 @@ export default define(meta, paramDef, async (ps, me) => {
const emoji = await Emojis.insert({
id: genId(),
updatedAt: new Date(),
name: name,
name,
category: null,
host: null,
aliases: [],

View file

@ -32,8 +32,6 @@ export default define(meta, paramDef, async (ps, me) => {
await db.queryResultCache!.remove(['meta_emojis']);
insertModerationLog(me, 'deleteEmoji', {
emoji: emoji,
});
insertModerationLog(me, 'deleteEmoji', { emoji });
}
});

View file

@ -37,7 +37,5 @@ export default define(meta, paramDef, async (ps, me) => {
await db.queryResultCache!.remove(['meta_emojis']);
insertModerationLog(me, 'deleteEmoji', {
emoji: emoji,
});
insertModerationLog(me, 'deleteEmoji', { emoji });
});

View file

@ -44,7 +44,7 @@ export default define(meta, paramDef, async (ps, user) => {
description: ps.description,
permission: ps.permission,
callbackUrl: ps.callbackUrl,
secret: secret,
secret,
}).then(x => Apps.findOneByOrFail(x.identifiers[0]));
return await Apps.pack(app, null, {

View file

@ -67,7 +67,7 @@ export default define(meta, paramDef, async (ps, user) => {
appId: session.appId,
userId: user.id,
token: accessToken,
hash: hash,
hash,
});
}

View file

@ -62,7 +62,7 @@ export default define(meta, paramDef, async (ps) => {
id: genId(),
createdAt: new Date(),
appId: app.id,
token: token,
token,
}).then(x => AuthSessions.findOneByOrFail(x.identifiers[0]));
return {

View file

@ -40,6 +40,6 @@ export default define(meta, paramDef, async (ps, user) => {
return {
capacity: 1024 * 1024 * instance.localDriveCapacityMb,
usage: usage,
usage,
};
});

View file

@ -29,7 +29,7 @@ export default define(meta, paramDef, async (ps, user) => {
const verified = (speakeasy as any).totp.verify({
secret: profile.twoFactorTempSecret,
encoding: 'base32',
token: token,
token,
});
if (!verified) {

View file

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

View file

@ -274,7 +274,7 @@ export default define(meta, paramDef, async (ps, user) => {
// 投稿を作成
const note = await create(user, {
createdAt: new Date(),
files: files,
files,
poll: ps.poll ? {
choices: ps.poll.choices,
multiple: ps.poll.multiple || false,

View file

@ -71,7 +71,7 @@ export default define(meta, paramDef, async (ps, me) => {
.andWhere('user.usernameLower LIKE :username', { username: ps.username.toLowerCase() + '%' })
.andWhere(new Brackets(qb => { qb
.where('user.updatedAt IS NULL')
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
}));
query.setParameters(followingQuery.getParameters());

View file

@ -46,7 +46,7 @@ export default define(meta, paramDef, async (ps, me) => {
.where('user.usernameLower LIKE :username', { username: ps.query.replace('@', '').toLowerCase() + '%' })
.andWhere(new Brackets(qb => { qb
.where('user.updatedAt IS NULL')
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
}))
.andWhere('user.isSuspended = FALSE');
@ -73,7 +73,7 @@ export default define(meta, paramDef, async (ps, me) => {
}))
.andWhere(new Brackets(qb => { qb
.where('user.updatedAt IS NULL')
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
}))
.andWhere('user.isSuspended = FALSE');
@ -104,7 +104,7 @@ export default define(meta, paramDef, async (ps, me) => {
.where(`user.id IN (${ profQuery.getQuery() })`)
.andWhere(new Brackets(qb => { qb
.where('user.updatedAt IS NULL')
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
}))
.andWhere('user.isSuspended = FALSE')
.setParameters(profQuery.getParameters());

View file

@ -25,7 +25,7 @@ export function genOpenapiSpec() {
paths: {} as any,
components: {
schemas: schemas,
schemas,
securitySchemes: {
ApiKeyAuth: {

View file

@ -118,7 +118,7 @@ export default async (ctx: Koa.Context) => {
const verified = (speakeasy as any).totp.verify({
secret: profile.twoFactorSecret,
encoding: 'base32',
token: token,
token,
window: 2,
});

View file

@ -80,7 +80,7 @@ export default async (ctx: Koa.Context) => {
createdAt: new Date(),
code,
email: emailAddress,
username: username,
username,
password: hash,
});

View file

@ -184,7 +184,7 @@ router.get('/dc/cb', async ctx => {
}
const profile = await UserProfiles.createQueryBuilder()
.where('"integrations"->\'discord\'->>\'id\' = :id', { id: id })
.where('"integrations"->\'discord\'->>\'id\' = :id', { id })
.andWhere('"userHost" IS NULL')
.getOne();
@ -197,12 +197,12 @@ router.get('/dc/cb', async ctx => {
integrations: {
...profile.integrations,
discord: {
id: id,
accessToken: accessToken,
refreshToken: refreshToken,
expiresDate: expiresDate,
username: username,
discriminator: discriminator,
id,
accessToken,
refreshToken,
expiresDate,
username,
discriminator,
},
},
});
@ -264,12 +264,12 @@ router.get('/dc/cb', async ctx => {
integrations: {
...profile.integrations,
discord: {
accessToken: accessToken,
refreshToken: refreshToken,
expiresDate: expiresDate,
id: id,
username: username,
discriminator: discriminator,
accessToken,
refreshToken,
expiresDate,
id,
username,
discriminator,
},
},
});

View file

@ -176,7 +176,7 @@ router.get('/gh/cb', async ctx => {
}
const link = await UserProfiles.createQueryBuilder()
.where('"integrations"->\'github\'->>\'id\' = :id', { id: id })
.where('"integrations"->\'github\'->>\'id\' = :id', { id })
.andWhere('"userHost" IS NULL')
.getOne();
@ -239,9 +239,9 @@ router.get('/gh/cb', async ctx => {
integrations: {
...profile.integrations,
github: {
accessToken: accessToken,
id: id,
login: login,
accessToken,
id,
login,
},
},
});

View file

@ -53,8 +53,8 @@ export default abstract class Channel {
this.connection.sendMessageToWs('channel', {
id: this.id,
type: type,
body: body,
type,
body,
});
}

View file

@ -244,7 +244,7 @@ export default class Connection {
*/
public sendMessageToWs(type: string, payload: any) {
this.wsConnection.send(JSON.stringify({
type: type,
type,
body: payload,
}));
}
@ -267,9 +267,7 @@ export default class Connection {
ch.init(params);
if (pong) {
this.sendMessageToWs('connected', {
id: id,
});
this.sendMessageToWs('connected', { id });
}
}

View file

@ -479,7 +479,7 @@ router.get('/_info_card_', async ctx => {
await ctx.render('info-card', {
version: config.version,
host: config.host,
meta: meta,
meta,
originalUsersCount: await Users.countBy({ host: IsNull() }),
originalNotesCount: await Notes.countBy({ userHost: IsNull() }),
});

View file

@ -29,7 +29,7 @@ export const urlPreviewHandler = async (ctx: Koa.Context) => {
try {
const summary = meta.summalyProxy ? await getJson(`${meta.summalyProxy}?${query({
url: url,
url,
lang: lang ?? 'ja-JP',
})}`) : await summaly.default(url, {
followRedirects: false,

View file

@ -14,7 +14,7 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: {
id: genId(),
antennaId: antenna.id,
noteId: note.id,
read: read,
read,
});
publishAntennaStream(antenna.id, 'note', note);

View file

@ -79,11 +79,11 @@ export default class FederationChart extends Chart<typeof schema> {
]);
return {
'sub': sub,
'pub': pub,
'pubsub': pubsub,
'subActive': subActive,
'pubActive': pubActive,
sub,
pub,
pubsub,
subActive,
pubActive,
};
}

View file

@ -266,9 +266,7 @@ export default abstract class Chart<T extends Schema> {
new Error('not happen') as never;
return repository.findOne({
where: group ? {
group: group,
} : {},
where: group ? { group } : {},
order: {
date: -1,
},
@ -294,7 +292,7 @@ export default abstract class Chart<T extends Schema> {
// 現在(=今のHour or Day)のログ
const currentLog = await repository.findOneBy({
date: Chart.dateToTimestamp(current),
...(group ? { group: group } : {}),
...(group ? { group } : {}),
}) as RawRecord<T> | undefined;
// ログがあればそれを返して終了
@ -333,8 +331,8 @@ export default abstract class Chart<T extends Schema> {
try {
// ロック内でもう1回チェックする
const currentLog = await repository.findOneBy({
date: date,
...(group ? { group: group } : {}),
date,
...(group ? { group } : {}),
}) as RawRecord<T> | undefined;
// ログがあればそれを返して終了
@ -348,8 +346,8 @@ export default abstract class Chart<T extends Schema> {
// 新規ログ挿入
log = await repository.insert({
date: date,
...(group ? { group: group } : {}),
date,
...(group ? { group } : {}),
...columns,
}).then(x => repository.findOneByOrFail(x.identifiers[0])) as RawRecord<T>;
@ -582,7 +580,7 @@ export default abstract class Chart<T extends Schema> {
let logs = await repository.find({
where: {
date: Between(Chart.dateToTimestamp(gt), Chart.dateToTimestamp(lt)),
...(group ? { group: group } : {}),
...(group ? { group } : {}),
},
order: {
date: -1,
@ -594,9 +592,7 @@ export default abstract class Chart<T extends Schema> {
// もっとも新しいログを持ってくる
// (すくなくともひとつログが無いと隙間埋めできないため)
const recentLog = await repository.findOne({
where: group ? {
group: group,
} : {},
where: group ? { group } : {},
order: {
date: -1,
},
@ -613,7 +609,7 @@ export default abstract class Chart<T extends Schema> {
const outdatedLog = await repository.findOne({
where: {
date: LessThan(Chart.dateToTimestamp(gt)),
...(group ? { group: group } : {}),
...(group ? { group } : {}),
},
order: {
date: -1,

View file

@ -23,8 +23,8 @@ export async function createNotification(
const notification = await Notifications.insert({
id: genId(),
createdAt: new Date(),
notifieeId: notifieeId,
type: type,
notifieeId,
type,
// 相手がこの通知をミュートしているようなら、既読を予めつけておく
isRead: isMuted,
...data,

View file

@ -36,7 +36,7 @@ export async function createSystemUser(username: string) {
account = await transactionalEntityManager.insert(User, {
id: genId(),
createdAt: new Date(),
username: username,
username,
usernameLower: username.toLowerCase(),
host: null,
token: secret,

View file

@ -54,8 +54,8 @@ export async function uploadFromUrl({
return driveFile!;
} catch (e) {
logger.error(`Failed to create drive file: ${e}`, {
url: url,
e: e,
url,
e,
});
throw e;
} finally {

View file

@ -7,7 +7,7 @@ export async function insertModerationLog(moderator: { id: User['id'] }, type: s
id: genId(),
createdAt: new Date(),
userId: moderator.id,
type: type,
type,
info: info || {},
});
}

View file

@ -22,7 +22,7 @@ export default class Logger {
constructor(domain: string, color?: string, store = true) {
this.domain = {
name: domain,
color: color,
color,
};
this.store = store;

View file

@ -72,7 +72,7 @@ class NotificationManager {
}
} else {
this.queue.push({
reason: reason,
reason,
target: notifiee,
});
}

View file

@ -35,9 +35,7 @@ export default async function(user: { id: User['id']; uri: User['uri']; host: Us
}
if (!quiet) {
publishNoteStream(note.id, 'deleted', {
deletedAt: deletedAt,
});
publishNoteStream(note.id, 'deleted', { deletedAt });
//#region ローカルの投稿なら削除アクティビティを配送
if (Users.isLocalUser(user) && !note.localOnly) {

View file

@ -45,7 +45,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) {
createdAt: new Date(),
noteId: note.id,
userId: user.id,
choice: choice,
choice,
});
// Increment votes count
@ -53,7 +53,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) {
await Polls.query(`UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE "noteId" = '${poll.noteId}'`);
publishNoteStream(note.id, 'pollVoted', {
choice: choice,
choice,
userId: user.id,
});
@ -61,7 +61,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) {
createNotification(note.userId, 'pollVote', {
notifierId: user.id,
noteId: note.id,
choice: choice,
choice,
});
// Fetch watchers
@ -74,7 +74,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) {
createNotification(watcher.userId, 'pollVote', {
notifierId: user.id,
noteId: note.id,
choice: choice,
choice,
});
}
});

View file

@ -103,7 +103,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
createNotification(note.userId, 'reaction', {
notifierId: user.id,
noteId: note.id,
reaction: reaction,
reaction,
});
}
@ -116,7 +116,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
createNotification(watcher.userId, 'reaction', {
notifierId: user.id,
noteId: note.id,
reaction: reaction,
reaction,
});
}
});

View file

@ -62,14 +62,14 @@ export default async function(
if ((readMentions.length > 0) || (readSpecifiedNotes.length > 0) || (readChannelNotes.length > 0)) {
// Remove the record
await NoteUnreads.delete({
userId: userId,
userId,
noteId: In([...readMentions.map(n => n.id), ...readSpecifiedNotes.map(n => n.id), ...readChannelNotes.map(n => n.id)]),
});
// TODO: ↓まとめてクエリしたい
NoteUnreads.countBy({
userId: userId,
userId,
isMentioned: true,
}).then(mentionsCount => {
if (mentionsCount === 0) {
@ -79,7 +79,7 @@ export default async function(
});
NoteUnreads.countBy({
userId: userId,
userId,
isSpecified: true,
}).then(specifiedCount => {
if (specifiedCount === 0) {
@ -89,7 +89,7 @@ export default async function(
});
NoteUnreads.countBy({
userId: userId,
userId,
noteChannelId: Not(IsNull()),
}).then(channelNoteCount => {
if (channelNoteCount === 0) {

View file

@ -19,7 +19,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: {
// スレッドミュート
const threadMute = await NoteThreadMutings.findOneBy({
userId: userId,
userId,
threadId: note.threadId || note.id,
});
if (threadMute) return;
@ -27,7 +27,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: {
const unread = {
id: genId(),
noteId: note.id,
userId: userId,
userId,
isSpecified: params.isSpecified,
isMentioned: params.isMentioned,
noteChannelId: note.channelId,

View file

@ -47,9 +47,7 @@ export async function pushNotification<T extends keyof pushNotificationsTypes>(u
meta.swPrivateKey);
// Fetch
const subscriptions = await SwSubscriptions.findBy({
userId: userId,
});
const subscriptions = await SwSubscriptions.findBy({ userId });
for (const subscription of subscriptions) {
const pushSubscription = {
@ -73,7 +71,7 @@ export async function pushNotification<T extends keyof pushNotificationsTypes>(u
if (err.statusCode === 410) {
SwSubscriptions.delete({
userId: userId,
userId,
endpoint: subscription.endpoint,
auth: subscription.auth,
publickey: subscription.publickey,

View file

@ -29,9 +29,9 @@ export async function sendEmail(to: string, subject: string, html: string, text:
// TODO: htmlサニタイズ
const info = await transporter.sendMail({
from: meta.email!,
to: to,
subject: subject,
text: text,
to,
subject,
text,
html: `<!doctype html>
<html>
<head>

View file

@ -26,12 +26,12 @@ import {
class Publisher {
private publish = (channel: StreamChannels, type: string | null, value?: any): void => {
const message = type == null ? value : value == null ?
{ type: type, body: null } :
{ type: type, body: value };
{ type, body: null } :
{ type, body: value };
redisClient.publish(config.host, JSON.stringify({
channel: channel,
message: message,
channel,
message,
}));
};

View file

@ -77,6 +77,6 @@ module.exports = {
'import/order': ['warn', {
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
}],
'object-shorthand': ['warn', 'consistent-as-needed'],
'object-shorthand': ['warn', 'always'],
},
};