forked from FoundKeyGang/FoundKey
add check if ids.length > 0 before executing query
This commit is contained in:
parent
19e29c3465
commit
199622b415
1 changed files with 21 additions and 19 deletions
|
@ -105,13 +105,14 @@ export async function toHtml(mfmText: string, mentions?: string[]): Promise<stri
|
||||||
async mention(node): Promise<HTMLElement | Text> {
|
async mention(node): Promise<HTMLElement | Text> {
|
||||||
const { username, host, acct } = node.props;
|
const { username, host, acct } = node.props;
|
||||||
const ids = mentions ?? extractMentions(nodes);
|
const ids = mentions ?? extractMentions(nodes);
|
||||||
|
if (ids.length > 0) {
|
||||||
const mentionedUsers = await UserProfiles.createQueryBuilder('user_profile')
|
const mentionedUsers = await UserProfiles.createQueryBuilder('user_profile')
|
||||||
.leftJoin('user_profile.user', 'user')
|
.leftJoin('user_profile.user', 'user')
|
||||||
.select('user.username')
|
.select('user.username')
|
||||||
.addSelect('user.host')
|
.addSelect('user.host')
|
||||||
// links should preferably use user friendly urls, only fall back to AP ids
|
// links should preferably use user friendly urls, only fall back to AP ids
|
||||||
.addSelect('COALESCE(user_profile.url, user.uri)', 'url')
|
.addSelect('COALESCE(user_profile.url, user.uri)', 'url')
|
||||||
.where('userId IN (:...ids)', { ids })
|
.where('"userId" IN (:...ids)', { ids })
|
||||||
.getMany();
|
.getMany();
|
||||||
const userInfo = mentionedUsers.find(user => user.user?.username === username && user.userHost === host);
|
const userInfo = mentionedUsers.find(user => user.user?.username === username && user.userHost === host);
|
||||||
if (userInfo != null) {
|
if (userInfo != null) {
|
||||||
|
@ -126,6 +127,7 @@ export async function toHtml(mfmText: string, mentions?: string[]): Promise<stri
|
||||||
card.appendChild(a);
|
card.appendChild(a);
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// this user does not actually exist
|
// this user does not actually exist
|
||||||
return doc.createTextNode(acct);
|
return doc.createTextNode(acct);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue