2014-11-11 15:50:01 -05:00
|
|
|
'use strict';
|
|
|
|
|
2014-11-12 10:12:26 -05:00
|
|
|
var ngModule = angular.module('woServices');
|
2014-11-11 15:50:01 -05:00
|
|
|
ngModule.service('mailConfig', MailConfig);
|
2014-11-19 11:19:55 -05:00
|
|
|
module.exports = MailConfig;
|
2014-11-11 15:50:01 -05:00
|
|
|
|
2014-11-19 11:19:55 -05:00
|
|
|
function MailConfig($http, $q, appConfig) {
|
2014-11-11 15:50:01 -05:00
|
|
|
this._http = $http;
|
|
|
|
this._q = $q;
|
2014-11-19 11:19:55 -05:00
|
|
|
this._appConfig = appConfig;
|
2014-11-11 15:50:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mail server IMAP and SMTP configuration for an email address
|
|
|
|
*/
|
|
|
|
MailConfig.prototype.get = function(emailAddress) {
|
|
|
|
if (emailAddress.indexOf('@') < 0) {
|
|
|
|
return this._q(function(resolve, reject) {
|
|
|
|
reject(new Error('Invalid email address!'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-11-21 09:06:29 -05:00
|
|
|
var url = this._appConfig.config.settingsUrl + emailAddress.split('@')[1];
|
2014-11-11 15:50:01 -05:00
|
|
|
return this._http.get(url).then(function(res) {
|
|
|
|
return res.data;
|
|
|
|
});
|
|
|
|
};
|