strip "@." from local reaction names

This commit is contained in:
Hazelnoot 2025-03-24 15:54:59 -04:00
parent 58cdee77d5
commit 876ecb28f0

View file

@ -340,8 +340,21 @@ namespace MisskeyAPI {
return Object.entries(r).map(([key, count]) => { return Object.entries(r).map(([key, count]) => {
const me = myReaction != null && key === myReaction; const me = myReaction != null && key === myReaction;
// Translate the emoji name - "r" mapping includes a leading/trailing ":" // Name is equal to the key for native emoji reactions, and as a fallback.
const [,name] = key.match(/^:([^@:]+(?:@[^:]+)?):$/) ?? [null,key]; let name = key;
// Custom emoji have a leading / trailing ":", which we need to remove.
const match = key.match(/^:([^@:]+)(@[^:]+)?:$/);
if (match) {
const [, prefix, host] = match;
// Local custom emoji end in "@.", which we need to remove.
if (host && host !== '@.') {
name = prefix + host;
} else {
name = prefix;
}
}
return { return {
count, count,