fix: AP Services throwing errors

This commit is contained in:
Mar0xy 2023-09-22 22:42:01 +02:00
parent d9eead6ccc
commit ab57616483
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
2 changed files with 3 additions and 3 deletions

View file

@ -27,6 +27,6 @@ export class ApMfmService {
@bindThis @bindThis
public getNoteHtml(note: MiNote): string | null { public getNoteHtml(note: MiNote): string | null {
if (!note.text) return ''; if (!note.text) return '';
return this.mfmService.toHtml(mfm.parse(note.text), JSON.parse(note.mentionedRemoteUsers)); return this.mfmService.toHtml(mfm.parse(note.text), note.mentionedRemoteUsers ? JSON.parse(note.mentionedRemoteUsers) : []);
} }
} }

View file

@ -353,7 +353,7 @@ export class ApRendererService {
const attributedTo = this.userEntityService.genLocalUserUri(note.userId); const attributedTo = this.userEntityService.genLocalUserUri(note.userId);
const mentions = (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri); const mentions = note.mentionedRemoteUsers ? (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri) : [];
let to: string[] = []; let to: string[] = [];
let cc: string[] = []; let cc: string[] = [];
@ -371,7 +371,7 @@ export class ApRendererService {
to = mentions; to = mentions;
} }
const mentionedUsers = note.mentions.length > 0 ? await this.usersRepository.findBy({ const mentionedUsers = note.mentions && note.mentions.length > 0 ? await this.usersRepository.findBy({
id: In(note.mentions), id: In(note.mentions),
}) : []; }) : [];