feat: mentions support

This commit is contained in:
Julian Lam
2024-03-05 14:24:13 -05:00
parent 1b64fdb5b3
commit e4c1ca1ede
6 changed files with 73 additions and 25 deletions

View File

@@ -235,9 +235,17 @@ Mocks.note = async (post) => {
if (matches.size) {
tag = tag || [];
Array.from(matches).map(match => ({
type: 'Mention',
name: match,
tag.push(...Array.from(matches).map(({ id: href, slug: name }) => {
if (utils.isNumber(href)) { // local ref
href = `${nconf.get('url')}/user/${name.slice(1)}`;
name = `${name}@${nconf.get('url_parsed').hostname}`;
}
return {
type: 'Mention',
href,
name,
};
}));
}
}