Built motion from commit (unavailable).|2.3.1
[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 _0x4901=['http','request','then','Template,\x20%s,\x20%s','Template,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','GetTemplate','findAll','options','raw','where','limit','include','map','model','info','debug','lodash','util','moment','randomstring','../../config/logger','../../config/environment','jayson/promise'];(function(_0x2763f2,_0x416af8){var _0x3ef471=function(_0x288aa2){while(--_0x288aa2){_0x2763f2['push'](_0x2763f2['shift']());}};_0x3ef471(++_0x416af8);}(_0x4901,0x155));var _0x1490=function(_0x30d755,_0x188807){_0x30d755=_0x30d755-0x0;var _0xa16cea=_0x4901[_0x30d755];return _0xa16cea;};'use strict';var _=require(_0x1490('0x0'));var util=require(_0x1490('0x1'));var moment=require(_0x1490('0x2'));var BPromise=require('bluebird');var rs=require(_0x1490('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x1490('0x4'))('rpc');var config=require(_0x1490('0x5'));var jayson=require(_0x1490('0x6'));var client=jayson['client'][_0x1490('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x1ee4b7,_0x556e54,_0x24c228){return new BPromise(function(_0x332321,_0x15bde8){return client[_0x1490('0x8')](_0x1ee4b7,_0x24c228)[_0x1490('0x9')](function(_0x398691){logger['info'](_0x1490('0xa'),_0x556e54,'request\x20sent');logger['debug'](_0x1490('0xb'),_0x556e54,_0x1490('0xc'),JSON['stringify'](_0x398691));if(_0x398691[_0x1490('0xd')]){if(_0x398691[_0x1490('0xd')][_0x1490('0xe')]===0x1f4){logger[_0x1490('0xd')](_0x1490('0xa'),_0x556e54,_0x398691[_0x1490('0xd')][_0x1490('0xf')]);return _0x15bde8(_0x398691[_0x1490('0xd')][_0x1490('0xf')]);}logger[_0x1490('0xd')](_0x1490('0xa'),_0x556e54,_0x398691[_0x1490('0xd')]['message']);return _0x332321(_0x398691[_0x1490('0xd')][_0x1490('0xf')]);}else{logger['info'](_0x1490('0xa'),_0x556e54,_0x1490('0xc'));_0x332321(_0x398691[_0x1490('0x10')][_0x1490('0xf')]);}})[_0x1490('0x11')](function(_0x5bc647){logger[_0x1490('0xd')]('Template,\x20%s,\x20%s',_0x556e54,_0x5bc647);_0x15bde8(_0x5bc647);});});}exports[_0x1490('0x12')]=function(_0x53e967){var _0x1fe196=this;return new Promise(function(_0x28a80f,_0x34f411){return db['Template'][_0x1490('0x13')]({'raw':_0x53e967[_0x1490('0x14')]?_0x53e967[_0x1490('0x14')][_0x1490('0x15')]===undefined?!![]:![]:!![],'where':_0x53e967[_0x1490('0x14')]?_0x53e967['options'][_0x1490('0x16')]||null:null,'attributes':_0x53e967['options']?_0x53e967[_0x1490('0x14')]['attributes']||null:null,'limit':_0x53e967['options']?_0x53e967[_0x1490('0x14')][_0x1490('0x17')]||null:null,'include':_0x53e967['options']?_0x53e967[_0x1490('0x14')][_0x1490('0x18')]?_['map'](_0x53e967[_0x1490('0x14')][_0x1490('0x18')],function(_0x4aa207){return{'model':db[_0x4aa207['model']],'as':_0x4aa207['as'],'attributes':_0x4aa207['attributes'],'include':_0x4aa207[_0x1490('0x18')]?_[_0x1490('0x19')](_0x4aa207[_0x1490('0x18')],function(_0xed6483){return{'model':db[_0xed6483[_0x1490('0x1a')]],'as':_0xed6483['as'],'attributes':_0xed6483['attributes'],'include':_0xed6483[_0x1490('0x18')]?_[_0x1490('0x19')](_0xed6483[_0x1490('0x18')],function(_0x2e96ab){return{'model':db[_0x2e96ab[_0x1490('0x1a')]],'as':_0x2e96ab['as'],'attributes':_0x2e96ab['attributes']};}):[]};}):[]};}):[]:[]})[_0x1490('0x9')](function(_0x2a3766){logger[_0x1490('0x1b')](_0x1490('0x12'),_0x53e967);logger[_0x1490('0x1c')](_0x1490('0x12'),_0x53e967,JSON['stringify'](_0x2a3766));_0x28a80f(_0x2a3766);})[_0x1490('0x11')](function(_0x185688){logger[_0x1490('0xd')](_0x1490('0x12'),_0x185688[_0x1490('0xf')],_0x53e967);_0x34f411(_0x1fe196[_0x1490('0xd')](0x1f4,_0x185688[_0x1490('0xf')]));});});};