Built motion from commit (unavailable).|2.5.4
[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 _0x7095=['error','Template,\x20%s,\x20%s','message','catch','options','include','map','model','attributes','info','GetTemplate','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','request','then','request\x20sent','debug','stringify'];(function(_0x1ac595,_0x5d2081){var _0x455fff=function(_0x3043ee){while(--_0x3043ee){_0x1ac595['push'](_0x1ac595['shift']());}};_0x455fff(++_0x5d2081);}(_0x7095,0xb3));var _0x5709=function(_0x22ae4f,_0x2837f6){_0x22ae4f=_0x22ae4f-0x0;var _0x27e200=_0x7095[_0x22ae4f];return _0x27e200;};'use strict';var _=require(_0x5709('0x0'));var util=require(_0x5709('0x1'));var moment=require('moment');var BPromise=require(_0x5709('0x2'));var rs=require(_0x5709('0x3'));var fs=require('fs');var Redis=require(_0x5709('0x4'));var db=require(_0x5709('0x5'))['db'];var utils=require(_0x5709('0x6'));var logger=require(_0x5709('0x7'))(_0x5709('0x8'));var config=require(_0x5709('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x5709('0xa')][_0x5709('0xb')]({'port':0x232a});function respondWithRpcPromise(_0xfc627,_0x90e6c1,_0x56f635){return new BPromise(function(_0x24f551,_0x3ee5fb){return client[_0x5709('0xc')](_0xfc627,_0x56f635)[_0x5709('0xd')](function(_0x2fe3ba){logger['info']('Template,\x20%s,\x20%s',_0x90e6c1,_0x5709('0xe'));logger[_0x5709('0xf')]('Template,\x20%s,\x20%s,\x20%s',_0x90e6c1,'request\x20sent',JSON[_0x5709('0x10')](_0x2fe3ba));if(_0x2fe3ba[_0x5709('0x11')]){if(_0x2fe3ba['error']['code']===0x1f4){logger['error'](_0x5709('0x12'),_0x90e6c1,_0x2fe3ba['error'][_0x5709('0x13')]);return _0x3ee5fb(_0x2fe3ba[_0x5709('0x11')]['message']);}logger[_0x5709('0x11')](_0x5709('0x12'),_0x90e6c1,_0x2fe3ba[_0x5709('0x11')]['message']);return _0x24f551(_0x2fe3ba[_0x5709('0x11')][_0x5709('0x13')]);}else{logger['info'](_0x5709('0x12'),_0x90e6c1,_0x5709('0xe'));_0x24f551(_0x2fe3ba['result'][_0x5709('0x13')]);}})[_0x5709('0x14')](function(_0x453b54){logger[_0x5709('0x11')](_0x5709('0x12'),_0x90e6c1,_0x453b54);_0x3ee5fb(_0x453b54);});});}exports['GetTemplate']=function(_0x35d255){var _0x8b3974=this;return new Promise(function(_0x360493,_0x2d3eaa){return db['Template']['findAll']({'raw':_0x35d255[_0x5709('0x15')]?_0x35d255[_0x5709('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x35d255['options']?_0x35d255[_0x5709('0x15')]['where']||null:null,'attributes':_0x35d255[_0x5709('0x15')]?_0x35d255['options']['attributes']||null:null,'limit':_0x35d255[_0x5709('0x15')]?_0x35d255[_0x5709('0x15')]['limit']||null:null,'include':_0x35d255[_0x5709('0x15')]?_0x35d255['options'][_0x5709('0x16')]?_[_0x5709('0x17')](_0x35d255[_0x5709('0x15')][_0x5709('0x16')],function(_0x33f5bf){return{'model':db[_0x33f5bf[_0x5709('0x18')]],'as':_0x33f5bf['as'],'attributes':_0x33f5bf[_0x5709('0x19')],'include':_0x33f5bf[_0x5709('0x16')]?_[_0x5709('0x17')](_0x33f5bf[_0x5709('0x16')],function(_0x404296){return{'model':db[_0x404296['model']],'as':_0x404296['as'],'attributes':_0x404296[_0x5709('0x19')],'include':_0x404296['include']?_[_0x5709('0x17')](_0x404296[_0x5709('0x16')],function(_0x84fdd1){return{'model':db[_0x84fdd1[_0x5709('0x18')]],'as':_0x84fdd1['as'],'attributes':_0x84fdd1[_0x5709('0x19')]};}):[]};}):[]};}):[]:[]})[_0x5709('0xd')](function(_0x1954f1){logger[_0x5709('0x1a')](_0x5709('0x1b'),_0x35d255);logger['debug'](_0x5709('0x1b'),_0x35d255,JSON[_0x5709('0x10')](_0x1954f1));_0x360493(_0x1954f1);})[_0x5709('0x14')](function(_0x3afa52){logger[_0x5709('0x11')](_0x5709('0x1b'),_0x3afa52[_0x5709('0x13')],_0x35d255);_0x2d3eaa(_0x8b3974[_0x5709('0x11')](0x1f4,_0x3afa52[_0x5709('0x13')]));});});};