Skip to content

Commit

Permalink
fix: added indexing to recipient search for aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Feb 22, 2024
1 parent 95e493b commit 5d74e68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/controllers/web/my-account/retrieve-aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,22 @@ async function retrieveAliases(ctx, next) {

if (isSANB(ctx.query.q)) {
if (ctx.state.domain.is_catchall_regex_disabled) {
query.$and.push({
name: ctx.query.q.split('@')[0].trim().toLowerCase()
});
if (isEmail(ctx.query.q)) {
query.$and.push({
$or: [
{
name: ctx.query.q.split('@')[0].trim().toLowerCase()
},
{
recipients: ctx.query.q.trim().toLowerCase()
}
]
});
} else {
query.$and.push({
name: ctx.query.q.split('@')[0].trim().toLowerCase()
});
}
} else {
query.$and.push({
$or: [
Expand Down
1 change: 1 addition & 0 deletions app/models/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ const Aliases = new mongoose.Schema({
],
recipients: [
{
index: true,
type: String,
trim: true,
// must be IP or FQDN or email
Expand Down

0 comments on commit 5d74e68

Please sign in to comment.