feat: improve emoji endpoint (#13742)

This commit is contained in:
Cocoa Hoto 2024-04-25 11:03:34 +09:00 committed by GitHub
parent 553ba84792
commit 85339ca751
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 3 deletions

View File

@ -120,12 +120,20 @@ export class ServerService implements OnApplicationShutdown {
return; return;
} }
const name = path.split('@')[0].replace(/\.webp$/i, ''); const emojiPath = path.replace(/\.webp$/i, '');
const host = path.split('@')[1]?.replace(/\.webp$/i, ''); const pathChunks = emojiPath.split('@');
if (pathChunks.length > 2) {
reply.code(400);
return;
}
const name = pathChunks.shift();
const host = pathChunks.pop();
const emoji = await this.emojisRepository.findOneBy({ const emoji = await this.emojisRepository.findOneBy({
// `@.` is the spec of ReactionService.decodeReaction // `@.` is the spec of ReactionService.decodeReaction
host: (host == null || host === '.') ? IsNull() : host, host: (host === undefined || host === '.') ? IsNull() : host,
name: name, name: name,
}); });