Skip to content

Commit cc33b83

Browse files
dunaj-devclaude
andcommitted
Fix alias parsing and display
- Update alias parsing to match Docker Mailserver format "* source destination" - Remove aliases from email accounts as they are separate entities - Remove aliases column from accounts table - Improve regex for parsing email account storage info 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 146f110 commit cc33b83

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed

backend/dockerMailserver.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,9 @@ async function getAccounts() {
6464
try {
6565
const stdout = await execSetup('email list');
6666

67-
// Parse multiline output with regex to extract email, size, and aliases
67+
// Parse multiline output with regex to extract email and size information
6868
const accounts = [];
6969
const accountLineRegex = /^\* ([\w\-\.@]+) \( ([\w\~]+) \/ ([\w\~]+) \) \[(\d+)%\](.*)$/;
70-
const aliasesRegex = /aliases \-> (.*)\]/;
7170

7271
// Process each line individually
7372
const lines = stdout.split('\n').filter(line => line.trim().length > 0);
@@ -85,21 +84,13 @@ async function getAccounts() {
8584
const totalSpace = match[3] === '~' ? 'unlimited' : match[3];
8685
const usagePercent = match[4];
8786

88-
// Extract aliases if present in the current line
89-
let aliases = [];
90-
const aliasMatch = line.match(aliasesRegex);
91-
if (aliasMatch) {
92-
aliases = aliasMatch[1].split(',').map(alias => alias.trim());
93-
}
94-
9587
accounts.push({
9688
email,
9789
storage: {
9890
used: usedSpace,
9991
total: totalSpace,
10092
percent: usagePercent + '%'
101-
},
102-
aliases
93+
}
10394
});
10495
}
10596
}
@@ -138,15 +129,26 @@ async function deleteAccount(email) {
138129
async function getAliases() {
139130
try {
140131
const stdout = await execSetup('alias list');
141-
const aliases = stdout.split('\n')
142-
.filter(line => line.trim().length > 0)
143-
.map(line => {
144-
const parts = line.split(' -> ');
145-
return {
146-
source: parts[0].trim(),
147-
destination: parts[1].trim()
148-
};
149-
});
132+
const aliases = [];
133+
134+
// Parse each line in the format "* source destination"
135+
const lines = stdout.split('\n').filter(line => line.trim().length > 0);
136+
const aliasRegex = /^\* ([\w\-\.@]+) ([\w\-\.@]+)$/;
137+
138+
for (let i = 0; i < lines.length; i++) {
139+
const line = lines[i].trim();
140+
141+
if (line.startsWith('*')) {
142+
const match = line.match(aliasRegex);
143+
if (match) {
144+
aliases.push({
145+
source: match[1],
146+
destination: match[2]
147+
});
148+
}
149+
}
150+
}
151+
150152
return aliases;
151153
} catch (error) {
152154
console.error('Error retrieving aliases:', error);

frontend/src/pages/Accounts.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,6 @@ const Accounts = () => {
137137
</div>
138138
) : 'N/A'
139139
},
140-
{ key: 'aliases', label: 'accounts.aliases',
141-
render: (account) => account.aliases && account.aliases.length > 0 ? (
142-
<div>
143-
{account.aliases.map((alias, index) => (
144-
<span key={index} className="badge bg-secondary me-1 mb-1">{alias}</span>
145-
))}
146-
</div>
147-
) : <span className="text-muted"></span>
148-
},
149140
{ key: 'actions', label: 'accounts.actions',
150141
render: (account) => (
151142
<Button

0 commit comments

Comments
 (0)