Skip to content

Commit

Permalink
fix: allow empty recipients input for aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Jan 25, 2025
1 parent 994ce77 commit 41f74f7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
10 changes: 0 additions & 10 deletions app/models/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ Aliases.pre('save', async function (next) {
}
});

// eslint-disable-next-line complexity
Aliases.pre('validate', function (next) {
// if storage used was below zero then set to zero
if (this.storage_used < 0) this.storage_used = 0;
Expand Down Expand Up @@ -440,15 +439,6 @@ Aliases.pre('validate', function (next) {
if (isSANB(this.description)) this.description = striptags(this.description);
if (!isSANB(this.description)) this.description = undefined;

// alias must have at least one recipient
if (
!this.has_imap &&
(!_.isArray(this.recipients) || _.isEmpty(this.recipients))
)
return next(
Boom.badRequest('Alias must have at least one recipient or IMAP enabled.')
);

next();
});

Expand Down
4 changes: 2 additions & 2 deletions helpers/get-forwarding-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ async function getForwardingConfiguration({
// then filter out recipients that haven't yet clicked
// the verification link required and sent
// (but if and only if the domain was not on free plan)
if (alias.name === '*') {
if (alias.name === '*' && alias.recipients.length > 0) {
body.mapping.push(alias.recipients.join(','));
return;
}
Expand Down Expand Up @@ -470,7 +470,7 @@ async function getForwardingConfiguration({
if (bannedUserIdSet.has(alias.user.toString())) continue;
// rewrite `alias.recipients` to verified recipients only
// if and only if user has recipient verification enabled
if (alias.has_recipient_verification) {
if (alias.has_recipient_verification && alias.recipients.length > 0) {
const recipients = [];
for (const recipient of alias.recipients) {
if (alias.verified_recipients.includes(recipient))
Expand Down

0 comments on commit 41f74f7

Please sign in to comment.