Skip to content

Commit

Permalink
fix(backend): 絵文字を編集すると保存できないことがある問題を修正
Browse files Browse the repository at this point in the history
Fix #10384
  • Loading branch information
syuilo committed Mar 22, 2023
1 parent fb42721 commit 0507872
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

## 13.10.2

### Server
- 絵文字を編集すると保存できないことがある問題を修正

### Client
- ドライブファイルのメニューが正常に動作しない問題を修正

Expand Down
12 changes: 6 additions & 6 deletions packages/backend/src/server/api/endpoints/admin/emoji/update.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Injectable } from '@nestjs/common';
import { DataSource } from 'typeorm';
import { DataSource, IsNull } from 'typeorm';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type { EmojisRepository } from '@/models/index.js';
import { DI } from '@/di-symbols.js';
Expand All @@ -19,9 +19,9 @@ export const meta = {
code: 'NO_SUCH_EMOJI',
id: '684dec9d-a8c2-4364-9aa8-456c49cb1dc8',
},
alreadyexistsemoji: {
message: 'Emoji already exists',
code: 'EMOJI_ALREADY_EXISTS',
sameNameEmojiExists: {
message: 'Emoji that have same name already exists.',
code: 'SAME_NAME_EMOJI_EXISTS',
id: '7180fe9d-1ee3-bff9-647d-fe9896d2ffb8',
},
},
Expand Down Expand Up @@ -62,9 +62,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 });
const sameNameEmoji = await this.emojisRepository.findOneBy({ name: ps.name, host: IsNull() });
if (emoji == null) throw new ApiError(meta.errors.noSuchEmoji);
if (emojiname != null && emojiname.id !== ps.id) throw new ApiError(meta.errors.alreadyexistsemoji);
if (sameNameEmoji != null && sameNameEmoji.id !== ps.id) throw new ApiError(meta.errors.sameNameEmojiExists);
await this.emojisRepository.update(emoji.id, {
updatedAt: new Date(),
name: ps.name,
Expand Down

0 comments on commit 0507872

Please sign in to comment.