mirror of
https://github.com/kokonect-link/cherrypick
synced 2025-01-19 08:13:14 +09:00
アップデート時のチェック
This commit is contained in:
parent
fda8cf5c7f
commit
f5cc70d943
@ -387,6 +387,11 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
||||
return (await this.emojisRepository.findOneBy({ name, host: IsNull() })) !== null;
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async getEmojiById(id: string): Promise<MiEmoji | null> {
|
||||
return this.emojisRepository.findOneBy({ id });
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public dispose(): void {
|
||||
this.cache.dispose();
|
||||
|
@ -74,9 +74,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId });
|
||||
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
|
||||
}
|
||||
if (ps.name) {
|
||||
const duplicateCheck = await this.customEmojiService.isDuplicateCheck(ps.name);
|
||||
if (duplicateCheck != null) throw new ApiError(meta.errors.sameNameEmojiExists);
|
||||
const oldemoji = await this.customEmojiService.getEmojiById(ps.id);
|
||||
if (oldemoji !== null) {
|
||||
if (ps.name !== oldemoji.name) {
|
||||
const duplicateCheck = await this.customEmojiService.isDuplicateCheck(ps.name);
|
||||
if (duplicateCheck) throw new ApiError(meta.errors.sameNameEmojiExists);
|
||||
}
|
||||
} else {
|
||||
throw new ApiError(meta.errors.noSuchEmoji);
|
||||
}
|
||||
|
||||
await this.customEmojiService.update(ps.id, {
|
||||
|
Loading…
Reference in New Issue
Block a user