fix: fix a problem which custom domain canot direct save by domain check

This commit is contained in:
moonrailgun 2024-04-21 18:09:48 +08:00
parent ccf7b8d4aa
commit e2fc9224c7
2 changed files with 6 additions and 3 deletions

View File

@ -50,10 +50,13 @@ class MonitorPageManager {
* check domain existed * check domain existed
* if domain not been used, return true * if domain not been used, return true
*/ */
async checkDomain(domain: string) { async checkDomain(domain: string, excludeMonitorId?: string) {
const res = await prisma.monitorStatusPage.findFirst({ const res = await prisma.monitorStatusPage.findFirst({
where: { where: {
domain, domain,
id: {
notIn: excludeMonitorId ? [excludeMonitorId] : [],
},
}, },
}); });

View File

@ -684,8 +684,8 @@ export const monitorRouter = router({
} }
} }
if (domain && !(await monitorPageManager.checkDomain(domain))) { if (domain && !(await monitorPageManager.checkDomain(domain, id))) {
throw new Error('This domain has been used'); throw new Error('This domain has been used by others');
} }
const page = await prisma.monitorStatusPage.update({ const page = await prisma.monitorStatusPage.update({