Built motion from commit a679711e.|2.6.15
[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 _0x3afb=['debug','Template,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','GetTemplate','Template','options','raw','where','attributes','limit','include','map','model','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','request','then','Template,\x20%s,\x20%s','request\x20sent'];(function(_0x106f42,_0x131ed9){var _0x3af68e=function(_0x77ee39){while(--_0x77ee39){_0x106f42['push'](_0x106f42['shift']());}};_0x3af68e(++_0x131ed9);}(_0x3afb,0xc1));var _0xb3af=function(_0x1757f2,_0x1b09fa){_0x1757f2=_0x1757f2-0x0;var _0x5e7212=_0x3afb[_0x1757f2];return _0x5e7212;};'use strict';var _=require(_0xb3af('0x0'));var util=require(_0xb3af('0x1'));var moment=require(_0xb3af('0x2'));var BPromise=require(_0xb3af('0x3'));var rs=require(_0xb3af('0x4'));var fs=require('fs');var Redis=require(_0xb3af('0x5'));var db=require(_0xb3af('0x6'))['db'];var utils=require(_0xb3af('0x7'));var logger=require(_0xb3af('0x8'))(_0xb3af('0x9'));var config=require('../../config/environment');var jayson=require(_0xb3af('0xa'));var client=jayson[_0xb3af('0xb')][_0xb3af('0xc')]({'port':0x232a});function respondWithRpcPromise(_0x44edd5,_0x791694,_0x39538c){return new BPromise(function(_0x19e654,_0x14382b){return client[_0xb3af('0xd')](_0x44edd5,_0x39538c)[_0xb3af('0xe')](function(_0x440623){logger['info'](_0xb3af('0xf'),_0x791694,_0xb3af('0x10'));logger[_0xb3af('0x11')](_0xb3af('0x12'),_0x791694,_0xb3af('0x10'),JSON[_0xb3af('0x13')](_0x440623));if(_0x440623[_0xb3af('0x14')]){if(_0x440623[_0xb3af('0x14')]['code']===0x1f4){logger[_0xb3af('0x14')](_0xb3af('0xf'),_0x791694,_0x440623['error']['message']);return _0x14382b(_0x440623[_0xb3af('0x14')]['message']);}logger[_0xb3af('0x14')](_0xb3af('0xf'),_0x791694,_0x440623[_0xb3af('0x14')][_0xb3af('0x15')]);return _0x19e654(_0x440623['error'][_0xb3af('0x15')]);}else{logger[_0xb3af('0x16')](_0xb3af('0xf'),_0x791694,_0xb3af('0x10'));_0x19e654(_0x440623[_0xb3af('0x17')][_0xb3af('0x15')]);}})[_0xb3af('0x18')](function(_0x57b593){logger[_0xb3af('0x14')]('Template,\x20%s,\x20%s',_0x791694,_0x57b593);_0x14382b(_0x57b593);});});}exports[_0xb3af('0x19')]=function(_0x54c1af){var _0x4d5280=this;return new Promise(function(_0x34d8a8,_0x495e18){return db[_0xb3af('0x1a')]['findAll']({'raw':_0x54c1af[_0xb3af('0x1b')]?_0x54c1af['options'][_0xb3af('0x1c')]===undefined?!![]:![]:!![],'where':_0x54c1af[_0xb3af('0x1b')]?_0x54c1af[_0xb3af('0x1b')][_0xb3af('0x1d')]||null:null,'attributes':_0x54c1af[_0xb3af('0x1b')]?_0x54c1af[_0xb3af('0x1b')][_0xb3af('0x1e')]||null:null,'limit':_0x54c1af[_0xb3af('0x1b')]?_0x54c1af[_0xb3af('0x1b')][_0xb3af('0x1f')]||null:null,'include':_0x54c1af[_0xb3af('0x1b')]?_0x54c1af[_0xb3af('0x1b')][_0xb3af('0x20')]?_[_0xb3af('0x21')](_0x54c1af[_0xb3af('0x1b')][_0xb3af('0x20')],function(_0x3add18){return{'model':db[_0x3add18[_0xb3af('0x22')]],'as':_0x3add18['as'],'attributes':_0x3add18['attributes'],'include':_0x3add18['include']?_[_0xb3af('0x21')](_0x3add18[_0xb3af('0x20')],function(_0x4fc0ec){return{'model':db[_0x4fc0ec[_0xb3af('0x22')]],'as':_0x4fc0ec['as'],'attributes':_0x4fc0ec['attributes'],'include':_0x4fc0ec['include']?_[_0xb3af('0x21')](_0x4fc0ec['include'],function(_0x48f3cd){return{'model':db[_0x48f3cd[_0xb3af('0x22')]],'as':_0x48f3cd['as'],'attributes':_0x48f3cd[_0xb3af('0x1e')]};}):[]};}):[]};}):[]:[]})[_0xb3af('0xe')](function(_0x43941b){logger[_0xb3af('0x16')](_0xb3af('0x19'),_0x54c1af);logger[_0xb3af('0x11')]('GetTemplate',_0x54c1af,JSON[_0xb3af('0x13')](_0x43941b));_0x34d8a8(_0x43941b);})['catch'](function(_0x536b1){logger[_0xb3af('0x14')]('GetTemplate',_0x536b1[_0xb3af('0x15')],_0x54c1af);_0x495e18(_0x4d5280['error'](0x1f4,_0x536b1[_0xb3af('0x15')]));});});};