diff --git a/web/html/xui/client_modal.html b/web/html/xui/client_modal.html
index fc3ea1e1..3113b461 100644
--- a/web/html/xui/client_modal.html
+++ b/web/html/xui/client_modal.html
@@ -230,20 +230,29 @@
},
methods: {
makeGroupEmailsUnique(dbInbounds, baseEmail, groupClients) {
+ // Extract the base part of the email (before the "__" if present)
const match = baseEmail.match(/^(.*?)__/);
- let base = match ? match[1] : baseEmail;
+ const base = match ? match[1] : baseEmail;
+ // Generate initial emails for each client in the group
const generatedEmails = groupClients.map((_, index) => `${base}__${index + 1}`);
- const isDuplicate = (emailToCheck) => {
+ // Function to check if an email already exists in dbInbounds but belongs to a different subId
+ const isDuplicate = (emailToCheck, clientSubId) => {
return dbInbounds.some((dbInbound) => {
const settings = JSON.parse(dbInbound.settings);
const clients = settings && settings.clients ? settings.clients : [];
- return clients.some(client => emailToCheck.includes(client.email));
+ return clients.some(client => client.email === emailToCheck && client.subId !== clientSubId);
});
};
- if (generatedEmails.some(email => isDuplicate(email))) {
+ // Check if any of the generated emails are duplicates
+ const hasDuplicates = generatedEmails.some((email, index) => {
+ return isDuplicate(email, groupClients[index].subId);
+ });
+
+ // If duplicates exist, add a random string to the base email to ensure uniqueness
+ if (hasDuplicates) {
const randomString = `-${RandomUtil.randomLowerAndNum(4)}`;
return groupClients.map((_, index) => `${base}${randomString}__${index + 1}`);
}
diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html
index 23e697b8..dce0da0b 100644
--- a/web/html/xui/inbounds.html
+++ b/web/html/xui/inbounds.html
@@ -1017,8 +1017,11 @@
okText: '{{ i18n "pages.client.submitAdd"}}',
dbInbounds: this.dbInbounds,
confirm: async (clients, dbInboundIds) => {
- await this.addGroupClient(clients, dbInboundIds, clientModal);
- await this.showQrcode(dbInboundIds[0],clients[0], true)
+ await this.addGroupClient(clients, dbInboundIds, clientModal).then((res) => {
+ if(res){
+ this.showQrcode(dbInboundIds[0],clients[0], true)
+ }
+ });
},
isEdit: false
});
@@ -1030,8 +1033,11 @@
okText: '{{ i18n "pages.client.submitAdd"}}',
dbInbound: dbInbound,
confirm: async (clients, dbInboundId) => {
- await this.addClient(clients, dbInboundId, clientModal);
- await this.showQrcode(dbInboundId,clients)
+ await this.addClient(clients, dbInboundId, clientModal).then((res) => {
+ if(res){
+ this.showQrcode(dbInboundId,clients)
+ }
+ });
},
isEdit: false
});