Browse Source

Make max public domain identity per user configurable, default unlimited

develop
Alice Gaudon 3 weeks ago
parent
commit
679e8ab769
4 changed files with 8 additions and 2 deletions
  1. +2
    -0
      config/default.json5
  2. +3
    -0
      config/test.json5
  3. +1
    -1
      src/controllers/AccountMailboxController.ts
  4. +2
    -1
      src/models/UserMailIdentityComponent.ts

+ 2
- 0
config/default.json5 View File

@ -36,6 +36,8 @@
allow_invalid_tls: true,
from: 'contact@rainbox.email',
from_name: 'Rainbox Email',
// Unlimited
max_public_identities_per_user: -1,
},
view: {
cache: false,


+ 3
- 0
config/test.json5 View File

@ -6,4 +6,7 @@
database: "rainbox_email_test",
create_database_automatically: true
},
mail: {
max_public_identities_per_user: 1,
},
}

+ 1
- 1
src/controllers/AccountMailboxController.ts View File

@ -66,7 +66,7 @@ export default class AccountMailboxController extends Controller {
}, req.body);
const actualPublicAddressesCount = await mailIdentityComponent.getPublicAddressesCount();
const maxPublicAddressesCount = mailIdentityComponent.getMaxPublicAddressesCount();
if (actualPublicAddressesCount >= maxPublicAddressesCount) {
if (maxPublicAddressesCount >= 0 && actualPublicAddressesCount >= maxPublicAddressesCount) {
req.flash('error', 'You have reached maximum public email addresses.');
res.redirect(Controller.route('account-mailbox'));
return;


+ 2
- 1
src/models/UserMailIdentityComponent.ts View File

@ -3,6 +3,7 @@ import User from "swaf/auth/models/User";
import {ManyModelRelation, OneModelRelation} from "swaf/db/ModelRelation";
import MailIdentity from "./MailIdentity";
import MailDomain from "./MailDomain";
import config from "config";
export default class UserMailIdentityComponent extends ModelComponent<User> {
public main_mail_identity_id?: number = undefined;
@ -27,7 +28,7 @@ export default class UserMailIdentityComponent extends ModelComponent<User> {
});
public getMaxPublicAddressesCount(): number {
return 1;
return config.get<number>('mail.max_public_identities_per_user');
}
public async getPublicAddressesCount(): Promise<number> {


Loading…
Cancel
Save