fix lint "object-shorthand"
This commit is contained in:
parent
37e47a257e
commit
c8f49bae76
57 changed files with 140 additions and 156 deletions
|
@ -202,7 +202,7 @@ export const db = new DataSource({
|
||||||
logging: log,
|
logging: log,
|
||||||
logger: log ? new MyCustomLogger() : undefined,
|
logger: log ? new MyCustomLogger() : undefined,
|
||||||
maxQueryExecutionTime: 300,
|
maxQueryExecutionTime: 300,
|
||||||
entities: entities,
|
entities,
|
||||||
migrations: ['../../migration/*.js'],
|
migrations: ['../../migration/*.js'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,5 @@ import { Cache } from './cache.js';
|
||||||
const cache = new Cache<UserKeypair>(Infinity);
|
const cache = new Cache<UserKeypair>(Infinity);
|
||||||
|
|
||||||
export async function getUserKeypair(userId: User['id']): Promise<UserKeypair> {
|
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 }));
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ export const DriveFileRepository = db.getRepository(DriveFile).extend({
|
||||||
|
|
||||||
const { sum } = await this
|
const { sum } = await this
|
||||||
.createQueryBuilder('file')
|
.createQueryBuilder('file')
|
||||||
.where('file.userId = :id', { id: id })
|
.where('file.userId = :id', { id })
|
||||||
.andWhere('file.isLink = FALSE')
|
.andWhere('file.isLink = FALSE')
|
||||||
.select('SUM(file.size)', 'sum')
|
.select('SUM(file.size)', 'sum')
|
||||||
.getRawOne();
|
.getRawOne();
|
||||||
|
|
|
@ -172,7 +172,7 @@ export const NoteRepository = db.getRepository(Note).extend({
|
||||||
user: Users.pack(note.user ?? note.userId, me, {
|
user: Users.pack(note.user ?? note.userId, me, {
|
||||||
detail: false,
|
detail: false,
|
||||||
}),
|
}),
|
||||||
text: text,
|
text,
|
||||||
cw: note.cw,
|
cw: note.cw,
|
||||||
visibility: note.visibility,
|
visibility: note.visibility,
|
||||||
localOnly: note.localOnly || undefined,
|
localOnly: note.localOnly || undefined,
|
||||||
|
|
|
@ -120,12 +120,12 @@ export const UserRepository = db.getRepository(User).extend({
|
||||||
muterId: userId,
|
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')
|
const groupQs = Promise.all(joinings.map(j => MessagingMessages.createQueryBuilder('message')
|
||||||
.where('message.groupId = :groupId', { groupId: j.userGroupId })
|
.where('message.groupId = :groupId', { groupId: j.userGroupId })
|
||||||
.andWhere('message.userId != :userId', { userId: userId })
|
.andWhere('message.userId != :userId', { userId })
|
||||||
.andWhere('NOT (:userId = ANY(message.reads))', { userId: userId })
|
.andWhere('NOT (:userId = ANY(message.reads))', { userId })
|
||||||
.andWhere('message.createdAt > :joinedAt', { joinedAt: j.createdAt }) // 自分が加入する前の会話については、未読扱いしない
|
.andWhere('message.createdAt > :joinedAt', { joinedAt: j.createdAt }) // 自分が加入する前の会話については、未読扱いしない
|
||||||
.getOne().then(x => x != null)));
|
.getOne().then(x => x != null)));
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ export const UserRepository = db.getRepository(User).extend({
|
||||||
|
|
||||||
async getHasUnreadAnnouncement(userId: User['id']): Promise<boolean> {
|
async getHasUnreadAnnouncement(userId: User['id']): Promise<boolean> {
|
||||||
const reads = await AnnouncementReads.findBy({
|
const reads = await AnnouncementReads.findBy({
|
||||||
userId: userId,
|
userId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const count = await Announcements.countBy(reads.length > 0 ? {
|
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 channels = await ChannelFollowings.findBy({ followerId: userId });
|
||||||
|
|
||||||
const unread = channels.length > 0 ? await NoteUnreads.findOneBy({
|
const unread = channels.length > 0 ? await NoteUnreads.findOneBy({
|
||||||
userId: userId,
|
userId,
|
||||||
noteChannelId: In(channels.map(x => x.followeeId)),
|
noteChannelId: In(channels.map(x => x.followeeId)),
|
||||||
}) : null;
|
}) : null;
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ export function deliver(user: ThinUser, content: unknown, to: string | null) {
|
||||||
|
|
||||||
export function inbox(activity: IActivity, signature: httpSignature.IParsedSignature) {
|
export function inbox(activity: IActivity, signature: httpSignature.IParsedSignature) {
|
||||||
const data = {
|
const data = {
|
||||||
activity: activity,
|
activity,
|
||||||
signature,
|
signature,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ export function inbox(activity: IActivity, signature: httpSignature.IParsedSigna
|
||||||
|
|
||||||
export function createDeleteDriveFilesJob(user: ThinUser) {
|
export function createDeleteDriveFilesJob(user: ThinUser) {
|
||||||
return dbQueue.add('deleteDriveFiles', {
|
return dbQueue.add('deleteDriveFiles', {
|
||||||
user: user,
|
user,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -133,7 +133,7 @@ export function createDeleteDriveFilesJob(user: ThinUser) {
|
||||||
|
|
||||||
export function createExportCustomEmojisJob(user: ThinUser) {
|
export function createExportCustomEmojisJob(user: ThinUser) {
|
||||||
return dbQueue.add('exportCustomEmojis', {
|
return dbQueue.add('exportCustomEmojis', {
|
||||||
user: user,
|
user,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -142,7 +142,7 @@ export function createExportCustomEmojisJob(user: ThinUser) {
|
||||||
|
|
||||||
export function createExportNotesJob(user: ThinUser) {
|
export function createExportNotesJob(user: ThinUser) {
|
||||||
return dbQueue.add('exportNotes', {
|
return dbQueue.add('exportNotes', {
|
||||||
user: user,
|
user,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -151,7 +151,7 @@ export function createExportNotesJob(user: ThinUser) {
|
||||||
|
|
||||||
export function createExportFollowingJob(user: ThinUser, excludeMuting = false, excludeInactive = false) {
|
export function createExportFollowingJob(user: ThinUser, excludeMuting = false, excludeInactive = false) {
|
||||||
return dbQueue.add('exportFollowing', {
|
return dbQueue.add('exportFollowing', {
|
||||||
user: user,
|
user,
|
||||||
excludeMuting,
|
excludeMuting,
|
||||||
excludeInactive,
|
excludeInactive,
|
||||||
}, {
|
}, {
|
||||||
|
@ -162,7 +162,7 @@ export function createExportFollowingJob(user: ThinUser, excludeMuting = false,
|
||||||
|
|
||||||
export function createExportMuteJob(user: ThinUser) {
|
export function createExportMuteJob(user: ThinUser) {
|
||||||
return dbQueue.add('exportMute', {
|
return dbQueue.add('exportMute', {
|
||||||
user: user,
|
user,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -171,7 +171,7 @@ export function createExportMuteJob(user: ThinUser) {
|
||||||
|
|
||||||
export function createExportBlockingJob(user: ThinUser) {
|
export function createExportBlockingJob(user: ThinUser) {
|
||||||
return dbQueue.add('exportBlocking', {
|
return dbQueue.add('exportBlocking', {
|
||||||
user: user,
|
user,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -180,7 +180,7 @@ export function createExportBlockingJob(user: ThinUser) {
|
||||||
|
|
||||||
export function createExportUserListsJob(user: ThinUser) {
|
export function createExportUserListsJob(user: ThinUser) {
|
||||||
return dbQueue.add('exportUserLists', {
|
return dbQueue.add('exportUserLists', {
|
||||||
user: user,
|
user,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -189,8 +189,8 @@ export function createExportUserListsJob(user: ThinUser) {
|
||||||
|
|
||||||
export function createImportFollowingJob(user: ThinUser, fileId: DriveFile['id']) {
|
export function createImportFollowingJob(user: ThinUser, fileId: DriveFile['id']) {
|
||||||
return dbQueue.add('importFollowing', {
|
return dbQueue.add('importFollowing', {
|
||||||
user: user,
|
user,
|
||||||
fileId: fileId,
|
fileId,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -199,8 +199,8 @@ export function createImportFollowingJob(user: ThinUser, fileId: DriveFile['id']
|
||||||
|
|
||||||
export function createImportMutingJob(user: ThinUser, fileId: DriveFile['id']) {
|
export function createImportMutingJob(user: ThinUser, fileId: DriveFile['id']) {
|
||||||
return dbQueue.add('importMuting', {
|
return dbQueue.add('importMuting', {
|
||||||
user: user,
|
user,
|
||||||
fileId: fileId,
|
fileId,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -209,8 +209,8 @@ export function createImportMutingJob(user: ThinUser, fileId: DriveFile['id']) {
|
||||||
|
|
||||||
export function createImportBlockingJob(user: ThinUser, fileId: DriveFile['id']) {
|
export function createImportBlockingJob(user: ThinUser, fileId: DriveFile['id']) {
|
||||||
return dbQueue.add('importBlocking', {
|
return dbQueue.add('importBlocking', {
|
||||||
user: user,
|
user,
|
||||||
fileId: fileId,
|
fileId,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -219,8 +219,8 @@ export function createImportBlockingJob(user: ThinUser, fileId: DriveFile['id'])
|
||||||
|
|
||||||
export function createImportUserListsJob(user: ThinUser, fileId: DriveFile['id']) {
|
export function createImportUserListsJob(user: ThinUser, fileId: DriveFile['id']) {
|
||||||
return dbQueue.add('importUserLists', {
|
return dbQueue.add('importUserLists', {
|
||||||
user: user,
|
user,
|
||||||
fileId: fileId,
|
fileId,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -229,8 +229,8 @@ export function createImportUserListsJob(user: ThinUser, fileId: DriveFile['id']
|
||||||
|
|
||||||
export function createImportCustomEmojisJob(user: ThinUser, fileId: DriveFile['id']) {
|
export function createImportCustomEmojisJob(user: ThinUser, fileId: DriveFile['id']) {
|
||||||
return dbQueue.add('importCustomEmojis', {
|
return dbQueue.add('importCustomEmojis', {
|
||||||
user: user,
|
user,
|
||||||
fileId: fileId,
|
fileId,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
@ -239,7 +239,7 @@ export function createImportCustomEmojisJob(user: ThinUser, fileId: DriveFile['i
|
||||||
|
|
||||||
export function createDeleteAccountJob(user: ThinUser, opts: { soft?: boolean; } = {}) {
|
export function createDeleteAccountJob(user: ThinUser, opts: { soft?: boolean; } = {}) {
|
||||||
return dbQueue.add('deleteAccount', {
|
return dbQueue.add('deleteAccount', {
|
||||||
user: user,
|
user,
|
||||||
soft: opts.soft,
|
soft: opts.soft,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
|
@ -249,7 +249,7 @@ export function createDeleteAccountJob(user: ThinUser, opts: { soft?: boolean; }
|
||||||
|
|
||||||
export function createDeleteObjectStorageFileJob(key: string) {
|
export function createDeleteObjectStorageFileJob(key: string) {
|
||||||
return objectStorageQueue.add('deleteFile', {
|
return objectStorageQueue.add('deleteFile', {
|
||||||
key: key,
|
key,
|
||||||
}, {
|
}, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
|
|
|
@ -76,9 +76,9 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = JSON.stringify({
|
const content = JSON.stringify({
|
||||||
fileName: fileName,
|
fileName,
|
||||||
downloaded: downloaded,
|
downloaded,
|
||||||
emoji: emoji,
|
emoji,
|
||||||
});
|
});
|
||||||
const isFirst = customEmojis.indexOf(emoji) === 0;
|
const isFirst = customEmojis.indexOf(emoji) === 0;
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ function serialize(note: Note, poll: Poll | null = null): Record<string, unknown
|
||||||
fileIds: note.fileIds,
|
fileIds: note.fileIds,
|
||||||
replyId: note.replyId,
|
replyId: note.replyId,
|
||||||
renoteId: note.renoteId,
|
renoteId: note.renoteId,
|
||||||
poll: poll,
|
poll,
|
||||||
cw: note.cw,
|
cw: note.cw,
|
||||||
visibility: note.visibility,
|
visibility: note.visibility,
|
||||||
visibleUserIds: note.visibleUserIds,
|
visibleUserIds: note.visibleUserIds,
|
||||||
|
|
|
@ -102,7 +102,7 @@ export class LdSignature {
|
||||||
const document = await this.fetchDocument(url);
|
const document = await this.fetchDocument(url);
|
||||||
return {
|
return {
|
||||||
contextUrl: null,
|
contextUrl: null,
|
||||||
document: document,
|
document,
|
||||||
documentUrl: url,
|
documentUrl: url,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,8 +77,8 @@ export async function createNote(value: string | IObject, resolver?: Resolver, s
|
||||||
resolver: {
|
resolver: {
|
||||||
history: resolver.getHistory(),
|
history: resolver.getHistory(),
|
||||||
},
|
},
|
||||||
value: value,
|
value,
|
||||||
object: object,
|
object,
|
||||||
});
|
});
|
||||||
throw new Error('invalid note');
|
throw new Error('invalid note');
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,6 @@ import { User } from '@/models/entities/user.js';
|
||||||
* @param id Follower|Followee ID
|
* @param id Follower|Followee ID
|
||||||
*/
|
*/
|
||||||
export default async function renderFollowUser(id: User['id']): Promise<any> {
|
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;
|
return Users.isLocalUser(user) ? `${config.url}/users/${user.id}` : user.uri;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,9 +112,7 @@ export default async function renderNote(note: Note, dive = true, isTalk = false
|
||||||
|
|
||||||
const asPoll = poll ? {
|
const asPoll = poll ? {
|
||||||
type: 'Question',
|
type: 'Question',
|
||||||
content: toHtml(Object.assign({}, note, {
|
content: toHtml(Object.assign({}, note, { text })),
|
||||||
text: text,
|
|
||||||
})),
|
|
||||||
[poll.expiresAt && poll.expiresAt < new Date() ? 'closed' : 'endTime']: poll.expiresAt,
|
[poll.expiresAt && poll.expiresAt < new Date() ? 'closed' : 'endTime']: poll.expiresAt,
|
||||||
[poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({
|
[poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
|
|
|
@ -72,7 +72,7 @@ export async function resolveUser(username: string, host: string | null): Promis
|
||||||
|
|
||||||
await Users.update({
|
await Users.update({
|
||||||
usernameLower,
|
usernameLower,
|
||||||
host: host,
|
host,
|
||||||
}, {
|
}, {
|
||||||
uri: self.href,
|
uri: self.href,
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,7 +51,7 @@ export default async (authorization: string | null | undefined, bodyToken: strin
|
||||||
where: [{
|
where: [{
|
||||||
hash: token.toLowerCase(), // app
|
hash: token.toLowerCase(), // app
|
||||||
}, {
|
}, {
|
||||||
token: token, // miauth
|
token, // miauth
|
||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ import { SelectQueryBuilder } from 'typeorm';
|
||||||
|
|
||||||
export function makePaginationQuery<T>(q: SelectQueryBuilder<T>, sinceId?: string, untilId?: string, sinceDate?: number, untilDate?: number) {
|
export function makePaginationQuery<T>(q: SelectQueryBuilder<T>, sinceId?: string, untilId?: string, sinceDate?: number, untilDate?: number) {
|
||||||
if (sinceId && untilId) {
|
if (sinceId && untilId) {
|
||||||
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: sinceId });
|
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId });
|
||||||
q.andWhere(`${q.alias}.id < :untilId`, { untilId: untilId });
|
q.andWhere(`${q.alias}.id < :untilId`, { untilId });
|
||||||
q.orderBy(`${q.alias}.id`, 'DESC');
|
q.orderBy(`${q.alias}.id`, 'DESC');
|
||||||
} else if (sinceId) {
|
} else if (sinceId) {
|
||||||
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId: sinceId });
|
q.andWhere(`${q.alias}.id > :sinceId`, { sinceId });
|
||||||
q.orderBy(`${q.alias}.id`, 'ASC');
|
q.orderBy(`${q.alias}.id`, 'ASC');
|
||||||
} else if (untilId) {
|
} else if (untilId) {
|
||||||
q.andWhere(`${q.alias}.id < :untilId`, { untilId: untilId });
|
q.andWhere(`${q.alias}.id < :untilId`, { untilId });
|
||||||
q.orderBy(`${q.alias}.id`, 'DESC');
|
q.orderBy(`${q.alias}.id`, 'DESC');
|
||||||
} else if (sinceDate && untilDate) {
|
} else if (sinceDate && untilDate) {
|
||||||
q.andWhere(`${q.alias}.createdAt > :sinceDate`, { sinceDate: new Date(sinceDate) });
|
q.andWhere(`${q.alias}.createdAt > :sinceDate`, { sinceDate: new Date(sinceDate) });
|
||||||
|
|
|
@ -79,7 +79,7 @@ export async function readGroupMessagingMessage(
|
||||||
|
|
||||||
// check joined
|
// check joined
|
||||||
const joining = await UserGroupJoinings.findOneBy({
|
const joining = await UserGroupJoinings.findOneBy({
|
||||||
userId: userId,
|
userId,
|
||||||
userGroupId: groupId,
|
userGroupId: groupId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ export async function readGroupMessagingMessage(
|
||||||
// Publish event
|
// Publish event
|
||||||
publishGroupMessagingStream(groupId, 'read', {
|
publishGroupMessagingStream(groupId, 'read', {
|
||||||
ids: reads,
|
ids: reads,
|
||||||
userId: userId,
|
userId,
|
||||||
});
|
});
|
||||||
publishMessagingIndexStream(userId, 'read', reads);
|
publishMessagingIndexStream(userId, 'read', reads);
|
||||||
|
|
||||||
|
@ -122,9 +122,9 @@ export async function readGroupMessagingMessage(
|
||||||
} else {
|
} else {
|
||||||
// そのグループにおいて未読がなければイベント発行
|
// そのグループにおいて未読がなければイベント発行
|
||||||
const unreadExist = await MessagingMessages.createQueryBuilder('message')
|
const unreadExist = await MessagingMessages.createQueryBuilder('message')
|
||||||
.where('message.groupId = :groupId', { groupId: groupId })
|
.where('message.groupId = :groupId', { groupId })
|
||||||
.andWhere('message.userId != :userId', { userId: userId })
|
.andWhere('message.userId != :userId', { userId })
|
||||||
.andWhere('NOT (:userId = ANY(message.reads))', { userId: userId })
|
.andWhere('NOT (:userId = ANY(message.reads))', { userId })
|
||||||
.andWhere('message.createdAt > :joinedAt', { joinedAt: joining.createdAt }) // 自分が加入する前の会話については、未読扱いしない
|
.andWhere('message.createdAt > :joinedAt', { joinedAt: joining.createdAt }) // 自分が加入する前の会話については、未読扱いしない
|
||||||
.getOne().then(x => x != null);
|
.getOne().then(x => x != null);
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ export async function signup(opts: {
|
||||||
account = await transactionalEntityManager.save(new User({
|
account = await transactionalEntityManager.save(new User({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
username: username,
|
username,
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
host: toPunyNullable(host),
|
host: toPunyNullable(host),
|
||||||
token: secret,
|
token: secret,
|
||||||
|
|
|
@ -718,7 +718,7 @@ export interface IEndpoint {
|
||||||
|
|
||||||
const endpoints: IEndpoint[] = eps.map(([name, ep]) => {
|
const endpoints: IEndpoint[] = eps.map(([name, ep]) => {
|
||||||
return {
|
return {
|
||||||
name: name,
|
name,
|
||||||
exec: ep.default,
|
exec: ep.default,
|
||||||
meta: ep.meta || {},
|
meta: ep.meta || {},
|
||||||
params: ep.paramDef,
|
params: ep.paramDef,
|
||||||
|
|
|
@ -41,7 +41,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
const emoji = await Emojis.insert({
|
const emoji = await Emojis.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
name: name,
|
name,
|
||||||
category: null,
|
category: null,
|
||||||
host: null,
|
host: null,
|
||||||
aliases: [],
|
aliases: [],
|
||||||
|
|
|
@ -32,8 +32,6 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
|
|
||||||
await db.queryResultCache!.remove(['meta_emojis']);
|
await db.queryResultCache!.remove(['meta_emojis']);
|
||||||
|
|
||||||
insertModerationLog(me, 'deleteEmoji', {
|
insertModerationLog(me, 'deleteEmoji', { emoji });
|
||||||
emoji: emoji,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,7 +37,5 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
|
|
||||||
await db.queryResultCache!.remove(['meta_emojis']);
|
await db.queryResultCache!.remove(['meta_emojis']);
|
||||||
|
|
||||||
insertModerationLog(me, 'deleteEmoji', {
|
insertModerationLog(me, 'deleteEmoji', { emoji });
|
||||||
emoji: emoji,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,7 +44,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
description: ps.description,
|
description: ps.description,
|
||||||
permission: ps.permission,
|
permission: ps.permission,
|
||||||
callbackUrl: ps.callbackUrl,
|
callbackUrl: ps.callbackUrl,
|
||||||
secret: secret,
|
secret,
|
||||||
}).then(x => Apps.findOneByOrFail(x.identifiers[0]));
|
}).then(x => Apps.findOneByOrFail(x.identifiers[0]));
|
||||||
|
|
||||||
return await Apps.pack(app, null, {
|
return await Apps.pack(app, null, {
|
||||||
|
|
|
@ -67,7 +67,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
appId: session.appId,
|
appId: session.appId,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
token: accessToken,
|
token: accessToken,
|
||||||
hash: hash,
|
hash,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default define(meta, paramDef, async (ps) => {
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
appId: app.id,
|
appId: app.id,
|
||||||
token: token,
|
token,
|
||||||
}).then(x => AuthSessions.findOneByOrFail(x.identifiers[0]));
|
}).then(x => AuthSessions.findOneByOrFail(x.identifiers[0]));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -40,6 +40,6 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
capacity: 1024 * 1024 * instance.localDriveCapacityMb,
|
capacity: 1024 * 1024 * instance.localDriveCapacityMb,
|
||||||
usage: usage,
|
usage,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
const verified = (speakeasy as any).totp.verify({
|
const verified = (speakeasy as any).totp.verify({
|
||||||
secret: profile.twoFactorTempSecret,
|
secret: profile.twoFactorTempSecret,
|
||||||
encoding: 'base32',
|
encoding: 'base32',
|
||||||
token: token,
|
token,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!verified) {
|
if (!verified) {
|
||||||
|
|
|
@ -55,10 +55,10 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
.orderBy('message.createdAt', 'DESC');
|
.orderBy('message.createdAt', 'DESC');
|
||||||
|
|
||||||
if (ps.group) {
|
if (ps.group) {
|
||||||
query.where('message.groupId IN (:...groups)', { groups: groups });
|
query.where('message.groupId IN (:...groups)', { groups });
|
||||||
|
|
||||||
if (found.length > 0) {
|
if (found.length > 0) {
|
||||||
query.andWhere('message.groupId NOT IN (:...found)', { found: found });
|
query.andWhere('message.groupId NOT IN (:...found)', { found });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
query.where(new Brackets(qb => { qb
|
query.where(new Brackets(qb => { qb
|
||||||
|
@ -68,8 +68,8 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
query.andWhere('message.groupId IS NULL');
|
query.andWhere('message.groupId IS NULL');
|
||||||
|
|
||||||
if (found.length > 0) {
|
if (found.length > 0) {
|
||||||
query.andWhere('message.userId NOT IN (:...found)', { found: found });
|
query.andWhere('message.userId NOT IN (:...found)', { found });
|
||||||
query.andWhere('message.recipientId NOT IN (:...found)', { found: found });
|
query.andWhere('message.recipientId NOT IN (:...found)', { found });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mute.length > 0) {
|
if (mute.length > 0) {
|
||||||
|
|
|
@ -274,7 +274,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
// 投稿を作成
|
// 投稿を作成
|
||||||
const note = await create(user, {
|
const note = await create(user, {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
files: files,
|
files,
|
||||||
poll: ps.poll ? {
|
poll: ps.poll ? {
|
||||||
choices: ps.poll.choices,
|
choices: ps.poll.choices,
|
||||||
multiple: ps.poll.multiple || false,
|
multiple: ps.poll.multiple || false,
|
||||||
|
|
|
@ -71,7 +71,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
.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
|
||||||
.where('user.updatedAt IS NULL')
|
.where('user.updatedAt IS NULL')
|
||||||
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
|
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
|
||||||
}));
|
}));
|
||||||
|
|
||||||
query.setParameters(followingQuery.getParameters());
|
query.setParameters(followingQuery.getParameters());
|
||||||
|
|
|
@ -46,7 +46,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
.where('user.usernameLower LIKE :username', { username: ps.query.replace('@', '').toLowerCase() + '%' })
|
.where('user.usernameLower LIKE :username', { username: ps.query.replace('@', '').toLowerCase() + '%' })
|
||||||
.andWhere(new Brackets(qb => { qb
|
.andWhere(new Brackets(qb => { qb
|
||||||
.where('user.updatedAt IS NULL')
|
.where('user.updatedAt IS NULL')
|
||||||
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
|
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
|
||||||
}))
|
}))
|
||||||
.andWhere('user.isSuspended = FALSE');
|
.andWhere('user.isSuspended = FALSE');
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
}))
|
}))
|
||||||
.andWhere(new Brackets(qb => { qb
|
.andWhere(new Brackets(qb => { qb
|
||||||
.where('user.updatedAt IS NULL')
|
.where('user.updatedAt IS NULL')
|
||||||
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
|
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
|
||||||
}))
|
}))
|
||||||
.andWhere('user.isSuspended = FALSE');
|
.andWhere('user.isSuspended = FALSE');
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
.where(`user.id IN (${ profQuery.getQuery() })`)
|
.where(`user.id IN (${ profQuery.getQuery() })`)
|
||||||
.andWhere(new Brackets(qb => { qb
|
.andWhere(new Brackets(qb => { qb
|
||||||
.where('user.updatedAt IS NULL')
|
.where('user.updatedAt IS NULL')
|
||||||
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });
|
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
|
||||||
}))
|
}))
|
||||||
.andWhere('user.isSuspended = FALSE')
|
.andWhere('user.isSuspended = FALSE')
|
||||||
.setParameters(profQuery.getParameters());
|
.setParameters(profQuery.getParameters());
|
||||||
|
|
|
@ -25,7 +25,7 @@ export function genOpenapiSpec() {
|
||||||
paths: {} as any,
|
paths: {} as any,
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
schemas: schemas,
|
schemas,
|
||||||
|
|
||||||
securitySchemes: {
|
securitySchemes: {
|
||||||
ApiKeyAuth: {
|
ApiKeyAuth: {
|
||||||
|
|
|
@ -118,7 +118,7 @@ export default async (ctx: Koa.Context) => {
|
||||||
const verified = (speakeasy as any).totp.verify({
|
const verified = (speakeasy as any).totp.verify({
|
||||||
secret: profile.twoFactorSecret,
|
secret: profile.twoFactorSecret,
|
||||||
encoding: 'base32',
|
encoding: 'base32',
|
||||||
token: token,
|
token,
|
||||||
window: 2,
|
window: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ export default async (ctx: Koa.Context) => {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
code,
|
code,
|
||||||
email: emailAddress,
|
email: emailAddress,
|
||||||
username: username,
|
username,
|
||||||
password: hash,
|
password: hash,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ router.get('/dc/cb', async ctx => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const profile = await UserProfiles.createQueryBuilder()
|
const profile = await UserProfiles.createQueryBuilder()
|
||||||
.where('"integrations"->\'discord\'->>\'id\' = :id', { id: id })
|
.where('"integrations"->\'discord\'->>\'id\' = :id', { id })
|
||||||
.andWhere('"userHost" IS NULL')
|
.andWhere('"userHost" IS NULL')
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
|
@ -197,12 +197,12 @@ router.get('/dc/cb', async ctx => {
|
||||||
integrations: {
|
integrations: {
|
||||||
...profile.integrations,
|
...profile.integrations,
|
||||||
discord: {
|
discord: {
|
||||||
id: id,
|
id,
|
||||||
accessToken: accessToken,
|
accessToken,
|
||||||
refreshToken: refreshToken,
|
refreshToken,
|
||||||
expiresDate: expiresDate,
|
expiresDate,
|
||||||
username: username,
|
username,
|
||||||
discriminator: discriminator,
|
discriminator,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -264,12 +264,12 @@ router.get('/dc/cb', async ctx => {
|
||||||
integrations: {
|
integrations: {
|
||||||
...profile.integrations,
|
...profile.integrations,
|
||||||
discord: {
|
discord: {
|
||||||
accessToken: accessToken,
|
accessToken,
|
||||||
refreshToken: refreshToken,
|
refreshToken,
|
||||||
expiresDate: expiresDate,
|
expiresDate,
|
||||||
id: id,
|
id,
|
||||||
username: username,
|
username,
|
||||||
discriminator: discriminator,
|
discriminator,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -176,7 +176,7 @@ router.get('/gh/cb', async ctx => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const link = await UserProfiles.createQueryBuilder()
|
const link = await UserProfiles.createQueryBuilder()
|
||||||
.where('"integrations"->\'github\'->>\'id\' = :id', { id: id })
|
.where('"integrations"->\'github\'->>\'id\' = :id', { id })
|
||||||
.andWhere('"userHost" IS NULL')
|
.andWhere('"userHost" IS NULL')
|
||||||
.getOne();
|
.getOne();
|
||||||
|
|
||||||
|
@ -239,9 +239,9 @@ router.get('/gh/cb', async ctx => {
|
||||||
integrations: {
|
integrations: {
|
||||||
...profile.integrations,
|
...profile.integrations,
|
||||||
github: {
|
github: {
|
||||||
accessToken: accessToken,
|
accessToken,
|
||||||
id: id,
|
id,
|
||||||
login: login,
|
login,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,8 +53,8 @@ export default abstract class Channel {
|
||||||
|
|
||||||
this.connection.sendMessageToWs('channel', {
|
this.connection.sendMessageToWs('channel', {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
type: type,
|
type,
|
||||||
body: body,
|
body,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ export default class Connection {
|
||||||
*/
|
*/
|
||||||
public sendMessageToWs(type: string, payload: any) {
|
public sendMessageToWs(type: string, payload: any) {
|
||||||
this.wsConnection.send(JSON.stringify({
|
this.wsConnection.send(JSON.stringify({
|
||||||
type: type,
|
type,
|
||||||
body: payload,
|
body: payload,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -267,9 +267,7 @@ export default class Connection {
|
||||||
ch.init(params);
|
ch.init(params);
|
||||||
|
|
||||||
if (pong) {
|
if (pong) {
|
||||||
this.sendMessageToWs('connected', {
|
this.sendMessageToWs('connected', { id });
|
||||||
id: id,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -479,7 +479,7 @@ router.get('/_info_card_', async ctx => {
|
||||||
await ctx.render('info-card', {
|
await ctx.render('info-card', {
|
||||||
version: config.version,
|
version: config.version,
|
||||||
host: config.host,
|
host: config.host,
|
||||||
meta: meta,
|
meta,
|
||||||
originalUsersCount: await Users.countBy({ host: IsNull() }),
|
originalUsersCount: await Users.countBy({ host: IsNull() }),
|
||||||
originalNotesCount: await Notes.countBy({ userHost: IsNull() }),
|
originalNotesCount: await Notes.countBy({ userHost: IsNull() }),
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,7 +29,7 @@ export const urlPreviewHandler = async (ctx: Koa.Context) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const summary = meta.summalyProxy ? await getJson(`${meta.summalyProxy}?${query({
|
const summary = meta.summalyProxy ? await getJson(`${meta.summalyProxy}?${query({
|
||||||
url: url,
|
url,
|
||||||
lang: lang ?? 'ja-JP',
|
lang: lang ?? 'ja-JP',
|
||||||
})}`) : await summaly.default(url, {
|
})}`) : await summaly.default(url, {
|
||||||
followRedirects: false,
|
followRedirects: false,
|
||||||
|
|
|
@ -14,7 +14,7 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: {
|
||||||
id: genId(),
|
id: genId(),
|
||||||
antennaId: antenna.id,
|
antennaId: antenna.id,
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
read: read,
|
read,
|
||||||
});
|
});
|
||||||
|
|
||||||
publishAntennaStream(antenna.id, 'note', note);
|
publishAntennaStream(antenna.id, 'note', note);
|
||||||
|
|
|
@ -79,11 +79,11 @@ export default class FederationChart extends Chart<typeof schema> {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'sub': sub,
|
sub,
|
||||||
'pub': pub,
|
pub,
|
||||||
'pubsub': pubsub,
|
pubsub,
|
||||||
'subActive': subActive,
|
subActive,
|
||||||
'pubActive': pubActive,
|
pubActive,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -266,9 +266,7 @@ export default abstract class Chart<T extends Schema> {
|
||||||
new Error('not happen') as never;
|
new Error('not happen') as never;
|
||||||
|
|
||||||
return repository.findOne({
|
return repository.findOne({
|
||||||
where: group ? {
|
where: group ? { group } : {},
|
||||||
group: group,
|
|
||||||
} : {},
|
|
||||||
order: {
|
order: {
|
||||||
date: -1,
|
date: -1,
|
||||||
},
|
},
|
||||||
|
@ -294,7 +292,7 @@ export default abstract class Chart<T extends Schema> {
|
||||||
// 現在(=今のHour or Day)のログ
|
// 現在(=今のHour or Day)のログ
|
||||||
const currentLog = await repository.findOneBy({
|
const currentLog = await repository.findOneBy({
|
||||||
date: Chart.dateToTimestamp(current),
|
date: Chart.dateToTimestamp(current),
|
||||||
...(group ? { group: group } : {}),
|
...(group ? { group } : {}),
|
||||||
}) as RawRecord<T> | undefined;
|
}) as RawRecord<T> | undefined;
|
||||||
|
|
||||||
// ログがあればそれを返して終了
|
// ログがあればそれを返して終了
|
||||||
|
@ -333,8 +331,8 @@ export default abstract class Chart<T extends Schema> {
|
||||||
try {
|
try {
|
||||||
// ロック内でもう1回チェックする
|
// ロック内でもう1回チェックする
|
||||||
const currentLog = await repository.findOneBy({
|
const currentLog = await repository.findOneBy({
|
||||||
date: date,
|
date,
|
||||||
...(group ? { group: group } : {}),
|
...(group ? { group } : {}),
|
||||||
}) as RawRecord<T> | undefined;
|
}) as RawRecord<T> | undefined;
|
||||||
|
|
||||||
// ログがあればそれを返して終了
|
// ログがあればそれを返して終了
|
||||||
|
@ -348,8 +346,8 @@ export default abstract class Chart<T extends Schema> {
|
||||||
|
|
||||||
// 新規ログ挿入
|
// 新規ログ挿入
|
||||||
log = await repository.insert({
|
log = await repository.insert({
|
||||||
date: date,
|
date,
|
||||||
...(group ? { group: group } : {}),
|
...(group ? { group } : {}),
|
||||||
...columns,
|
...columns,
|
||||||
}).then(x => repository.findOneByOrFail(x.identifiers[0])) as RawRecord<T>;
|
}).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({
|
let logs = await repository.find({
|
||||||
where: {
|
where: {
|
||||||
date: Between(Chart.dateToTimestamp(gt), Chart.dateToTimestamp(lt)),
|
date: Between(Chart.dateToTimestamp(gt), Chart.dateToTimestamp(lt)),
|
||||||
...(group ? { group: group } : {}),
|
...(group ? { group } : {}),
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
date: -1,
|
date: -1,
|
||||||
|
@ -594,9 +592,7 @@ export default abstract class Chart<T extends Schema> {
|
||||||
// もっとも新しいログを持ってくる
|
// もっとも新しいログを持ってくる
|
||||||
// (すくなくともひとつログが無いと隙間埋めできないため)
|
// (すくなくともひとつログが無いと隙間埋めできないため)
|
||||||
const recentLog = await repository.findOne({
|
const recentLog = await repository.findOne({
|
||||||
where: group ? {
|
where: group ? { group } : {},
|
||||||
group: group,
|
|
||||||
} : {},
|
|
||||||
order: {
|
order: {
|
||||||
date: -1,
|
date: -1,
|
||||||
},
|
},
|
||||||
|
@ -613,7 +609,7 @@ export default abstract class Chart<T extends Schema> {
|
||||||
const outdatedLog = await repository.findOne({
|
const outdatedLog = await repository.findOne({
|
||||||
where: {
|
where: {
|
||||||
date: LessThan(Chart.dateToTimestamp(gt)),
|
date: LessThan(Chart.dateToTimestamp(gt)),
|
||||||
...(group ? { group: group } : {}),
|
...(group ? { group } : {}),
|
||||||
},
|
},
|
||||||
order: {
|
order: {
|
||||||
date: -1,
|
date: -1,
|
||||||
|
|
|
@ -23,8 +23,8 @@ export async function createNotification(
|
||||||
const notification = await Notifications.insert({
|
const notification = await Notifications.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
notifieeId: notifieeId,
|
notifieeId,
|
||||||
type: type,
|
type,
|
||||||
// 相手がこの通知をミュートしているようなら、既読を予めつけておく
|
// 相手がこの通知をミュートしているようなら、既読を予めつけておく
|
||||||
isRead: isMuted,
|
isRead: isMuted,
|
||||||
...data,
|
...data,
|
||||||
|
|
|
@ -36,7 +36,7 @@ export async function createSystemUser(username: string) {
|
||||||
account = await transactionalEntityManager.insert(User, {
|
account = await transactionalEntityManager.insert(User, {
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
username: username,
|
username,
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
host: null,
|
host: null,
|
||||||
token: secret,
|
token: secret,
|
||||||
|
|
|
@ -54,8 +54,8 @@ export async function uploadFromUrl({
|
||||||
return driveFile!;
|
return driveFile!;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(`Failed to create drive file: ${e}`, {
|
logger.error(`Failed to create drive file: ${e}`, {
|
||||||
url: url,
|
url,
|
||||||
e: e,
|
e,
|
||||||
});
|
});
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -7,7 +7,7 @@ export async function insertModerationLog(moderator: { id: User['id'] }, type: s
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
userId: moderator.id,
|
userId: moderator.id,
|
||||||
type: type,
|
type,
|
||||||
info: info || {},
|
info: info || {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ export default class Logger {
|
||||||
constructor(domain: string, color?: string, store = true) {
|
constructor(domain: string, color?: string, store = true) {
|
||||||
this.domain = {
|
this.domain = {
|
||||||
name: domain,
|
name: domain,
|
||||||
color: color,
|
color,
|
||||||
};
|
};
|
||||||
this.store = store;
|
this.store = store;
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ class NotificationManager {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.queue.push({
|
this.queue.push({
|
||||||
reason: reason,
|
reason,
|
||||||
target: notifiee,
|
target: notifiee,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,7 @@ export default async function(user: { id: User['id']; uri: User['uri']; host: Us
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
publishNoteStream(note.id, 'deleted', {
|
publishNoteStream(note.id, 'deleted', { deletedAt });
|
||||||
deletedAt: deletedAt,
|
|
||||||
});
|
|
||||||
|
|
||||||
//#region ローカルの投稿なら削除アクティビティを配送
|
//#region ローカルの投稿なら削除アクティビティを配送
|
||||||
if (Users.isLocalUser(user) && !note.localOnly) {
|
if (Users.isLocalUser(user) && !note.localOnly) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
choice: choice,
|
choice,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Increment votes count
|
// 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}'`);
|
await Polls.query(`UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE "noteId" = '${poll.noteId}'`);
|
||||||
|
|
||||||
publishNoteStream(note.id, 'pollVoted', {
|
publishNoteStream(note.id, 'pollVoted', {
|
||||||
choice: choice,
|
choice,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) {
|
||||||
createNotification(note.userId, 'pollVote', {
|
createNotification(note.userId, 'pollVote', {
|
||||||
notifierId: user.id,
|
notifierId: user.id,
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
choice: choice,
|
choice,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch watchers
|
// Fetch watchers
|
||||||
|
@ -74,7 +74,7 @@ export default async function(user: CacheableUser, note: Note, choice: number) {
|
||||||
createNotification(watcher.userId, 'pollVote', {
|
createNotification(watcher.userId, 'pollVote', {
|
||||||
notifierId: user.id,
|
notifierId: user.id,
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
choice: choice,
|
choice,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -103,7 +103,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
|
||||||
createNotification(note.userId, 'reaction', {
|
createNotification(note.userId, 'reaction', {
|
||||||
notifierId: user.id,
|
notifierId: user.id,
|
||||||
noteId: note.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', {
|
createNotification(watcher.userId, 'reaction', {
|
||||||
notifierId: user.id,
|
notifierId: user.id,
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
reaction: reaction,
|
reaction,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -62,14 +62,14 @@ export default async function(
|
||||||
if ((readMentions.length > 0) || (readSpecifiedNotes.length > 0) || (readChannelNotes.length > 0)) {
|
if ((readMentions.length > 0) || (readSpecifiedNotes.length > 0) || (readChannelNotes.length > 0)) {
|
||||||
// Remove the record
|
// Remove the record
|
||||||
await NoteUnreads.delete({
|
await NoteUnreads.delete({
|
||||||
userId: userId,
|
userId,
|
||||||
noteId: In([...readMentions.map(n => n.id), ...readSpecifiedNotes.map(n => n.id), ...readChannelNotes.map(n => n.id)]),
|
noteId: In([...readMentions.map(n => n.id), ...readSpecifiedNotes.map(n => n.id), ...readChannelNotes.map(n => n.id)]),
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: ↓まとめてクエリしたい
|
// TODO: ↓まとめてクエリしたい
|
||||||
|
|
||||||
NoteUnreads.countBy({
|
NoteUnreads.countBy({
|
||||||
userId: userId,
|
userId,
|
||||||
isMentioned: true,
|
isMentioned: true,
|
||||||
}).then(mentionsCount => {
|
}).then(mentionsCount => {
|
||||||
if (mentionsCount === 0) {
|
if (mentionsCount === 0) {
|
||||||
|
@ -79,7 +79,7 @@ export default async function(
|
||||||
});
|
});
|
||||||
|
|
||||||
NoteUnreads.countBy({
|
NoteUnreads.countBy({
|
||||||
userId: userId,
|
userId,
|
||||||
isSpecified: true,
|
isSpecified: true,
|
||||||
}).then(specifiedCount => {
|
}).then(specifiedCount => {
|
||||||
if (specifiedCount === 0) {
|
if (specifiedCount === 0) {
|
||||||
|
@ -89,7 +89,7 @@ export default async function(
|
||||||
});
|
});
|
||||||
|
|
||||||
NoteUnreads.countBy({
|
NoteUnreads.countBy({
|
||||||
userId: userId,
|
userId,
|
||||||
noteChannelId: Not(IsNull()),
|
noteChannelId: Not(IsNull()),
|
||||||
}).then(channelNoteCount => {
|
}).then(channelNoteCount => {
|
||||||
if (channelNoteCount === 0) {
|
if (channelNoteCount === 0) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: {
|
||||||
|
|
||||||
// スレッドミュート
|
// スレッドミュート
|
||||||
const threadMute = await NoteThreadMutings.findOneBy({
|
const threadMute = await NoteThreadMutings.findOneBy({
|
||||||
userId: userId,
|
userId,
|
||||||
threadId: note.threadId || note.id,
|
threadId: note.threadId || note.id,
|
||||||
});
|
});
|
||||||
if (threadMute) return;
|
if (threadMute) return;
|
||||||
|
@ -27,7 +27,7 @@ export async function insertNoteUnread(userId: User['id'], note: Note, params: {
|
||||||
const unread = {
|
const unread = {
|
||||||
id: genId(),
|
id: genId(),
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
userId: userId,
|
userId,
|
||||||
isSpecified: params.isSpecified,
|
isSpecified: params.isSpecified,
|
||||||
isMentioned: params.isMentioned,
|
isMentioned: params.isMentioned,
|
||||||
noteChannelId: note.channelId,
|
noteChannelId: note.channelId,
|
||||||
|
|
|
@ -47,9 +47,7 @@ export async function pushNotification<T extends keyof pushNotificationsTypes>(u
|
||||||
meta.swPrivateKey);
|
meta.swPrivateKey);
|
||||||
|
|
||||||
// Fetch
|
// Fetch
|
||||||
const subscriptions = await SwSubscriptions.findBy({
|
const subscriptions = await SwSubscriptions.findBy({ userId });
|
||||||
userId: userId,
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const subscription of subscriptions) {
|
for (const subscription of subscriptions) {
|
||||||
const pushSubscription = {
|
const pushSubscription = {
|
||||||
|
@ -73,7 +71,7 @@ export async function pushNotification<T extends keyof pushNotificationsTypes>(u
|
||||||
|
|
||||||
if (err.statusCode === 410) {
|
if (err.statusCode === 410) {
|
||||||
SwSubscriptions.delete({
|
SwSubscriptions.delete({
|
||||||
userId: userId,
|
userId,
|
||||||
endpoint: subscription.endpoint,
|
endpoint: subscription.endpoint,
|
||||||
auth: subscription.auth,
|
auth: subscription.auth,
|
||||||
publickey: subscription.publickey,
|
publickey: subscription.publickey,
|
||||||
|
|
|
@ -29,9 +29,9 @@ export async function sendEmail(to: string, subject: string, html: string, text:
|
||||||
// TODO: htmlサニタイズ
|
// TODO: htmlサニタイズ
|
||||||
const info = await transporter.sendMail({
|
const info = await transporter.sendMail({
|
||||||
from: meta.email!,
|
from: meta.email!,
|
||||||
to: to,
|
to,
|
||||||
subject: subject,
|
subject,
|
||||||
text: text,
|
text,
|
||||||
html: `<!doctype html>
|
html: `<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
|
@ -26,12 +26,12 @@ import {
|
||||||
class Publisher {
|
class Publisher {
|
||||||
private publish = (channel: StreamChannels, type: string | null, value?: any): void => {
|
private publish = (channel: StreamChannels, type: string | null, value?: any): void => {
|
||||||
const message = type == null ? value : value == null ?
|
const message = type == null ? value : value == null ?
|
||||||
{ type: type, body: null } :
|
{ type, body: null } :
|
||||||
{ type: type, body: value };
|
{ type, body: value };
|
||||||
|
|
||||||
redisClient.publish(config.host, JSON.stringify({
|
redisClient.publish(config.host, JSON.stringify({
|
||||||
channel: channel,
|
channel,
|
||||||
message: message,
|
message,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,6 @@ module.exports = {
|
||||||
'import/order': ['warn', {
|
'import/order': ['warn', {
|
||||||
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
|
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
|
||||||
}],
|
}],
|
||||||
'object-shorthand': ['warn', 'consistent-as-needed'],
|
'object-shorthand': ['warn', 'always'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue