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 = { type UploadFromUrlArgs = {
url: string; 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; folderId?: DriveFolder['id'] | null;
uri?: string | null; uri?: string | null;
sensitive?: boolean; sensitive?: boolean;

View File

@ -13,20 +13,21 @@ import { HttpRequestService } from './HttpRequestService.js';
import type { DOMWindow } from 'jsdom'; import type { DOMWindow } from 'jsdom';
type NodeInfo = { type NodeInfo = {
openRegistrations?: any; openRegistrations?: unknown;
software?: { software?: {
name?: any; name?: unknown;
version?: any; version?: unknown;
}; };
metadata?: { metadata?: {
name?: any; name?: unknown;
nodeName?: any; nodeName?: unknown;
nodeDescription?: any; nodeDescription?: unknown;
description?: any; description?: unknown;
maintainer?: { maintainer?: {
name?: any; name?: unknown;
email?: any; email?: unknown;
}; };
themeColor?: unknown;
}; };
}; };
@ -81,7 +82,7 @@ export class FetchInstanceMetadataService {
} as Record<string, any>; } as Record<string, any>;
if (info) { 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.softwareVersion = info.software?.version;
updates.openRegistrations = info.openRegistrations; updates.openRegistrations = info.openRegistrations;
updates.maintainerName = info.metadata ? info.metadata.maintainer ? (info.metadata.maintainer.name ?? null) : null : null; 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> { private async getSiteName(info: NodeInfo | null, doc: DOMWindow['document'] | null, manifest: Record<string, any> | null): Promise<string | null> {
if (info && info.metadata) { if (info && info.metadata) {
if (info.metadata.nodeName || info.metadata.name) { if (typeof info.metadata.nodeName === 'string') {
return info.metadata.nodeName ?? info.metadata.name; 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> { private async getDescription(info: NodeInfo | null, doc: DOMWindow['document'] | null, manifest: Record<string, any> | null): Promise<string | null> {
if (info && info.metadata) { if (info && info.metadata) {
if (info.metadata.nodeDescription || info.metadata.description) { if (typeof info.metadata.nodeDescription === 'string') {
return info.metadata.nodeDescription ?? info.metadata.description; 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); 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); const obj = JSON.parse(data);
if (obj.channel === 'internal') { if (obj.channel === 'internal') {

View File

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

View File

@ -3,7 +3,7 @@ import { Inject, Injectable } from '@nestjs/common';
import bcrypt from 'bcryptjs'; import bcrypt from 'bcryptjs';
import { DataSource, IsNull } from 'typeorm'; import { DataSource, IsNull } from 'typeorm';
import { DI } from '@/di-symbols.js'; 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 type { Config } from '@/config.js';
import { User } from '@/models/entities/User.js'; import { User } from '@/models/entities/User.js';
import { UserProfile } from '@/models/entities/UserProfile.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 CACert = i + 1 >= certificates.length ? Cert : certificates[i + 1];
const certStruct = jsrsasign.ASN1HEX.getTLVbyList(certificate.hex!, 0, [0]); const certStruct = jsrsasign.ASN1HEX.getTLVbyList(certificate.hex!, 0, [0]);
if (certStruct == null) throw new Error('certStruct is null');
const algorithm = certificate.getSignatureAlgorithmField(); const algorithm = certificate.getSignatureAlgorithmField();
const signatureHex = certificate.getSignatureValueHex(); 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 { DI } from '@/di-symbols.js';
import logger from '@/logger.js'; import logger from '@/logger.js';
import type { UsersRepository, FollowingsRepository, FollowRequestsRepository, BlockingsRepository, UserListsRepository, UserListJoiningsRepository } from '@/models/index.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 { UserEntityService } from './entities/UserEntityService.js';
import { WebhookService } from './WebhookService.js'; import { WebhookService } from './WebhookService.js';
import { ApRendererService } from './remote/activitypub/ApRendererService.js'; import { ApRendererService } from './remote/activitypub/ApRendererService.js';
import { LoggerService } from './LoggerService.js';
@Injectable() @Injectable()
export class UserBlockingService { export class UserBlockingService {
private logger: Logger;
constructor( constructor(
@Inject(DI.usersRepository) @Inject(DI.usersRepository)
private usersRepository: UsersRepository, private usersRepository: UsersRepository,
@ -41,7 +45,9 @@ export class UserBlockingService {
private webhookService: WebhookService, private webhookService: WebhookService,
private apRendererService: ApRendererService, private apRendererService: ApRendererService,
private perUserFollowingChart: PerUserFollowingChart, private perUserFollowingChart: PerUserFollowingChart,
private loggerService: LoggerService,
) { ) {
this.logger = this.loggerService.getLogger('user-block');
} }
public async block(blocker: User, blockee: User) { public async block(blocker: User, blockee: User) {
@ -181,7 +187,7 @@ export class UserBlockingService {
}); });
if (blocking == null) { if (blocking == null) {
logger.warn('ブロック解除がリクエストされましたがブロックしていませんでした'); this.logger.warn('ブロック解除がリクエストされましたがブロックしていませんでした');
return; return;
} }

View File

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

View File

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

View File

@ -1,4 +1,5 @@
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { IsNull, Not } from 'typeorm';
import { Endpoint } from '@/server/api/endpoint-base.js'; import { Endpoint } from '@/server/api/endpoint-base.js';
import type { AccessTokensRepository } from '@/models/index.js'; import type { AccessTokensRepository } from '@/models/index.js';
import { AppEntityService } from '@/core/entities/AppEntityService.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({ const tokens = await this.accessTokensRepository.find({
where: { where: {
userId: me.id, userId: me.id,
appId: Not(IsNull()),
}, },
take: ps.limit, take: ps.limit,
skip: ps.offset, 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, detail: true,
}))); })));
}); });