refactor: fix types

This commit is contained in:
syuilo 2023-02-12 20:06:10 +09:00
parent 5d3d5cd59c
commit a71682f6f0

View file

@ -24,7 +24,7 @@ import type { UsersRepository, UserProfilesRepository, NotesRepository, DriveFil
import { bindThis } from '@/decorators.js'; import { bindThis } from '@/decorators.js';
import { LdSignatureService } from './LdSignatureService.js'; import { LdSignatureService } from './LdSignatureService.js';
import { ApMfmService } from './ApMfmService.js'; import { ApMfmService } from './ApMfmService.js';
import type { IAccept, IActivity, IAdd, IAnnounce, IApDocument, IApEmoji, IApHashtag, IApImage, IApMention, IBlock, ICreate, IDelete, IFlag, IFollow, IKey, ILike, IObject, IQuestion, IRead, IReject, IRemove, ITombstone, IUndo, IUpdate } from './type.js'; import type { IAccept, IActivity, IAdd, IAnnounce, IApDocument, IApEmoji, IApHashtag, IApImage, IApMention, IBlock, ICreate, IDelete, IFlag, IFollow, IKey, ILike, IObject, IPost, IQuestion, IRead, IReject, IRemove, ITombstone, IUndo, IUpdate } from './type.js';
import type { IIdentifier } from './models/identifier.js'; import type { IIdentifier } from './models/identifier.js';
@Injectable() @Injectable()
@ -293,7 +293,7 @@ export class ApRendererService {
} }
@bindThis @bindThis
public async renderNote(note: Note, dive = true, isTalk = false): Promise<IObject> { public async renderNote(note: Note, dive = true, isTalk = false): Promise<IPost> {
const getPromisedFiles = async (ids: string[]) => { const getPromisedFiles = async (ids: string[]) => {
if (!ids || ids.length === 0) return []; if (!ids || ids.length === 0) return [];
const items = await this.driveFilesRepository.findBy({ id: In(ids) }); const items = await this.driveFilesRepository.findBy({ id: In(ids) });
@ -406,11 +406,11 @@ export class ApRendererService {
totalItems: poll!.votes[i], totalItems: poll!.votes[i],
}, },
})), })),
} : {}; } as const : {};
const asTalk = isTalk ? { const asTalk = isTalk ? {
_misskey_talk: true, _misskey_talk: true,
} : {}; } as const : {};
return { return {
id: `${this.config.url}/notes/${note.id}`, id: `${this.config.url}/notes/${note.id}`,
@ -515,7 +515,7 @@ export class ApRendererService {
} }
@bindThis @bindThis
public async renderQuestion(user: { id: User['id'] }, note: Note, poll: Poll): IQuestion { public renderQuestion(user: { id: User['id'] }, note: Note, poll: Poll): IQuestion {
return { return {
type: 'Question', type: 'Question',
id: `${this.config.url}/questions/${note.id}`, id: `${this.config.url}/questions/${note.id}`,