Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

絵文字の名前に@や:が使用できる #9964

Merged
merged 6 commits into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/backend/src/server/api/endpoints/admin/emoji/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ export const meta = {
code: 'NO_SUCH_EMOJI',
id: '684dec9d-a8c2-4364-9aa8-456c49cb1dc8',
},
alreadyexistsemoji: {
message: 'Emoji already exists',
code: 'EMOJI_ALREADY_EXISTS',
id: '7180fe9d-1ee3-bff9-647d-fe9896d2ffb8',
},
},
} as const;

export const paramDef = {
type: 'object',
properties: {
id: { type: 'string', format: 'misskey:id' },
name: { type: 'string' },
name: { type: 'string', pattern: '^[a-zA-Z0-9_]+$' },
category: {
type: 'string',
nullable: true,
Expand Down Expand Up @@ -56,9 +61,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
) {
super(meta, paramDef, async (ps, me) => {
const emoji = await this.emojisRepository.findOneBy({ id: ps.id });

const emojiname = await this.emojisRepository.findOneBy({ name: ps.name });
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);

if (emojiname != null && emojiname.id !== ps.id) throw new ApiError(meta.errors.alreadyexistsemoji);
await this.emojisRepository.update(emoji.id, {
updatedAt: new Date(),
name: ps.name,
Expand Down