This commit is contained in:
EdamAmex 2024-12-22 13:58:15 +09:00 committed by GitHub
commit 3de930be98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 45 additions and 41 deletions

View File

@ -126,9 +126,9 @@ const $meta: Provider = {
const { type, body } = obj.message as GlobalEvents['internal']['payload']; const { type, body } = obj.message as GlobalEvents['internal']['payload'];
switch (type) { switch (type) {
case 'metaUpdated': { case 'metaUpdated': {
for (const key in body.after) { Object.entries(body.after).forEach(([key, value]) => {
(meta as any)[key] = (body.after as any)[key]; (meta as any)[key] = value;
} });
meta.proxyAccount = null; // joinなカラムは通常取ってこないので meta.proxyAccount = null; // joinなカラムは通常取ってこないので
break; break;
} }

View File

@ -146,7 +146,7 @@ function loadConfigBoot(): Config {
if (typeof exception === 'string') { if (typeof exception === 'string') {
configLogger.error(exception); configLogger.error(exception);
process.exit(1); process.exit(1);
} else if ((exception as any).code === 'ENOENT') { } else if (exception && typeof exception === 'object' && 'code' in exception && exception.code === 'ENOENT') {
configLogger.error('Configuration file not found', null, true); configLogger.error('Configuration file not found', null, true);
process.exit(1); process.exit(1);
} }

View File

@ -11,6 +11,7 @@ import * as nsfw from 'nsfwjs';
import si from 'systeminformation'; import si from 'systeminformation';
import { Mutex } from 'async-mutex'; import { Mutex } from 'async-mutex';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { Tensor3D } from '@tensorflow/tfjs-core';
const _filename = fileURLToPath(import.meta.url); const _filename = fileURLToPath(import.meta.url);
const _dirname = dirname(_filename); const _dirname = dirname(_filename);
@ -51,7 +52,7 @@ export class AiService {
} }
const buffer = await fs.promises.readFile(path); const buffer = await fs.promises.readFile(path);
const image = await tf.node.decodeImage(buffer, 3) as any; const image = await tf.node.decodeImage(buffer, 3) as Tensor3D;
try { try {
const predictions = await this.model.classify(image); const predictions = await this.model.classify(image);
return predictions; return predictions;

View File

@ -16,6 +16,7 @@ import type { MiMeta, UserProfilesRepository } from '@/models/_.js';
import { LoggerService } from '@/core/LoggerService.js'; import { LoggerService } from '@/core/LoggerService.js';
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { HttpRequestService } from '@/core/HttpRequestService.js'; import { HttpRequestService } from '@/core/HttpRequestService.js';
import SMTPPool from 'nodemailer/lib/smtp-pool/index.js';
@Injectable() @Injectable()
export class EmailService { export class EmailService {
@ -48,6 +49,7 @@ export class EmailService {
const enableAuth = this.meta.smtpUser != null && this.meta.smtpUser !== ''; const enableAuth = this.meta.smtpUser != null && this.meta.smtpUser !== '';
const transporter = nodemailer.createTransport({ const transporter = nodemailer.createTransport({
pool: true,
host: this.meta.smtpHost, host: this.meta.smtpHost,
port: this.meta.smtpPort, port: this.meta.smtpPort,
secure: this.meta.smtpSecure, secure: this.meta.smtpSecure,
@ -57,7 +59,7 @@ export class EmailService {
user: this.meta.smtpUser, user: this.meta.smtpUser,
pass: this.meta.smtpPass, pass: this.meta.smtpPass,
} : undefined, } : undefined,
} as any); } as SMTPPool.Options);
const htmlContent = `<!doctype html> const htmlContent = `<!doctype html>
<html> <html>

View File

@ -68,7 +68,7 @@ export class HashtagService {
const q = this.hashtagsRepository.createQueryBuilder('tag').update() const q = this.hashtagsRepository.createQueryBuilder('tag').update()
.where('name = :name', { name: tag }); .where('name = :name', { name: tag });
const set = {} as any; const set = {} as Record<string, () => string>;
if (isUserAttached) { if (isUserAttached) {
if (inc) { if (inc) {

View File

@ -6,7 +6,7 @@
import { URL } from 'node:url'; import { URL } from 'node:url';
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import * as parse5 from 'parse5'; import * as parse5 from 'parse5';
import { Window, XMLSerializer } from 'happy-dom'; import { HTMLElement, Text, Window, XMLSerializer } from 'happy-dom';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js'; import type { Config } from '@/config.js';
import { intersperse } from '@/misc/prelude/array.js'; import { intersperse } from '@/misc/prelude/array.js';
@ -245,9 +245,9 @@ export class MfmService {
const body = doc.createElement('p'); const body = doc.createElement('p');
function appendChildren(children: mfm.MfmNode[], targetElement: any): void { function appendChildren(children: mfm.MfmNode[], targetElement: HTMLElement): void {
if (children) { if (children) {
for (const child of children.map(x => (handlers as any)[x.type](x))) targetElement.appendChild(child); for (const child of children.map(x => (handlers[x.type] as (node: mfm.NodeType<typeof x.type>) => HTMLElement | Text)(x))) targetElement.appendChild(child);
} }
} }
@ -257,7 +257,7 @@ export class MfmService {
return el; return el;
} }
const handlers: { [K in mfm.MfmNode['type']]: (node: mfm.NodeType<K>) => any } = { const handlers: { [K in mfm.MfmNode['type']]: (node: mfm.NodeType<K>) => HTMLElement | Text} = {
bold: (node) => { bold: (node) => {
const el = doc.createElement('b'); const el = doc.createElement('b');
appendChildren(node.children, el); appendChildren(node.children, el);

View File

@ -57,6 +57,7 @@ import { trackPromise } from '@/misc/promise-tracker.js';
import { IdentifiableError } from '@/misc/identifiable-error.js'; import { IdentifiableError } from '@/misc/identifiable-error.js';
import { CollapsedQueue } from '@/misc/collapsed-queue.js'; import { CollapsedQueue } from '@/misc/collapsed-queue.js';
import { CacheService } from '@/core/CacheService.js'; import { CacheService } from '@/core/CacheService.js';
import { noteVisibilities } from '@/types.js';
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention'; type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
@ -134,7 +135,7 @@ type Option = {
localOnly?: boolean | null; localOnly?: boolean | null;
reactionAcceptance?: MiNote['reactionAcceptance']; reactionAcceptance?: MiNote['reactionAcceptance'];
cw?: string | null; cw?: string | null;
visibility?: string; visibility?: typeof noteVisibilities[number];
visibleUsers?: MinimumUser[] | null; visibleUsers?: MinimumUser[] | null;
channel?: MiChannel | null; channel?: MiChannel | null;
apMentions?: MinimumUser[] | null; apMentions?: MinimumUser[] | null;
@ -424,7 +425,7 @@ export class NoteCreateService implements OnApplicationShutdown {
userId: user.id, userId: user.id,
localOnly: data.localOnly!, localOnly: data.localOnly!,
reactionAcceptance: data.reactionAcceptance, reactionAcceptance: data.reactionAcceptance,
visibility: data.visibility as any, visibility: data.visibility,
visibleUserIds: data.visibility === 'specified' visibleUserIds: data.visibility === 'specified'
? data.visibleUsers ? data.visibleUsers
? data.visibleUsers.map(u => u.id) ? data.visibleUsers.map(u => u.id)
@ -857,7 +858,7 @@ export class NoteCreateService implements OnApplicationShutdown {
i === self.findIndex(u2 => u.id === u2.id), i === self.findIndex(u2 => u.id === u2.id),
); );
return mentionedUsers; return mentionedUsers.filter(mentionedUser => !!mentionedUser) as MiUser[];
} }
@bindThis @bindThis

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { Brackets, In } from 'typeorm'; import { Brackets, FindOptionsWhere, In } from 'typeorm';
import { Injectable, Inject } from '@nestjs/common'; import { Injectable, Inject } from '@nestjs/common';
import type { MiUser, MiLocalUser, MiRemoteUser } from '@/models/User.js'; import type { MiUser, MiLocalUser, MiRemoteUser } from '@/models/User.js';
import type { MiNote, IMentionedRemoteUsers } from '@/models/Note.js'; import type { MiNote, IMentionedRemoteUsers } from '@/models/Note.js';
@ -165,7 +165,7 @@ export class NoteDeleteService {
@bindThis @bindThis
private async getMentionedRemoteUsers(note: MiNote) { private async getMentionedRemoteUsers(note: MiNote) {
const where = [] as any[]; const where = [] as FindOptionsWhere<MiUser>[];
// mention / reply / dm // mention / reply / dm
const uris = (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri); const uris = (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri);

View File

@ -153,7 +153,7 @@ export class NotificationService implements OnApplicationShutdown {
notifierId, notifierId,
} : {}), } : {}),
...data, ...data,
} as any as FilterUnionByProperty<MiNotification, 'type', T>; } as unknown as FilterUnionByProperty<MiNotification, 'type', T>;
const redisIdPromise = this.redisClient.xadd( const redisIdPromise = this.redisClient.xadd(
`notificationTimeline:${notifieeId}`, `notificationTimeline:${notifieeId}`,

View File

@ -39,7 +39,7 @@ function truncateBody<T extends keyof PushNotificationsTypes>(type: T, body: Pus
cw: undefined, cw: undefined,
reply: undefined, reply: undefined,
renote: undefined, renote: undefined,
user: type === 'notification' ? undefined as any : body.note.user, user: type === 'notification' ? undefined : body.note.user,
}, },
} : {}), } : {}),
}; };

View File

@ -133,7 +133,7 @@ export class UserSuspendService {
} }
for (const inbox of queue) { for (const inbox of queue) {
this.queueService.deliver(user as any, content, inbox, true); this.queueService.deliver(user, content, inbox, true);
} }
} }
} }

View File

@ -390,10 +390,10 @@ export class ApPersonService implements OnModuleInit {
uri: person.id, uri: person.id,
tags, tags,
isBot, isBot,
isCat: (person as any).isCat === true, isCat: 'isCat' in person && person.isCat as boolean,
requireSigninToViewContents: (person as any).requireSigninToViewContents === true, requireSigninToViewContents: 'requireSigninToViewContents' in person && person.requireSigninToViewContents as boolean,
makeNotesFollowersOnlyBefore: (person as any).makeNotesFollowersOnlyBefore ?? null, makeNotesFollowersOnlyBefore: ('makeNotesFollowersOnlyBefore' in person && person.makeNotesFollowersOnlyBefore as number) || null,
makeNotesHiddenBefore: (person as any).makeNotesHiddenBefore ?? null, makeNotesHiddenBefore: ('makeNotesHiddenBefore' in person && person.makeNotesHiddenBefore as number) || null,
emojis, emojis,
})) as MiRemoteUser; })) as MiRemoteUser;
@ -737,7 +737,7 @@ export class ApPersonService implements OnModuleInit {
transactionalEntityManager.insert(MiUserNotePining, { transactionalEntityManager.insert(MiUserNotePining, {
id: this.idService.gen(Date.now() + td), id: this.idService.gen(Date.now() + td),
userId: user.id, userId: user.id,
noteId: note.id, noteId: note?.id,
}); });
} }
}); });

