Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / template / template.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 _0x5fe5=['../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','then','Template,\x20%s,\x20%s','request\x20sent','Template,\x20%s,\x20%s,\x20%s','error','code','message','GetTemplate','Template','options','raw','where','attributes','limit','map','include','model','info','debug','stringify','catch','lodash','util','moment','ioredis'];(function(_0x2c91e9,_0x2fb965){var _0x13f0ff=function(_0xb39edf){while(--_0xb39edf){_0x2c91e9['push'](_0x2c91e9['shift']());}};_0x13f0ff(++_0x2fb965);}(_0x5fe5,0x1ec));var _0x55fe=function(_0x43b5a7,_0xf5e3d6){_0x43b5a7=_0x43b5a7-0x0;var _0x5461fe=_0x5fe5[_0x43b5a7];return _0x5461fe;};'use strict';var _=require(_0x55fe('0x0'));var util=require(_0x55fe('0x1'));var moment=require(_0x55fe('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x55fe('0x3'));var db=require(_0x55fe('0x4'))['db'];var utils=require(_0x55fe('0x5'));var logger=require(_0x55fe('0x6'))(_0x55fe('0x7'));var config=require('../../config/environment');var jayson=require(_0x55fe('0x8'));var client=jayson[_0x55fe('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1b2bcb,_0x4c6bbf,_0x5b34a6){return new BPromise(function(_0x186284,_0x5c4b81){return client['request'](_0x1b2bcb,_0x5b34a6)[_0x55fe('0xa')](function(_0xd78cdb){logger['info'](_0x55fe('0xb'),_0x4c6bbf,_0x55fe('0xc'));logger['debug'](_0x55fe('0xd'),_0x4c6bbf,_0x55fe('0xc'),JSON['stringify'](_0xd78cdb));if(_0xd78cdb[_0x55fe('0xe')]){if(_0xd78cdb[_0x55fe('0xe')][_0x55fe('0xf')]===0x1f4){logger[_0x55fe('0xe')]('Template,\x20%s,\x20%s',_0x4c6bbf,_0xd78cdb[_0x55fe('0xe')][_0x55fe('0x10')]);return _0x5c4b81(_0xd78cdb[_0x55fe('0xe')]['message']);}logger['error']('Template,\x20%s,\x20%s',_0x4c6bbf,_0xd78cdb[_0x55fe('0xe')][_0x55fe('0x10')]);return _0x186284(_0xd78cdb['error'][_0x55fe('0x10')]);}else{logger['info'](_0x55fe('0xb'),_0x4c6bbf,_0x55fe('0xc'));_0x186284(_0xd78cdb['result']['message']);}})['catch'](function(_0x25dde0){logger[_0x55fe('0xe')](_0x55fe('0xb'),_0x4c6bbf,_0x25dde0);_0x5c4b81(_0x25dde0);});});}exports[_0x55fe('0x11')]=function(_0x162a43){var _0x29e0df=this;return new Promise(function(_0x339c1f,_0x5e43b1){return db[_0x55fe('0x12')]['findAll']({'raw':_0x162a43[_0x55fe('0x13')]?_0x162a43[_0x55fe('0x13')][_0x55fe('0x14')]===undefined?!![]:![]:!![],'where':_0x162a43[_0x55fe('0x13')]?_0x162a43[_0x55fe('0x13')][_0x55fe('0x15')]||null:null,'attributes':_0x162a43['options']?_0x162a43[_0x55fe('0x13')][_0x55fe('0x16')]||null:null,'limit':_0x162a43[_0x55fe('0x13')]?_0x162a43[_0x55fe('0x13')][_0x55fe('0x17')]||null:null,'include':_0x162a43[_0x55fe('0x13')]?_0x162a43['options']['include']?_[_0x55fe('0x18')](_0x162a43[_0x55fe('0x13')][_0x55fe('0x19')],function(_0x169e05){return{'model':db[_0x169e05[_0x55fe('0x1a')]],'as':_0x169e05['as'],'attributes':_0x169e05[_0x55fe('0x16')],'include':_0x169e05[_0x55fe('0x19')]?_[_0x55fe('0x18')](_0x169e05[_0x55fe('0x19')],function(_0x287c50){return{'model':db[_0x287c50[_0x55fe('0x1a')]],'as':_0x287c50['as'],'attributes':_0x287c50[_0x55fe('0x16')],'include':_0x287c50[_0x55fe('0x19')]?_[_0x55fe('0x18')](_0x287c50[_0x55fe('0x19')],function(_0x5f3785){return{'model':db[_0x5f3785[_0x55fe('0x1a')]],'as':_0x5f3785['as'],'attributes':_0x5f3785['attributes']};}):[]};}):[]};}):[]:[]})[_0x55fe('0xa')](function(_0x14a89e){logger[_0x55fe('0x1b')](_0x55fe('0x11'),_0x162a43);logger[_0x55fe('0x1c')](_0x55fe('0x11'),_0x162a43,JSON[_0x55fe('0x1d')](_0x14a89e));_0x339c1f(_0x14a89e);})[_0x55fe('0x1e')](function(_0x3abb37){logger[_0x55fe('0xe')](_0x55fe('0x11'),_0x3abb37[_0x55fe('0x10')],_0x162a43);_0x5e43b1(_0x29e0df[_0x55fe('0xe')](0x1f4,_0x3abb37[_0x55fe('0x10')]));});});};