Skip to content

Commit

Permalink
store IDN email-usernames in ACE, as dovecot/postfix need them this way
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p committed Sep 26, 2024
1 parent 40aa48a commit 140c6c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/Froxlor/Api/Commands/EmailDomains.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function listing()
$result = [];
$query_fields = [];
$result_stmt = Database::prepare("
SELECT DISTINCT d.domain, e.domainid,
SELECT DISTINCT d.domain, d.domain_ace, e.domainid,
COUNT(e.email) as addresses,
IFNULL(SUM(CASE WHEN e.popaccountid > 0 THEN 1 ELSE 0 END), 0) as accounts,
IFNULL(SUM(
Expand Down
16 changes: 10 additions & 6 deletions lib/Froxlor/Api/Commands/Emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,22 @@ public function add()
$description = $this->getParam('description', true, '');

// validation
$idna_convert = new IdnaWrapper();
if (substr($domain, 0, 4) != 'xn--') {
$idna_convert = new IdnaWrapper();
$domain = $idna_convert->encode(Validate::validate($domain, 'domain', '', '', [], true));
}
$email_part = $idna_convert->encode($email_part);

// check domain and whether it's an email-enabled domain
// use internal call because the customer might have 'domains' in customer_hide_options
$domain_check = $this->apiCall('SubDomains.get', [
'domainname' => $domain
], true);
if ((int)$domain_check['isemaildomain'] == 0) {
Response::standardError('maindomainnonexist', $domain, true);
Response::standardError('maindomainnonexist', $idna_convert->decode($domain), true);
}
if ((int)$domain_check['deactivated'] == 1) {
Response::standardError('maindomaindeactivated', $domain, true);
Response::standardError('maindomaindeactivated', $idna_convert->decode($domain), true);
}

if (Settings::Get('catchall.catchall_enabled') != '1') {
Expand All @@ -127,7 +128,7 @@ public function add()

// validate it
if (!Validate::validateEmail($email_full)) {
Response::standardError('emailiswrong', $email_full, true);
Response::standardError('emailiswrong', $idna_convert->decode($email_full), true);
}

// get needed customer info to reduce the email-address-counter by one
Expand All @@ -148,7 +149,7 @@ public function add()

if ($email_check) {
if (strtolower($email_check['email_full']) == strtolower($email_full)) {
Response::standardError('emailexistalready', $email_full, true);
Response::standardError('emailexistalready', $idna_convert->decode($email_full), true);
} elseif ($email_check['email'] == $email) {
Response::standardError('youhavealreadyacatchallforthisdomain', '', true);
}
Expand Down Expand Up @@ -226,7 +227,7 @@ public function get()
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON v.`popaccountid` = u.`id`
WHERE v.`customerid` IN (" . implode(", ", $customer_ids) . ")
AND " . (is_numeric($params['idea']) ? "v.`id`= :idea" : "(v.`email` = :idea OR v.`email_full` = :idea)"
));
));
$result = Database::pexecute_first($result_stmt, $params, true, true);
if ($result) {
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_INFO, "[API] get email address '" . $result['email_full'] . "'");
Expand Down Expand Up @@ -396,7 +397,10 @@ public function listing()
LEFT JOIN `" . TABLE_MAIL_USERS . "` u ON (m.`popaccountid` = u.`id`)
WHERE m.`customerid` IN (" . implode(", ", $customer_ids) . ")" . $this->getSearchWhere($query_fields, true) . $this->getOrderBy() . $this->getLimit());
Database::pexecute($result_stmt, $query_fields, true, true);
$idna_convert = new IdnaWrapper();
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
$row['email'] = $idna_convert->decode($row['email']);
$row['email_full'] = $idna_convert->decode($row['email_full']);
$result[] = $row;
}
$this->logger()->logAction($this->isAdmin() ? FroxlorLogger::ADM_ACTION : FroxlorLogger::USR_ACTION, LOG_INFO, "[API] list email-addresses");
Expand Down
2 changes: 2 additions & 0 deletions lib/Froxlor/Cron/Http/LetsEncrypt/AcmeSh.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ private static function issueDomains()
WHERE
dom.`customerid` = cust.`customerid`
AND cust.deactivated = 0
AND dom.deactivated = 0
AND dom.`ssl_enabled` = 1
AND dom.`letsencrypt` = 1
AND dom.`aliasdomain` IS NULL
Expand Down Expand Up @@ -383,6 +384,7 @@ private static function renewDomains($check = false)
WHERE
dom.`customerid` = cust.`customerid`
AND cust.deactivated = 0
AND dom.deactivated = 0
AND dom.`ssl_enabled` = 1
AND dom.`letsencrypt` = 1
AND dom.`aliasdomain` IS NULL
Expand Down
2 changes: 1 addition & 1 deletion lib/tablelisting/customer/tablelisting.emails_overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'self_overview' => ['section' => 'email', 'page' => 'overview'],
'default_sorting' => ['d.domain' => 'asc'],
'columns' => [
'd.domain' => [
'd.domain_ace' => [
'label' => 'Domain',
'field' => 'domain',
],
Expand Down

0 comments on commit 140c6c9

Please sign in to comment.