36b2ca35bab5a6a3c8276a06d3842c9e6671c708
[motion2.git] / server / services / email / server / index.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x3eb5=['mailAccounts','Imap','password','Smtp','pass','length','http','stringify','127.0.0.1','Email\x20RPC\x20server\x20listening\x20on\x20127.0.0.1:%d!','jayson/promise','bluebird','lodash','email','listen','sendMail','account','message','then','catch','error','verifySmtp','Verified','values'];(function(_0x19c6c9,_0x3388e4){var _0x29285c=function(_0x40f438){while(--_0x40f438){_0x19c6c9['push'](_0x19c6c9['shift']());}};_0x29285c(++_0x3388e4);}(_0x3eb5,0xca));var _0x53eb=function(_0x43b5a7,_0xf5e3d6){_0x43b5a7=_0x43b5a7-0x0;var _0x5461fe=_0x3eb5[_0x43b5a7];return _0x5461fe;};'use strict';var jayson=require(_0x53eb('0x0'));var BPromise=require(_0x53eb('0x1'));var _=require(_0x53eb('0x2'));var logger=require('../../../config/logger')(_0x53eb('0x3'));exports[_0x53eb('0x4')]=function(_0x579d83,_0x186156){return new BPromise(function(_0x4b47a6,_0x7ff84a){var _0x476cba={'SendMail':function(_0x275a26){var _0x390a1d=this;return new Promise(function(_0x4a5e6b,_0x37d8fe){_0x186156[_0x53eb('0x5')](_0x275a26[_0x53eb('0x6')],_0x275a26[_0x53eb('0x7')])[_0x53eb('0x8')](function(_0x41072d){_0x4a5e6b({'code':0xc8,'message':_0x41072d});})[_0x53eb('0x9')](function(_0x35767b){_0x37d8fe(_0x390a1d[_0x53eb('0xa')](0x1f4,_0x35767b));});});},'VerifySmtp':function(_0x3492bc){var _0x50a64b=this;return new Promise(function(_0x37ae1a,_0xe65159){_0x186156[_0x53eb('0xb')](_0x3492bc['account'])['then'](function(_0x13983c){_0x37ae1a({'code':0xc8,'message':_0x53eb('0xc')});})[_0x53eb('0x9')](function(_0x2fe15a){_0xe65159(_0x50a64b[_0x53eb('0xa')](0x1f4,_0x2fe15a));});});},'MailAccounts':function(_0x57be99){return new Promise(function(_0x4c6690,_0x41a6fb){var _0xf1d51c=_[_0x53eb('0xd')](_0x579d83[_0x53eb('0xe')]);for(var _0x6854b1=0x0;_0x6854b1<_0xf1d51c['length'];_0x6854b1+=0x1){if(_0xf1d51c[_0x6854b1][_0x53eb('0xf')]&&_0xf1d51c[_0x6854b1][_0x53eb('0xf')][_0x53eb('0x10')]){delete _0xf1d51c[_0x6854b1][_0x53eb('0xf')]['password'];}if(_0xf1d51c[_0x6854b1][_0x53eb('0x11')]&&_0xf1d51c[_0x6854b1][_0x53eb('0x11')]['pass']){delete _0xf1d51c[_0x6854b1]['Smtp'][_0x53eb('0x12')];}}_0x4c6690({'count':_0xf1d51c[_0x53eb('0x13')],'rows':_0xf1d51c});});}};var _0x415de2=jayson['server'](_0x476cba)[_0x53eb('0x14')]();_0x415de2['on'](_0x53eb('0xa'),function(_0x854f75){logger['error'](JSON[_0x53eb('0x15')](_0x854f75));return _0x7ff84a(_0x854f75);});_0x415de2[_0x53eb('0x4')](0x232b,_0x53eb('0x16'),function(){console['log'](_0x53eb('0x17'),0x232b);return _0x4b47a6('RPC\x20listening\x20on\x20port:'+0x232b);});});};