94e01cdb9fb08ae6e37cdc5f2e1c4fbdda9d8e02
[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 _0x8f4c=['body','options','raw','lodash','util','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','jayson/promise','defaults','localhost','socket.io-emitter','redis','./mailMessage.socket','register','then','info','MailMessage,\x20%s,\x20%s','request\x20sent','debug','MailMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','CreateMailMessage','MailMessage','create'];(function(_0x397e5f,_0x454c8f){var _0x5302b8=function(_0x1a29ef){while(--_0x1a29ef){_0x397e5f['push'](_0x397e5f['shift']());}};_0x5302b8(++_0x454c8f);}(_0x8f4c,0x113));var _0xc8f4=function(_0x2ebfdb,_0x3cad62){_0x2ebfdb=_0x2ebfdb-0x0;var _0x4430ef=_0x8f4c[_0x2ebfdb];return _0x4430ef;};'use strict';var _=require(_0xc8f4('0x0'));var util=require(_0xc8f4('0x1'));var moment=require(_0xc8f4('0x2'));var BPromise=require(_0xc8f4('0x3'));var rs=require(_0xc8f4('0x4'));var fs=require('fs');var Redis=require(_0xc8f4('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0xc8f4('0x6'));var logger=require(_0xc8f4('0x7'))(_0xc8f4('0x8'));var config=require('../../config/environment');var jayson=require(_0xc8f4('0x9'));var client=jayson['client']['http']({'port':0x232a});config['redis']=_[_0xc8f4('0xa')](config['redis'],{'host':_0xc8f4('0xb'),'port':0x18eb});var socket=require(_0xc8f4('0xc'))(new Redis(config[_0xc8f4('0xd')]));require(_0xc8f4('0xe'))[_0xc8f4('0xf')](socket);function respondWithRpcPromise(_0x599de3,_0x38c41b,_0x191b92){return new BPromise(function(_0x2fba62,_0x3a2f8a){return client['request'](_0x599de3,_0x191b92)[_0xc8f4('0x10')](function(_0x52c699){logger[_0xc8f4('0x11')](_0xc8f4('0x12'),_0x38c41b,_0xc8f4('0x13'));logger[_0xc8f4('0x14')](_0xc8f4('0x15'),_0x38c41b,'request\x20sent',JSON[_0xc8f4('0x16')](_0x52c699));if(_0x52c699[_0xc8f4('0x17')]){if(_0x52c699[_0xc8f4('0x17')][_0xc8f4('0x18')]===0x1f4){logger[_0xc8f4('0x17')](_0xc8f4('0x12'),_0x38c41b,_0x52c699['error'][_0xc8f4('0x19')]);return _0x3a2f8a(_0x52c699[_0xc8f4('0x17')][_0xc8f4('0x19')]);}logger[_0xc8f4('0x17')](_0xc8f4('0x12'),_0x38c41b,_0x52c699['error'][_0xc8f4('0x19')]);return _0x2fba62(_0x52c699['error']['message']);}else{logger[_0xc8f4('0x11')](_0xc8f4('0x12'),_0x38c41b,_0xc8f4('0x13'));_0x2fba62(_0x52c699[_0xc8f4('0x1a')][_0xc8f4('0x19')]);}})[_0xc8f4('0x1b')](function(_0x2459ac){logger[_0xc8f4('0x17')](_0xc8f4('0x12'),_0x38c41b,_0x2459ac);_0x3a2f8a(_0x2459ac);});});}exports[_0xc8f4('0x1c')]=function(_0x3cd90c){var _0x3126e5=this;return new Promise(function(_0x22236c,_0x5f3264){return db[_0xc8f4('0x1d')][_0xc8f4('0x1e')](_0x3cd90c[_0xc8f4('0x1f')],{'raw':_0x3cd90c[_0xc8f4('0x20')]?_0x3cd90c[_0xc8f4('0x20')][_0xc8f4('0x21')]===undefined?!![]:![]:!![]})[_0xc8f4('0x10')](function(_0x43eb57){logger['info'](_0xc8f4('0x1c'),_0x3cd90c);logger[_0xc8f4('0x14')](_0xc8f4('0x1c'),_0x3cd90c,JSON[_0xc8f4('0x16')](_0x43eb57));_0x22236c(_0x43eb57);})['catch'](function(_0x39174f){logger['error'](_0xc8f4('0x1c'),_0x39174f['message'],_0x3cd90c);_0x5f3264(_0x3126e5[_0xc8f4('0x17')](0x1f4,_0x39174f[_0xc8f4('0x19')]));});});};