View File

@ -75,13 +75,13 @@ export default class Logger {
} }
@bindThis @bindThis
public error(x: string | Error, data?: Record<string, any> | null, important = false): void { // 実行を継続できない状況で使う public error(x: string | object | Error, data?: Record<string, any> | null, important = false): void { // 実行を継続できない状況で使う
if (x instanceof Error) { if (x instanceof Error) {
data = data ?? {}; data = data ?? {};
data.e = x; data.e = x;
this.log('error', x.toString(), data, important); this.log('error', x.toString(), data, important);
} else if (typeof x === 'object') { } else if (typeof x === 'object') {
this.log('error', `${(x as any).message ?? (x as any).name ?? x}`, data, important); this.log('error', `${('message' in x ? x.message : 'name' in x ? x.name : x)}`, data, important);
} else { } else {
this.log('error', `${x}`, data, important); this.log('error', `${x}`, data, important);
} }

View File

@ -647,7 +647,7 @@ describe('クリップ', () => {
...request, ...request,
}, { }, {
status: 204, status: 204,
}) as any as void; }) as unknown as void;
}; };
const removeNote = async (parameters: Misskey.entities.ClipsRemoveNoteRequest, request: Partial<ApiRequest<'clips/remove-note'>> = {}): Promise<void> => { const removeNote = async (parameters: Misskey.entities.ClipsRemoveNoteRequest, request: Partial<ApiRequest<'clips/remove-note'>> = {}): Promise<void> => {
@ -658,7 +658,7 @@ describe('クリップ', () => {
...request, ...request,
}, { }, {
status: 204, status: 204,
}) as any as void; }) as unknown as void;
}; };
const notes = async (parameters: Misskey.entities.ClipsNotesRequest, request: Partial<ApiRequest<'clips/notes'>> = {}): Promise<Misskey.entities.Note[]> => { const notes = async (parameters: Misskey.entities.ClipsNotesRequest, request: Partial<ApiRequest<'clips/notes'>> = {}): Promise<Misskey.entities.Note[]> => {

View File

@ -17,7 +17,7 @@ export function misskeyApi<
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT, _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
>( >(
endpoint: E, endpoint: E,
data: P = {} as any, data: P = {} as P,
signal?: AbortSignal, signal?: AbortSignal,
): Promise<_ResT> { ): Promise<_ResT> {
if (endpoint.includes('://')) throw new Error('invalid endpoint'); if (endpoint.includes('://')) throw new Error('invalid endpoint');
@ -64,7 +64,7 @@ export function misskeyApiGet<
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT, _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
>( >(
endpoint: E, endpoint: E,
data: P = {} as any, data: P = {} as P,
): Promise<_ResT> { ): Promise<_ResT> {
pendingApiRequestsCount.value++; pendingApiRequestsCount.value++;
@ -72,7 +72,7 @@ export function misskeyApiGet<
pendingApiRequestsCount.value--; pendingApiRequestsCount.value--;
}; };
const query = new URLSearchParams(data as any); const query = new URLSearchParams(data);
const promise = new Promise<_ResT>((resolve, reject) => { const promise = new Promise<_ResT>((resolve, reject) => {
// Send request // Send request

View File

@ -43,7 +43,7 @@ const config = {
plugins: [ plugins: [
{ {
// XXX: https://github.com/IanVS/vite-plugin-turbosnap/issues/8 // XXX: https://github.com/IanVS/vite-plugin-turbosnap/issues/8
...(turbosnap as any as typeof turbosnap['default'])({ ...(turbosnap as unknown as typeof turbosnap['default'])({
rootDir: config.root ?? process.cwd(), rootDir: config.root ?? process.cwd(),
}), }),
name: 'fake-turbosnap', name: 'fake-turbosnap',

View File

@ -17,7 +17,7 @@ export function misskeyApi<
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT, _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
>( >(
endpoint: E, endpoint: E,
data: P & { i?: string | null; } = {} as any, data: P & { i?: string | null; } = {} as P,
token?: string | null | undefined, token?: string | null | undefined,
signal?: AbortSignal, signal?: AbortSignal,
): Promise<_ResT> { ): Promise<_ResT> {
@ -69,7 +69,7 @@ export function misskeyApiGet<
_ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT, _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType<E, P> : ResT,
>( >(
endpoint: E, endpoint: E,
data: P = {} as any, data: P = {} as P,
): Promise<_ResT> { ): Promise<_ResT> {
pendingApiRequestsCount.value++; pendingApiRequestsCount.value++;
@ -77,7 +77,7 @@ export function misskeyApiGet<
pendingApiRequestsCount.value--; pendingApiRequestsCount.value--;
}; };
const query = new URLSearchParams(data as any); const query = new URLSearchParams(data);
const promise = new Promise<_ResT>((resolve, reject) => { const promise = new Promise<_ResT>((resolve, reject) => {
// Send request // Send request

View File

@ -17,7 +17,7 @@ export function useForm<T extends Record<string, any>>(initialState: T, save: (n
const currentState = reactive<T>(copy(initialState)); const currentState = reactive<T>(copy(initialState));
const previousState = reactive<T>(copy(initialState)); const previousState = reactive<T>(copy(initialState));
const modifiedStates = reactive<Record<keyof T, boolean>>({} as any); const modifiedStates = reactive<Record<keyof T, boolean> | Record<string, never>>({});
for (const key in currentState) { for (const key in currentState) {
modifiedStates[key] = false; modifiedStates[key] = false;
} }

View File

@ -18,7 +18,7 @@ describe('Scroll', () => {
document.body.append(div); document.body.append(div);
let called = false; let called = false;
onScrollTop(div as any as HTMLElement, () => called = true); onScrollTop(div as unknown as HTMLElement, () => called = true);
assert.ok(called); assert.ok(called);
}); });
@ -30,7 +30,7 @@ describe('Scroll', () => {
assert.strictEqual(div.scrollTop, 0); assert.strictEqual(div.scrollTop, 0);
let called = false; let called = false;
onScrollTop(div as any as HTMLElement, () => called = true); onScrollTop(div as unknown as HTMLElement, () => called = true);
assert.ok(!called); assert.ok(!called);
}); });
@ -46,7 +46,7 @@ describe('Scroll', () => {
document.body.append(div); document.body.append(div);
let called = false; let called = false;
onScrollBottom(div as any as HTMLElement, () => called = true); onScrollBottom(div as unknown as HTMLElement, () => called = true);
assert.ok(called); assert.ok(called);
}); });
@ -58,7 +58,7 @@ describe('Scroll', () => {
assert.strictEqual(div.scrollTop, 0); assert.strictEqual(div.scrollTop, 0);
let called = false; let called = false;
onScrollBottom(div as any as HTMLElement, () => called = true); onScrollBottom(div as unknown as HTMLElement, () => called = true);
assert.ok(!called); assert.ok(!called);
}); });

View File

@ -123,7 +123,7 @@ describe('MkUrlPreview', () => {
url: 'https://example.local/player', url: 'https://example.local/player',
width: null, width: null,
height: null, height: null,
allow: undefined as any, allow: undefined as unknown as string[],
}, },
}); });
assert.exists(iframe, 'iframe should exist'); assert.exists(iframe, 'iframe should exist');