fixes
This commit is contained in:
parent
174a8b1b3e
commit
417f52359d
21 changed files with 88 additions and 70 deletions
|
@ -119,8 +119,7 @@ function loadConfigBoot(): Config {
|
|||
if (typeof exception === 'string') {
|
||||
configLogger.error(exception);
|
||||
process.exit(1);
|
||||
}
|
||||
if (exception.code === 'ENOENT') {
|
||||
} else if ((exception as any).code === 'ENOENT') {
|
||||
configLogger.error('Configuration file not found', null, true);
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ export class AntennaService implements OnApplicationShutdown {
|
|||
this.redisSubscriber.off('message', this.onRedisMessage);
|
||||
}
|
||||
|
||||
private async onRedisMessage(_, data) {
|
||||
private async onRedisMessage(_: string, data: string): Promise<void> {
|
||||
const obj = JSON.parse(data);
|
||||
|
||||
if (obj.channel === 'internal') {
|
||||
|
|
|
@ -20,7 +20,7 @@ export class ObjectStorageQueueProcessorsService {
|
|||
public start(q: Bull.Queue) {
|
||||
const jobs = {
|
||||
deleteFile: (job) => this.deleteFileProcessorService.process(job),
|
||||
cleanRemoteFiles: (job) => this.cleanRemoteFilesProcessorService.process(job),
|
||||
cleanRemoteFiles: (job, done) => this.cleanRemoteFilesProcessorService.process(job, done),
|
||||
} as Record<string, Bull.ProcessCallbackFunction<ObjectStorageJobData | Bull.ProcessPromiseFunction<ObjectStorageJobData>>>;
|
||||
|
||||
for (const [k, v] of Object.entries(jobs)) {
|
||||
|
|
|
@ -118,7 +118,7 @@ export class NodeinfoServerService {
|
|||
router.get(nodeinfo2_0path, async ctx => {
|
||||
const base = await cache.fetch(null, () => nodeinfo2());
|
||||
|
||||
delete base.software.repository;
|
||||
delete (base as any).software.repository;
|
||||
|
||||
ctx.body = { version: '2.0', ...base };
|
||||
ctx.set('Cache-Control', 'public, max-age=600');
|
||||
|
|
|
@ -72,7 +72,7 @@ export class StreamingApiServerService {
|
|||
|
||||
const ev = new EventEmitter();
|
||||
|
||||
async function onRedisMessage(_: string, data: string) {
|
||||
async function onRedisMessage(_: string, data: string): Promise<void> {
|
||||
const parsed = JSON.parse(data);
|
||||
ev.emit(parsed.channel, parsed.message);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
|||
import type { AbuseUserReportsRepository } from '@/models/index.js';
|
||||
import { QueryService } from '@/core/QueryService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { AbuseUserReportEntityService } from '@/core/entities/AbuseUserReportEntityService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
@ -93,6 +94,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
@Inject(DI.abuseUserReportsRepository)
|
||||
private abuseUserReportsRepository: AbuseUserReportsRepository,
|
||||
|
||||
private abuseUserReportEntityService: AbuseUserReportEntityService,
|
||||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
|
|
|
@ -5,6 +5,7 @@ import { QueueService } from '@/core/QueueService.js';
|
|||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
import { UserSuspendService } from '@/core/UserSuspendService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
@ -28,6 +29,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
||||
private userEntityService: UserEntityService,
|
||||
private queueService: QueueService,
|
||||
private globalEventService: GlobalEventService,
|
||||
private userSuspendService: UserSuspendService,
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
|||
import type { UsersRepository } from '@/models/index.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
@ -27,6 +28,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
||||
private userEntityService: UserEntityService,
|
||||
private moderationLogService: ModerationLogService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
|
|
|
@ -3,6 +3,7 @@ import type { DriveFilesRepository } from '@/models/index.js';
|
|||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { QueryService } from '@/core/QueryService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
@ -47,6 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
@Inject(DI.driveFilesRepository)
|
||||
private driveFilesRepository: DriveFilesRepository,
|
||||
|
||||
private driveFileEntityService: DriveFileEntityService,
|
||||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
|
|
|
@ -192,12 +192,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
throw new ApiError(meta.errors.noSuchFile);
|
||||
}
|
||||
|
||||
const res = file as Partial<typeof file>;
|
||||
|
||||
if (!me.isAdmin) {
|
||||
delete file.requestIp;
|
||||
delete file.requestHeaders;
|
||||
delete res.requestIp;
|
||||
delete res.requestHeaders;
|
||||
}
|
||||
|
||||
return file;
|
||||
return res;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import type { EmojisRepository } from '@/models/index.js';
|
|||
import type { Emoji } from '@/models/entities/Emoji.js';
|
||||
import { QueryService } from '@/core/QueryService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { EmojiEntityService } from '@/core/entities/EmojiEntityService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
@ -71,6 +72,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
@Inject(DI.emojisRepository)
|
||||
private emojisRepository: EmojisRepository,
|
||||
|
||||
private emojiEntityService: EmojiEntityService,
|
||||
private queryService: QueryService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { URL } from 'node:url';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { DeliverQueue } from '@/core/queue/QueueModule.js';
|
||||
import type { DeliverQueue } from '@/core/queue/QueueModule.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { URL } from 'node:url';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { InboxQueue } from '@/core/queue/QueueModule.js';
|
||||
import type { InboxQueue } from '@/core/queue/QueueModule.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { DbQueue, DeliverQueue, EndedPollNotificationQueue, InboxQueue, ObjectStorageQueue, SystemQueue, WebhookDeliverQueue } from '@/core/queue/QueueModule.js';
|
||||
import type { DbQueue, DeliverQueue, EndedPollNotificationQueue, InboxQueue, ObjectStorageQueue, SystemQueue, WebhookDeliverQueue } from '@/core/queue/QueueModule.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
|
|
@ -7,6 +7,7 @@ import { ModerationLogService } from '@/core/ModerationLogService.js';
|
|||
import { UserSuspendService } from '@/core/UserSuspendService.js';
|
||||
import { UserFollowingService } from '@/core/UserFollowingService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
@ -36,6 +37,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
@Inject(DI.notificationsRepository)
|
||||
private notificationsRepository: NotificationsRepository,
|
||||
|
||||
private userEntityService: UserEntityService,
|
||||
private userFollowingService: UserFollowingService,
|
||||
private userSuspendService: UserSuspendService,
|
||||
private moderationLogService: ModerationLogService,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import type { NotesRepository, AntennaNotesRepository } from '@/models/index.js';
|
||||
import type { NotesRepository, AntennaNotesRepository, AntennasRepository } from '@/models/index.js';
|
||||
import { QueryService } from '@/core/QueryService.js';
|
||||
import { NoteReadService } from '@/core/NoteReadService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
|
|
@ -44,7 +44,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||
private globalEventService: GlobalEventService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const channel = await Channels.findOneBy({
|
||||
const channel = await this.channelsRepository.findOneBy({
|
||||
id: ps.channelId,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { IsNull } from 'typeorm';
|
||||
import type { InstancesRepository, NotesRepository, UsersRepository } from '@/models/index.js';
|
||||
import type { InstancesRepository, NoteReactionsRepository, NotesRepository, UsersRepository } from '@/models/index.js';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
||||
|
|
|
@ -159,6 +159,7 @@ export class DiscordServerService {
|
|||
|
||||
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
||||
this.redisClient.get(sessid, async (_, state) => {
|
||||
if (state == null) throw new Error('empty state');
|
||||
res(JSON.parse(state));
|
||||
});
|
||||
});
|
||||
|
@ -169,22 +170,22 @@ export class DiscordServerService {
|
|||
}
|
||||
|
||||
const { accessToken, refreshToken, expiresDate } = await new Promise<any>((res, rej) =>
|
||||
oauth2!.getOAuthAccessToken(code, {
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri,
|
||||
}, (err, accessToken, refreshToken, result) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
} else if (result.error) {
|
||||
rej(result.error);
|
||||
} else {
|
||||
res({
|
||||
accessToken,
|
||||
refreshToken,
|
||||
expiresDate: Date.now() + Number(result.expires_in) * 1000,
|
||||
});
|
||||
}
|
||||
}));
|
||||
oauth2!.getOAuthAccessToken(code, {
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri,
|
||||
}, (err, accessToken, refreshToken, result) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
} else if (result.error) {
|
||||
rej(result.error);
|
||||
} else {
|
||||
res({
|
||||
accessToken,
|
||||
refreshToken,
|
||||
expiresDate: Date.now() + Number(result.expires_in) * 1000,
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
const { id, username, discriminator } = (await this.httpRequestService.getJson('https://discord.com/api/users/@me', '*/*', 10 * 1000, {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
|
@ -230,6 +231,7 @@ export class DiscordServerService {
|
|||
|
||||
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
||||
this.redisClient.get(userToken, async (_, state) => {
|
||||
if (state == null) throw new Error('empty state');
|
||||
res(JSON.parse(state));
|
||||
});
|
||||
});
|
||||
|
@ -240,22 +242,22 @@ export class DiscordServerService {
|
|||
}
|
||||
|
||||
const { accessToken, refreshToken, expiresDate } = await new Promise<any>((res, rej) =>
|
||||
oauth2!.getOAuthAccessToken(code, {
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri,
|
||||
}, (err, accessToken, refreshToken, result) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
} else if (result.error) {
|
||||
rej(result.error);
|
||||
} else {
|
||||
res({
|
||||
accessToken,
|
||||
refreshToken,
|
||||
expiresDate: Date.now() + Number(result.expires_in) * 1000,
|
||||
});
|
||||
}
|
||||
}));
|
||||
oauth2!.getOAuthAccessToken(code, {
|
||||
grant_type: 'authorization_code',
|
||||
redirect_uri,
|
||||
}, (err, accessToken, refreshToken, result) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
} else if (result.error) {
|
||||
rej(result.error);
|
||||
} else {
|
||||
res({
|
||||
accessToken,
|
||||
refreshToken,
|
||||
expiresDate: Date.now() + Number(result.expires_in) * 1000,
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
const { id, username, discriminator } = (await this.httpRequestService.getJson('https://discord.com/api/users/@me', '*/*', 10 * 1000, {
|
||||
'Authorization': `Bearer ${accessToken}`,
|
||||
|
|
|
@ -157,6 +157,7 @@ export class GithubServerService {
|
|||
|
||||
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
||||
this.redisClient.get(sessid, async (_, state) => {
|
||||
if (state == null) throw new Error('empty state');
|
||||
res(JSON.parse(state));
|
||||
});
|
||||
});
|
||||
|
@ -167,17 +168,17 @@ export class GithubServerService {
|
|||
}
|
||||
|
||||
const { accessToken } = await new Promise<any>((res, rej) =>
|
||||
oauth2!.getOAuthAccessToken(code, {
|
||||
redirect_uri,
|
||||
}, (err, accessToken, refresh, result) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
} else if (result.error) {
|
||||
rej(result.error);
|
||||
} else {
|
||||
res({ accessToken });
|
||||
}
|
||||
}));
|
||||
oauth2!.getOAuthAccessToken(code, {
|
||||
redirect_uri,
|
||||
}, (err, accessToken, refresh, result) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
} else if (result.error) {
|
||||
rej(result.error);
|
||||
} else {
|
||||
res({ accessToken });
|
||||
}
|
||||
}));
|
||||
|
||||
const { login, id } = (await this.httpRequestService.getJson('https://api.github.com/user', 'application/vnd.github.v3+json', 10 * 1000, {
|
||||
'Authorization': `bearer ${accessToken}`,
|
||||
|
@ -208,6 +209,7 @@ export class GithubServerService {
|
|||
|
||||
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
||||
this.redisClient.get(userToken, async (_, state) => {
|
||||
if (state == null) throw new Error('empty state');
|
||||
res(JSON.parse(state));
|
||||
});
|
||||
});
|
||||
|
@ -218,18 +220,18 @@ export class GithubServerService {
|
|||
}
|
||||
|
||||
const { accessToken } = await new Promise<any>((res, rej) =>
|
||||
oauth2!.getOAuthAccessToken(
|
||||
code,
|
||||
{ redirect_uri },
|
||||
(err, accessToken, refresh, result) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
} else if (result.error) {
|
||||
rej(result.error);
|
||||
} else {
|
||||
res({ accessToken });
|
||||
}
|
||||
}));
|
||||
oauth2!.getOAuthAccessToken(
|
||||
code,
|
||||
{ redirect_uri },
|
||||
(err, accessToken, refresh, result) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
} else if (result.error) {
|
||||
rej(result.error);
|
||||
} else {
|
||||
res({ accessToken });
|
||||
}
|
||||
}));
|
||||
|
||||
const { login, id } = (await this.httpRequestService.getJson('https://api.github.com/user', 'application/vnd.github.v3+json', 10 * 1000, {
|
||||
'Authorization': `bearer ${accessToken}`,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"strict": true,
|
||||
"strictNullChecks": true,
|
||||
"strictPropertyInitialization": false,
|
||||
"skipLibCheck": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"resolveJsonModule": true,
|
||||
|
|
Loading…
Reference in a new issue