Skip to content

Commit

Permalink
feat: improve emoji endpoint (misskey-dev#13742)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoto-Cocoa authored Apr 25, 2024
1 parent 553ba84 commit 85339ca
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/backend/src/server/ServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,20 @@ export class ServerService implements OnApplicationShutdown {
return;
}

const name = path.split('@')[0].replace(/\.webp$/i, '');
const host = path.split('@')[1]?.replace(/\.webp$/i, '');
const emojiPath = path.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({
// `@.` is the spec of ReactionService.decodeReaction
host: (host == null || host === '.') ? IsNull() : host,
host: (host === undefined || host === '.') ? IsNull() : host,
name: name,
});

Expand Down

0 comments on commit 85339ca

Please sign in to comment.