アップデート時のチェック
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;
|
return (await this.emojisRepository.findOneBy({ name, host: IsNull() })) !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async getEmojiById(id: string): Promise<MiEmoji | null> {
|
||||||
|
return this.emojisRepository.findOneBy({ id });
|
||||||
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public dispose(): void {
|
public dispose(): void {
|
||||||
this.cache.dispose();
|
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 });
|
driveFile = await this.driveFilesRepository.findOneBy({ id: ps.fileId });
|
||||||
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
|
if (driveFile == null) throw new ApiError(meta.errors.noSuchFile);
|
||||||
}
|
}
|
||||||
if (ps.name) {
|
const oldemoji = await this.customEmojiService.getEmojiById(ps.id);
|
||||||
const duplicateCheck = await this.customEmojiService.isDuplicateCheck(ps.name);
|
if (oldemoji !== null) {
|
||||||
if (duplicateCheck != null) throw new ApiError(meta.errors.sameNameEmojiExists);
|
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, {
|
await this.customEmojiService.update(ps.id, {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue