fix(backend): pagesのnameの重複チェックはnameプロパティがある時のみ行うように

This commit is contained in:
kakkokari-gtyih 2024-12-09 17:21:50 +09:00
parent dac3b1f405
commit 9288b5ad1f

View File

@ -102,15 +102,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}
}
await this.pagesRepository.findBy({
id: Not(ps.pageId),
userId: me.id,
name: ps.name,
}).then(result => {
if (result.length > 0) {
throw new ApiError(meta.errors.nameAlreadyExists);
}
});
if (ps.name != null) {
await this.pagesRepository.findBy({
id: Not(ps.pageId),
userId: me.id,
name: ps.name,
}).then(result => {
if (result.length > 0) {
throw new ApiError(meta.errors.nameAlreadyExists);
}
});
}
await this.pagesRepository.update(page.id, {
updatedAt: new Date(),