Built motion from commit 97153652.|2.6.26
[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 _0x78f0=['util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','request','then','info','Template,\x20%s,\x20%s','request\x20sent','Template,\x20%s,\x20%s,\x20%s','error','code','message','result','GetTemplate','Template','findAll','options','raw','attributes','limit','include','map','model','debug','stringify','catch','lodash'];(function(_0x3ac8b2,_0x1cee01){var _0x5772b1=function(_0x4313cb){while(--_0x4313cb){_0x3ac8b2['push'](_0x3ac8b2['shift']());}};_0x5772b1(++_0x1cee01);}(_0x78f0,0x15d));var _0x078f=function(_0xca050b,_0x3e6f0a){_0xca050b=_0xca050b-0x0;var _0x1871a2=_0x78f0[_0xca050b];return _0x1871a2;};'use strict';var _=require(_0x078f('0x0'));var util=require(_0x078f('0x1'));var moment=require(_0x078f('0x2'));var BPromise=require(_0x078f('0x3'));var rs=require(_0x078f('0x4'));var fs=require('fs');var Redis=require(_0x078f('0x5'));var db=require(_0x078f('0x6'))['db'];var utils=require(_0x078f('0x7'));var logger=require('../../config/logger')(_0x078f('0x8'));var config=require(_0x078f('0x9'));var jayson=require(_0x078f('0xa'));var client=jayson[_0x078f('0xb')]['http']({'port':0x232a});function respondWithRpcPromise(_0x728cfe,_0x205510,_0x4a7db3){return new BPromise(function(_0x2ef013,_0x1901e3){return client[_0x078f('0xc')](_0x728cfe,_0x4a7db3)[_0x078f('0xd')](function(_0x7e87f){logger[_0x078f('0xe')](_0x078f('0xf'),_0x205510,_0x078f('0x10'));logger['debug'](_0x078f('0x11'),_0x205510,_0x078f('0x10'),JSON['stringify'](_0x7e87f));if(_0x7e87f[_0x078f('0x12')]){if(_0x7e87f[_0x078f('0x12')][_0x078f('0x13')]===0x1f4){logger[_0x078f('0x12')]('Template,\x20%s,\x20%s',_0x205510,_0x7e87f['error'][_0x078f('0x14')]);return _0x1901e3(_0x7e87f[_0x078f('0x12')][_0x078f('0x14')]);}logger[_0x078f('0x12')]('Template,\x20%s,\x20%s',_0x205510,_0x7e87f[_0x078f('0x12')][_0x078f('0x14')]);return _0x2ef013(_0x7e87f['error'][_0x078f('0x14')]);}else{logger[_0x078f('0xe')](_0x078f('0xf'),_0x205510,_0x078f('0x10'));_0x2ef013(_0x7e87f[_0x078f('0x15')][_0x078f('0x14')]);}})['catch'](function(_0x56bad2){logger[_0x078f('0x12')](_0x078f('0xf'),_0x205510,_0x56bad2);_0x1901e3(_0x56bad2);});});}exports[_0x078f('0x16')]=function(_0x19a182){var _0x201560=this;return new Promise(function(_0x25bb2d,_0xb8af8c){return db[_0x078f('0x17')][_0x078f('0x18')]({'raw':_0x19a182[_0x078f('0x19')]?_0x19a182[_0x078f('0x19')][_0x078f('0x1a')]===undefined?!![]:![]:!![],'where':_0x19a182['options']?_0x19a182[_0x078f('0x19')]['where']||null:null,'attributes':_0x19a182['options']?_0x19a182[_0x078f('0x19')][_0x078f('0x1b')]||null:null,'limit':_0x19a182[_0x078f('0x19')]?_0x19a182[_0x078f('0x19')][_0x078f('0x1c')]||null:null,'include':_0x19a182[_0x078f('0x19')]?_0x19a182[_0x078f('0x19')][_0x078f('0x1d')]?_[_0x078f('0x1e')](_0x19a182['options'][_0x078f('0x1d')],function(_0x14ad5c){return{'model':db[_0x14ad5c[_0x078f('0x1f')]],'as':_0x14ad5c['as'],'attributes':_0x14ad5c['attributes'],'include':_0x14ad5c['include']?_[_0x078f('0x1e')](_0x14ad5c[_0x078f('0x1d')],function(_0x3d9d08){return{'model':db[_0x3d9d08[_0x078f('0x1f')]],'as':_0x3d9d08['as'],'attributes':_0x3d9d08[_0x078f('0x1b')],'include':_0x3d9d08[_0x078f('0x1d')]?_[_0x078f('0x1e')](_0x3d9d08['include'],function(_0x1f6596){return{'model':db[_0x1f6596[_0x078f('0x1f')]],'as':_0x1f6596['as'],'attributes':_0x1f6596['attributes']};}):[]};}):[]};}):[]:[]})[_0x078f('0xd')](function(_0x35304e){logger[_0x078f('0xe')](_0x078f('0x16'),_0x19a182);logger[_0x078f('0x20')](_0x078f('0x16'),_0x19a182,JSON[_0x078f('0x21')](_0x35304e));_0x25bb2d(_0x35304e);})[_0x078f('0x22')](function(_0x1f0ad6){logger[_0x078f('0x12')](_0x078f('0x16'),_0x1f0ad6[_0x078f('0x14')],_0x19a182);_0xb8af8c(_0x201560[_0x078f('0x12')](0x1f4,_0x1f0ad6[_0x078f('0x14')]));});});};