mail/src/js/service/mail-config.js

27 lines
722 B
JavaScript
Raw Permalink Normal View History

2014-11-11 15:50:01 -05:00
'use strict';
var ngModule = angular.module('woServices');
2014-11-11 15:50:01 -05:00
ngModule.service('mailConfig', MailConfig);
module.exports = MailConfig;
2014-11-11 15:50:01 -05:00
function MailConfig($http, $q, appConfig) {
2014-11-11 15:50:01 -05:00
this._http = $http;
this._q = $q;
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!'));
});
}
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;
});
};