27bea8c7b828164b3a3bb2994eb1445b3f3aa217
[motion2.git] / server / api / mailMessage / mailMessage.rpc.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 _0xbe2a=['error','code','MailMessage,\x20%s,\x20%s','message','catch','MailMessage','create','body','options','raw','CreateMailMessage','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./mailMessage.socket','register','info','request\x20sent','debug','stringify'];(function(_0x17c1ff,_0x4d1ac4){var _0x43f824=function(_0x3cd4ba){while(--_0x3cd4ba){_0x17c1ff['push'](_0x17c1ff['shift']());}};_0x43f824(++_0x4d1ac4);}(_0xbe2a,0x1d9));var _0xabe2=function(_0x3644d2,_0x252a08){_0x3644d2=_0x3644d2-0x0;var _0x4c3130=_0xbe2a[_0x3644d2];return _0x4c3130;};'use strict';var _=require(_0xabe2('0x0'));var util=require(_0xabe2('0x1'));var moment=require(_0xabe2('0x2'));var BPromise=require(_0xabe2('0x3'));var rs=require(_0xabe2('0x4'));var fs=require('fs');var Redis=require(_0xabe2('0x5'));var db=require(_0xabe2('0x6'))['db'];var utils=require('../../config/utils');var logger=require(_0xabe2('0x7'))('rpc');var config=require(_0xabe2('0x8'));var jayson=require(_0xabe2('0x9'));var client=jayson[_0xabe2('0xa')][_0xabe2('0xb')]({'port':0x232a});config[_0xabe2('0xc')]=_[_0xabe2('0xd')](config['redis'],{'host':_0xabe2('0xe'),'port':0x18eb});var socket=require(_0xabe2('0xf'))(new Redis(config[_0xabe2('0xc')]));require(_0xabe2('0x10'))[_0xabe2('0x11')](socket);function respondWithRpcPromise(_0x1b6319,_0x53a91f,_0x27fbaa){return new BPromise(function(_0x307e01,_0x35ddd1){return client['request'](_0x1b6319,_0x27fbaa)['then'](function(_0x5742c5){logger[_0xabe2('0x12')]('MailMessage,\x20%s,\x20%s',_0x53a91f,_0xabe2('0x13'));logger[_0xabe2('0x14')]('MailMessage,\x20%s,\x20%s,\x20%s',_0x53a91f,'request\x20sent',JSON[_0xabe2('0x15')](_0x5742c5));if(_0x5742c5[_0xabe2('0x16')]){if(_0x5742c5[_0xabe2('0x16')][_0xabe2('0x17')]===0x1f4){logger[_0xabe2('0x16')](_0xabe2('0x18'),_0x53a91f,_0x5742c5[_0xabe2('0x16')][_0xabe2('0x19')]);return _0x35ddd1(_0x5742c5[_0xabe2('0x16')][_0xabe2('0x19')]);}logger['error'](_0xabe2('0x18'),_0x53a91f,_0x5742c5[_0xabe2('0x16')][_0xabe2('0x19')]);return _0x307e01(_0x5742c5['error'][_0xabe2('0x19')]);}else{logger[_0xabe2('0x12')](_0xabe2('0x18'),_0x53a91f,_0xabe2('0x13'));_0x307e01(_0x5742c5['result'][_0xabe2('0x19')]);}})[_0xabe2('0x1a')](function(_0x50a49a){logger[_0xabe2('0x16')](_0xabe2('0x18'),_0x53a91f,_0x50a49a);_0x35ddd1(_0x50a49a);});});}exports['CreateMailMessage']=function(_0x55d89){var _0x3efadc=this;return new Promise(function(_0x2906f4,_0x4a5f75){return db[_0xabe2('0x1b')][_0xabe2('0x1c')](_0x55d89[_0xabe2('0x1d')],{'raw':_0x55d89[_0xabe2('0x1e')]?_0x55d89[_0xabe2('0x1e')][_0xabe2('0x1f')]===undefined?!![]:![]:!![]})['then'](function(_0x237a41){logger[_0xabe2('0x12')]('CreateMailMessage',_0x55d89);logger['debug'](_0xabe2('0x20'),_0x55d89,JSON[_0xabe2('0x15')](_0x237a41));_0x2906f4(_0x237a41);})[_0xabe2('0x1a')](function(_0x91f296){logger['error'](_0xabe2('0x20'),_0x91f296[_0xabe2('0x19')],_0x55d89);_0x4a5f75(_0x3efadc[_0xabe2('0x16')](0x1f4,_0x91f296['message']));});});};