Fix SOGo login

listAllMailboxes query was mangled
This commit is contained in:
Girish Ramakrishnan
2021-01-28 22:21:18 -08:00
parent ef68cb70c0
commit a842d77b6d
3 changed files with 16 additions and 2 deletions
+2 -2
View File
@@ -262,8 +262,8 @@ function listAllMailboxes(page, perPage, callback) {
assert.strictEqual(typeof callback, 'function');
const query = 'SELECT m1.name AS name, m1.domain AS domain, m1.ownerId AS ownerId, m1.ownerType as ownerType, JSON_ARRAYAGG(m2.name) AS aliasNames, JSON_ARRAYAGG(m2.domain) AS aliasDomains '
+ ` FROM (SELECT * FROM mailboxes WHERE type='${exports.TYPE_MAILBOX}') AS m1` +
+ ` LEFT JOIN (SELECT * FROM mailboxes WHERE type='${exports.TYPE_ALIAS}') AS m2` +
+ ` FROM (SELECT * FROM mailboxes WHERE type='${exports.TYPE_MAILBOX}') AS m1`
+ ` LEFT JOIN (SELECT * FROM mailboxes WHERE type='${exports.TYPE_ALIAS}') AS m2`
+ ' ON m1.name=m2.aliasName AND m1.domain=m2.aliasDomain AND m1.ownerId=m2.ownerId'
+ ' GROUP BY m1.name, m1.domain, m1.ownerId'
+ ' ORDER BY name LIMIT ?,?';
+13
View File
@@ -1863,6 +1863,19 @@ describe('database', function () {
});
});
it('list all mailboxes succeeds', function (done) {
mailboxdb.listAllMailboxes(1, 10, function (error, mailboxes) {
expect(error).to.be(null);
expect(mailboxes.length).to.be(2);
expect(mailboxes[0].name).to.be('girish');
expect(mailboxes[1].name).to.be('support');
expect(mailboxes[1].domain).to.be(DOMAIN_0.domain);
done();
});
});
it('can get aliases of name', function (done) {
mailboxdb.getAliasesForName('support', DOMAIN_0.domain, function (error, results) {
expect(error).to.be(null);