Built motion from commit (unavailable).|2.5.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 _0x517d=['result','catch','GetTemplate','Template','findAll','options','raw','attributes','limit','include','map','model','stringify','lodash','util','moment','bluebird','randomstring','../../config/logger','rpc','jayson/promise','client','http','request','then','info','Template,\x20%s,\x20%s','request\x20sent','debug','error','message'];(function(_0x369cd2,_0x29d7f1){var _0x3751d8=function(_0x2bf885){while(--_0x2bf885){_0x369cd2['push'](_0x369cd2['shift']());}};_0x3751d8(++_0x29d7f1);}(_0x517d,0x181));var _0xd517=function(_0x1e2061,_0x1ac12a){_0x1e2061=_0x1e2061-0x0;var _0xa75b01=_0x517d[_0x1e2061];return _0xa75b01;};'use strict';var _=require(_0xd517('0x0'));var util=require(_0xd517('0x1'));var moment=require(_0xd517('0x2'));var BPromise=require(_0xd517('0x3'));var rs=require(_0xd517('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0xd517('0x5'))(_0xd517('0x6'));var config=require('../../config/environment');var jayson=require(_0xd517('0x7'));var client=jayson[_0xd517('0x8')][_0xd517('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1ed569,_0x1de29a,_0x98465b){return new BPromise(function(_0x17e5ab,_0x3bec24){return client[_0xd517('0xa')](_0x1ed569,_0x98465b)[_0xd517('0xb')](function(_0x8fb804){logger[_0xd517('0xc')](_0xd517('0xd'),_0x1de29a,_0xd517('0xe'));logger[_0xd517('0xf')]('Template,\x20%s,\x20%s,\x20%s',_0x1de29a,_0xd517('0xe'),JSON['stringify'](_0x8fb804));if(_0x8fb804[_0xd517('0x10')]){if(_0x8fb804[_0xd517('0x10')]['code']===0x1f4){logger['error'](_0xd517('0xd'),_0x1de29a,_0x8fb804['error'][_0xd517('0x11')]);return _0x3bec24(_0x8fb804[_0xd517('0x10')][_0xd517('0x11')]);}logger[_0xd517('0x10')](_0xd517('0xd'),_0x1de29a,_0x8fb804[_0xd517('0x10')][_0xd517('0x11')]);return _0x17e5ab(_0x8fb804[_0xd517('0x10')]['message']);}else{logger[_0xd517('0xc')](_0xd517('0xd'),_0x1de29a,'request\x20sent');_0x17e5ab(_0x8fb804[_0xd517('0x12')][_0xd517('0x11')]);}})[_0xd517('0x13')](function(_0x2a182a){logger['error'](_0xd517('0xd'),_0x1de29a,_0x2a182a);_0x3bec24(_0x2a182a);});});}exports[_0xd517('0x14')]=function(_0x1edaab){var _0xdb3d64=this;return new Promise(function(_0x914072,_0x2d52ab){return db[_0xd517('0x15')][_0xd517('0x16')]({'raw':_0x1edaab[_0xd517('0x17')]?_0x1edaab['options'][_0xd517('0x18')]===undefined?!![]:![]:!![],'where':_0x1edaab[_0xd517('0x17')]?_0x1edaab[_0xd517('0x17')]['where']||null:null,'attributes':_0x1edaab['options']?_0x1edaab[_0xd517('0x17')][_0xd517('0x19')]||null:null,'limit':_0x1edaab['options']?_0x1edaab[_0xd517('0x17')][_0xd517('0x1a')]||null:null,'include':_0x1edaab[_0xd517('0x17')]?_0x1edaab[_0xd517('0x17')][_0xd517('0x1b')]?_[_0xd517('0x1c')](_0x1edaab['options'][_0xd517('0x1b')],function(_0xdcdd59){return{'model':db[_0xdcdd59[_0xd517('0x1d')]],'as':_0xdcdd59['as'],'attributes':_0xdcdd59[_0xd517('0x19')],'include':_0xdcdd59[_0xd517('0x1b')]?_['map'](_0xdcdd59[_0xd517('0x1b')],function(_0x43f7fe){return{'model':db[_0x43f7fe['model']],'as':_0x43f7fe['as'],'attributes':_0x43f7fe['attributes'],'include':_0x43f7fe[_0xd517('0x1b')]?_[_0xd517('0x1c')](_0x43f7fe[_0xd517('0x1b')],function(_0xed6131){return{'model':db[_0xed6131[_0xd517('0x1d')]],'as':_0xed6131['as'],'attributes':_0xed6131['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x449246){logger[_0xd517('0xc')](_0xd517('0x14'),_0x1edaab);logger['debug']('GetTemplate',_0x1edaab,JSON[_0xd517('0x1e')](_0x449246));_0x914072(_0x449246);})['catch'](function(_0x272697){logger[_0xd517('0x10')](_0xd517('0x14'),_0x272697[_0xd517('0x11')],_0x1edaab);_0x2d52ab(_0xdb3d64[_0xd517('0x10')](0x1f4,_0x272697[_0xd517('0x11')]));});});};