Fix: typeerror

Signed-off-by: mattyatea <mattyacocacora0@gmail.com>
This commit is contained in:
mattyatea 2023-10-27 06:12:55 +09:00
parent bfd817ae10
commit e71db2462e
No known key found for this signature in database
GPG Key ID: 068E54E2C33BEF9A
1 changed files with 24 additions and 12 deletions

View File

@ -38,6 +38,8 @@ import { MetaService } from '@/core/MetaService.js';
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js'; import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
import type { AccountMoveService } from '@/core/AccountMoveService.js'; import type { AccountMoveService } from '@/core/AccountMoveService.js';
import { checkHttps } from '@/misc/check-https.js'; import { checkHttps } from '@/misc/check-https.js';
import emojis from '@/server/api/endpoints/emojis.js';
import { MiAvatarDecoration } from '@/models/_.js';
import { getApId, getApType, getOneApHrefNullable, isActor, isCollection, isCollectionOrOrderedCollection, isPropertyValue } from '../type.js'; import { getApId, getApType, getOneApHrefNullable, isActor, isCollection, isCollectionOrOrderedCollection, isPropertyValue } from '../type.js';
import { extractApHashtags } from './tag.js'; import { extractApHashtags } from './tag.js';
import type { OnModuleInit } from '@nestjs/common'; import type { OnModuleInit } from '@nestjs/common';
@ -292,12 +294,21 @@ export class ApPersonService implements OnModuleInit {
//#endregion //#endregion
//#region アバターデコレーション取得 //#region アバターデコレーション取得
const avatardecorations = await this.apNoteService.extractAvatarDecorations(person.tag ?? [], host) const _avatarDecorations = await this.apNoteService.extractAvatarDecorations(person.tag ?? [], host)
.then(_decorations => _decorations.map(decorations => decorations.name))
.catch(err => { .catch(err => {
this.logger.error('error occurred while fetching user avatar decorations', { stack: err }); this.logger.error('error occurred while fetching user avatar decorations', { stack: err });
return []; return [];
}); });
const avatarDecorations: {id: string, angle: number, flipH: boolean}[] = [];
_avatarDecorations.forEach((value, index) => {
avatarDecorations.push({
id: value.id,
angle: person.AvatarDecorations ? person.AvatarDecorations[index].angle : 0,
flipH: person.AvatarDecorations ? person.AvatarDecorations[index].flipH : false,
});
});
//#endregion //#endregion
try { try {
@ -326,7 +337,7 @@ export class ApPersonService implements OnModuleInit {
isBot, isBot,
isCat: (person as any).isCat === true, isCat: (person as any).isCat === true,
emojis, emojis,
avatarDecorations: avatardecorations, avatarDecorations,
})) as MiRemoteUser; })) as MiRemoteUser;
await transactionalEntityManager.save(new MiUserProfile({ await transactionalEntityManager.save(new MiUserProfile({
@ -429,19 +440,20 @@ export class ApPersonService implements OnModuleInit {
this.logger.info(`Updating the Person: ${person.id}`); this.logger.info(`Updating the Person: ${person.id}`);
const avatardecorations = await this.apNoteService.extractAvatarDecorations(person.tag ?? [], exist.host) const _avatarDecorations = await this.apNoteService.extractAvatarDecorations(person.tag ?? [], exist.host)
.catch(err => { .catch(err => {
this.logger.error('error occurred while fetching user avatar decorations', { stack: err }); this.logger.error('error occurred while fetching user avatar decorations', { stack: err });
return []; return [];
}); });
avatardecorations.forEach((value, index) => { const avatarDecorations: {id: string, angle: number, flipH: boolean}[] = [];
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore _avatarDecorations.forEach((value, index) => {
avatardecorations[index].flipH = person.AvatarDecorations[index].flipH; avatarDecorations.push({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment id: value.id,
// @ts-ignore angle: person.AvatarDecorations ? person.AvatarDecorations[index].angle : 0,
avatardecorations[index].angle = person.AvatarDecorations[index].angle; flipH: person.AvatarDecorations ? person.AvatarDecorations[index].flipH : false,
});
}); });
// カスタム絵文字取得 // カスタム絵文字取得
@ -478,7 +490,7 @@ export class ApPersonService implements OnModuleInit {
movedToUri: person.movedTo ?? null, movedToUri: person.movedTo ?? null,
alsoKnownAs: person.alsoKnownAs ?? null, alsoKnownAs: person.alsoKnownAs ?? null,
isExplorable: person.discoverable, isExplorable: person.discoverable,
avatarDecorations: avatardecorations, avatarDecorations,
...(await this.resolveAvatarAndBanner(exist, person.icon, person.image).catch(() => ({}))), ...(await this.resolveAvatarAndBanner(exist, person.icon, person.image).catch(() => ({}))),
} as Partial<MiRemoteUser> & Pick<MiRemoteUser, 'isBot' | 'isCat' | 'isLocked' | 'movedToUri' | 'alsoKnownAs' | 'isExplorable'>; } as Partial<MiRemoteUser> & Pick<MiRemoteUser, 'isBot' | 'isCat' | 'isLocked' | 'movedToUri' | 'alsoKnownAs' | 'isExplorable'>;
const moving = ((): boolean => { const moving = ((): boolean => {