Allow tagging(mention) in Notes with username or display name (#137)

Signed-off-by: Harshil-Jani <harshiljani2002@gmail.com>
This commit is contained in:
Harshil Jani 2024-04-09 13:34:58 +05:30 committed by GitHub
parent 3fcd7fece8
commit 17be82375e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -298,6 +298,16 @@ export class ContentComponent {
} else {
i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: token.substring(6), token: decoded.type });
}
} else if (token.startsWith('@')) {
const username = token.substring(1);
const npub = this.profileService.following.find((follower) => follower.name === username)?.npub;
if (npub) {
const decoded = nip19.decode(npub);
const val = decoded.data as any;
i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: val, token: decoded.type });
} else {
res[i] += token;
}
} else if (token.startsWith('http://') || token.startsWith('https://')) {
if (this.isImage(token)) {
i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: token, token: 'image' });