fix: fix a problem which custom domain canot direct save by domain check
This commit is contained in:
parent
ccf7b8d4aa
commit
e2fc9224c7
@ -50,10 +50,13 @@ class MonitorPageManager {
|
||||
* check domain existed
|
||||
* if domain not been used, return true
|
||||
*/
|
||||
async checkDomain(domain: string) {
|
||||
async checkDomain(domain: string, excludeMonitorId?: string) {
|
||||
const res = await prisma.monitorStatusPage.findFirst({
|
||||
where: {
|
||||
domain,
|
||||
id: {
|
||||
notIn: excludeMonitorId ? [excludeMonitorId] : [],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -684,8 +684,8 @@ export const monitorRouter = router({
|
||||
}
|
||||
}
|
||||
|
||||
if (domain && !(await monitorPageManager.checkDomain(domain))) {
|
||||
throw new Error('This domain has been used');
|
||||
if (domain && !(await monitorPageManager.checkDomain(domain, id))) {
|
||||
throw new Error('This domain has been used by others');
|
||||
}
|
||||
|
||||
const page = await prisma.monitorStatusPage.update({
|
||||
|
Loading…
Reference in New Issue
Block a user