});
// SCOPES
- MailAccount.addScope('default', {
- where: {
- custom: false,
- },
- include: [{
- model: models.MailServerIn,
- attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'delete', 'filter', 'state', 'mailbox', 'connTimeout', 'authTimeout', 'keepalive', 'source', 'polling', 'pollingTimeout']
- }, {
- model: models.MailServerOut,
- attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'state', 'source', 'description']
- }, {
- model: models.MailApplication,
+ MailAccount.addScope('default', function(query) {
+ var opt = {
include: [{
- model: models.User,
- attributes: ['id',
- 'name',
- 'email',
- 'internal',
- 'fullname'
- ]
+ model: models.MailServerIn,
+ attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'delete', 'filter', 'state', 'mailbox', 'connTimeout', 'authTimeout', 'keepalive', 'source', 'polling', 'pollingTimeout']
}, {
- model: models.MailQueue
+ model: models.MailServerOut,
+ attributes: ['id', 'host', 'port', 'username', 'password', 'ssl', 'state', 'source', 'description']
+ }, {
+ model: models.MailApplication,
+ include: [{
+ model: models.User,
+ attributes: ['id',
+ 'name',
+ 'email',
+ 'internal',
+ 'fullname'
+ ]
+ }, {
+ model: models.MailQueue
+ }]
}]
- }]
+ };
+ if (query && !query.custom) {
+ opt.where = {
+ custom: false,
+ };
+ delete query.custom;
+ }
+ return opt;
});
}
});