cabdfb4abf05de0b2fab7fba1e44facf1e2b9690
[motion2.git] / server / api / mailApplication / mailApplication.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 _0x204f=['attributes','limit','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','client','http','request','then','info','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','MailApplication,\x20%s,\x20%s','message','result','catch','UpdateMailApplication','MailApplication','update','options'];(function(_0x1e1b12,_0x4ce9f5){var _0x118f5d=function(_0x2000aa){while(--_0x2000aa){_0x1e1b12['push'](_0x1e1b12['shift']());}};_0x118f5d(++_0x4ce9f5);}(_0x204f,0x15e));var _0xf204=function(_0x367584,_0x57e019){_0x367584=_0x367584-0x0;var _0xf1652f=_0x204f[_0x367584];return _0xf1652f;};'use strict';var _=require(_0xf204('0x0'));var util=require(_0xf204('0x1'));var moment=require(_0xf204('0x2'));var BPromise=require(_0xf204('0x3'));var rs=require(_0xf204('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xf204('0x5'))['db'];var utils=require(_0xf204('0x6'));var logger=require(_0xf204('0x7'))('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xf204('0x8')][_0xf204('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x3d9e05,_0xa5b976,_0x382bcd){return new BPromise(function(_0x38a1aa,_0x2d4786){return client[_0xf204('0xa')](_0x3d9e05,_0x382bcd)[_0xf204('0xb')](function(_0xf9a346){logger[_0xf204('0xc')]('MailApplication,\x20%s,\x20%s',_0xa5b976,_0xf204('0xd'));logger[_0xf204('0xe')](_0xf204('0xf'),_0xa5b976,_0xf204('0xd'),JSON[_0xf204('0x10')](_0xf9a346));if(_0xf9a346[_0xf204('0x11')]){if(_0xf9a346[_0xf204('0x11')][_0xf204('0x12')]===0x1f4){logger[_0xf204('0x11')](_0xf204('0x13'),_0xa5b976,_0xf9a346[_0xf204('0x11')][_0xf204('0x14')]);return _0x2d4786(_0xf9a346['error'][_0xf204('0x14')]);}logger[_0xf204('0x11')](_0xf204('0x13'),_0xa5b976,_0xf9a346[_0xf204('0x11')][_0xf204('0x14')]);return _0x38a1aa(_0xf9a346[_0xf204('0x11')][_0xf204('0x14')]);}else{logger[_0xf204('0xc')](_0xf204('0x13'),_0xa5b976,'request\x20sent');_0x38a1aa(_0xf9a346[_0xf204('0x15')][_0xf204('0x14')]);}})[_0xf204('0x16')](function(_0x2b6001){logger[_0xf204('0x11')](_0xf204('0x13'),_0xa5b976,_0x2b6001);_0x2d4786(_0x2b6001);});});}exports[_0xf204('0x17')]=function(_0x4d85c8){var _0x1672c3=this;return new Promise(function(_0x41f38f,_0x49e7ce){return db[_0xf204('0x18')][_0xf204('0x19')](_0x4d85c8['body'],{'raw':_0x4d85c8[_0xf204('0x1a')]?_0x4d85c8['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4d85c8[_0xf204('0x1a')]?_0x4d85c8[_0xf204('0x1a')]['where']||null:null,'attributes':_0x4d85c8['options']?_0x4d85c8[_0xf204('0x1a')][_0xf204('0x1b')]||null:null,'limit':_0x4d85c8[_0xf204('0x1a')]?_0x4d85c8[_0xf204('0x1a')][_0xf204('0x1c')]||null:null})[_0xf204('0xb')](function(_0x43ac30){logger['info'](_0xf204('0x17'),_0x4d85c8);logger['debug'](_0xf204('0x17'),_0x4d85c8,JSON[_0xf204('0x10')](_0x43ac30));_0x41f38f(_0x43ac30);})[_0xf204('0x16')](function(_0x456482){logger[_0xf204('0x11')](_0xf204('0x17'),_0x456482[_0xf204('0x14')],_0x4d85c8);_0x49e7ce(_0x1672c3[_0xf204('0x11')](0x1f4,_0x456482[_0xf204('0x14')]));});});};