This commit is contained in:
syuilo 2022-09-24 07:12:11 +09:00
parent 417f52359d
commit c8f6bc0dab
10 changed files with 37 additions and 25 deletions

View file

@ -61,7 +61,7 @@ type AddFileArgs = {
type UploadFromUrlArgs = {
url: string;
user: { id: User['id']; host: User['host'] } | null;
user: { id: User['id']; host: User['host']; driveCapacityOverrideMb: User['driveCapacityOverrideMb'] } | null;
folderId?: DriveFolder['id'] | null;
uri?: string | null;
sensitive?: boolean;

View file

@ -13,20 +13,21 @@ import { HttpRequestService } from './HttpRequestService.js';
import type { DOMWindow } from 'jsdom';
type NodeInfo = {
openRegistrations?: any;
openRegistrations?: unknown;
software?: {
name?: any;
version?: any;
name?: unknown;
version?: unknown;
};
metadata?: {
name?: any;
nodeName?: any;
nodeDescription?: any;
description?: any;
name?: unknown;
nodeName?: unknown;
nodeDescription?: unknown;
description?: unknown;
maintainer?: {
name?: any;
email?: any;
name?: unknown;
email?: unknown;
};
themeColor?: unknown;
};
};
@ -81,7 +82,7 @@ export class FetchInstanceMetadataService {
} as Record<string, any>;
if (info) {
updates.softwareName = info.software?.name.toLowerCase();
updates.softwareName = typeof info.software?.name === 'string' ? info.software.name.toLowerCase() : '?';
updates.softwareVersion = info.software?.version;
updates.openRegistrations = info.openRegistrations;
updates.maintainerName = info.metadata ? info.metadata.maintainer ? (info.metadata.maintainer.name ?? null) : null : null;
@ -238,8 +239,10 @@ export class FetchInstanceMetadataService {
private async getSiteName(info: NodeInfo | null, doc: DOMWindow['document'] | null, manifest: Record<string, any> | null): Promise<string | null> {
if (info && info.metadata) {
if (info.metadata.nodeName || info.metadata.name) {
return info.metadata.nodeName ?? info.metadata.name;
if (typeof info.metadata.nodeName === 'string') {
return info.metadata.nodeName;
} else if (typeof info.metadata.name === 'string') {
return info.metadata.name;
}
}
@ -260,8 +263,10 @@ export class FetchInstanceMetadataService {
private async getDescription(info: NodeInfo | null, doc: DOMWindow['document'] | null, manifest: Record<string, any> | null): Promise<string | null> {
if (info && info.metadata) {
if (info.metadata.nodeDescription || info.metadata.description) {
return info.metadata.nodeDescription ?? info.metadata.description;
if (typeof info.metadata.nodeDescription === 'string') {
return info.metadata.nodeDescription;
} else if (typeof info.metadata.description === 'string') {
return info.metadata.description;
}
}

View file

@ -34,7 +34,7 @@ export class MetaService implements OnApplicationShutdown {
this.redisSubscriber.on('message', this.onMessage);
}
private async onMessage(_, data): Promise<void> {
private async onMessage(_: string, data: string): Promise<void> {
const obj = JSON.parse(data);
if (obj.channel === 'internal') {

View file

@ -534,7 +534,6 @@ export class NoteCreateService {
});
const nm = new NotificationManager(this.mutingsRepository, this.createNotificationService, user, note);
const nmRelatedPromises = [];
await this.createMentionedEvents(mentionedUsers, note, nm);
@ -583,9 +582,7 @@ export class NoteCreateService {
}
}
Promise.all(nmRelatedPromises).then(() => {
nm.deliver();
});
nm.deliver();
//#region AP deliver
if (this.userEntityService.isLocalUser(user)) {

View file

@ -3,7 +3,7 @@ import { Inject, Injectable } from '@nestjs/common';
import bcrypt from 'bcryptjs';
import { DataSource, IsNull } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { UsedUsernamesRepository } from '@/models/index.js';
import type { UsedUsernamesRepository, UsersRepository } from '@/models/index.js';
import type { Config } from '@/config.js';
import { User } from '@/models/entities/User.js';
import { UserProfile } from '@/models/entities/UserProfile.js';

View file

@ -67,6 +67,8 @@ function verifyCertificateChain(certificates: string[]) {
const CACert = i + 1 >= certificates.length ? Cert : certificates[i + 1];
const certStruct = jsrsasign.ASN1HEX.getTLVbyList(certificate.hex!, 0, [0]);
if (certStruct == null) throw new Error('certStruct is null');
const algorithm = certificate.getSignatureAlgorithmField();
const signatureHex = certificate.getSignatureValueHex();

View file

@ -9,12 +9,16 @@ import PerUserFollowingChart from '@/core/chart/charts/per-user-following.js';
import { DI } from '@/di-symbols.js';
import logger from '@/logger.js';
import type { UsersRepository, FollowingsRepository, FollowRequestsRepository, BlockingsRepository, UserListsRepository, UserListJoiningsRepository } from '@/models/index.js';
import Logger from '@/logger.js';
import { UserEntityService } from './entities/UserEntityService.js';
import { WebhookService } from './WebhookService.js';
import { ApRendererService } from './remote/activitypub/ApRendererService.js';
import { LoggerService } from './LoggerService.js';
@Injectable()
export class UserBlockingService {
private logger: Logger;
constructor(
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
@ -41,7 +45,9 @@ export class UserBlockingService {
private webhookService: WebhookService,
private apRendererService: ApRendererService,
private perUserFollowingChart: PerUserFollowingChart,
private loggerService: LoggerService,
) {
this.logger = this.loggerService.getLogger('user-block');
}
public async block(blocker: User, blockee: User) {
@ -181,7 +187,7 @@ export class UserBlockingService {
});
if (blocking == null) {
logger.warn('ブロック解除がリクエストされましたがブロックしていませんでした');
this.logger.warn('ブロック解除がリクエストされましたがブロックしていませんでした');
return;
}

View file

@ -33,7 +33,7 @@ export class UserCacheService implements OnApplicationShutdown {
this.redisSubscriber.on('message', this.onMessage);
}
private async onMessage(_, data) {
private async onMessage(_: string, data: string): Promise<void> {
const obj = JSON.parse(data);
if (obj.channel === 'internal') {

View file

@ -32,7 +32,7 @@ export class WebhookService implements OnApplicationShutdown {
return this.webhooks;
}
private async onMessage(_, data) {
private async onMessage(_: string, data: string): Promise<void> {
const obj = JSON.parse(data);
if (obj.channel === 'internal') {

View file

@ -1,4 +1,5 @@
import { Inject, Injectable } from '@nestjs/common';
import { IsNull, Not } from 'typeorm';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { AccessTokensRepository } from '@/models/index.js';
import { AppEntityService } from '@/core/entities/AppEntityService.js';
@ -34,6 +35,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const tokens = await this.accessTokensRepository.find({
where: {
userId: me.id,
appId: Not(IsNull()),
},
take: ps.limit,
skip: ps.offset,
@ -42,7 +44,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
},
});
return await Promise.all(tokens.map(token => this.appEntityService.pack(token.appId, me, {
return await Promise.all(tokens.map(token => this.appEntityService.pack(token.appId!, me, {
detail: true,
})));
});