Built motion from commit 44b1f254.|2.6.26
[motion2.git] / server / api / openchannelApplication / openchannelApplication.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 _0xbfe4=['request\x20sent','debug','OpenchannelApplication,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','UpdateOpenchannelApplication','OpenchannelApplication','update','options','raw','where','limit','lodash','util','moment','randomstring','ioredis','../../config/utils','../../config/logger','../../config/environment','jayson/promise','http','request','then','info','OpenchannelApplication,\x20%s,\x20%s'];(function(_0x4353cd,_0x45e37e){var _0xa3479e=function(_0x546ae3){while(--_0x546ae3){_0x4353cd['push'](_0x4353cd['shift']());}};_0xa3479e(++_0x45e37e);}(_0xbfe4,0xbd));var _0x4bfe=function(_0x5ba77d,_0x37ea92){_0x5ba77d=_0x5ba77d-0x0;var _0x18bc74=_0xbfe4[_0x5ba77d];return _0x18bc74;};'use strict';var _=require(_0x4bfe('0x0'));var util=require(_0x4bfe('0x1'));var moment=require(_0x4bfe('0x2'));var BPromise=require('bluebird');var rs=require(_0x4bfe('0x3'));var fs=require('fs');var Redis=require(_0x4bfe('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0x4bfe('0x5'));var logger=require(_0x4bfe('0x6'))('rpc');var config=require(_0x4bfe('0x7'));var jayson=require(_0x4bfe('0x8'));var client=jayson['client'][_0x4bfe('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x46728f,_0x273ff9,_0x25e56a){return new BPromise(function(_0x5c21c0,_0x44e873){return client[_0x4bfe('0xa')](_0x46728f,_0x25e56a)[_0x4bfe('0xb')](function(_0x1f1734){logger[_0x4bfe('0xc')](_0x4bfe('0xd'),_0x273ff9,_0x4bfe('0xe'));logger[_0x4bfe('0xf')](_0x4bfe('0x10'),_0x273ff9,_0x4bfe('0xe'),JSON[_0x4bfe('0x11')](_0x1f1734));if(_0x1f1734[_0x4bfe('0x12')]){if(_0x1f1734[_0x4bfe('0x12')][_0x4bfe('0x13')]===0x1f4){logger[_0x4bfe('0x12')](_0x4bfe('0xd'),_0x273ff9,_0x1f1734[_0x4bfe('0x12')]['message']);return _0x44e873(_0x1f1734[_0x4bfe('0x12')][_0x4bfe('0x14')]);}logger[_0x4bfe('0x12')](_0x4bfe('0xd'),_0x273ff9,_0x1f1734['error'][_0x4bfe('0x14')]);return _0x5c21c0(_0x1f1734['error'][_0x4bfe('0x14')]);}else{logger[_0x4bfe('0xc')](_0x4bfe('0xd'),_0x273ff9,'request\x20sent');_0x5c21c0(_0x1f1734['result'][_0x4bfe('0x14')]);}})[_0x4bfe('0x15')](function(_0x232ab7){logger[_0x4bfe('0x12')]('OpenchannelApplication,\x20%s,\x20%s',_0x273ff9,_0x232ab7);_0x44e873(_0x232ab7);});});}exports[_0x4bfe('0x16')]=function(_0x45178e){var _0x394736=this;return new Promise(function(_0x4864b3,_0x107c16){return db[_0x4bfe('0x17')][_0x4bfe('0x18')](_0x45178e['body'],{'raw':_0x45178e['options']?_0x45178e[_0x4bfe('0x19')][_0x4bfe('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x45178e[_0x4bfe('0x19')]?_0x45178e[_0x4bfe('0x19')][_0x4bfe('0x1b')]||null:null,'attributes':_0x45178e[_0x4bfe('0x19')]?_0x45178e[_0x4bfe('0x19')]['attributes']||null:null,'limit':_0x45178e['options']?_0x45178e[_0x4bfe('0x19')][_0x4bfe('0x1c')]||null:null})['then'](function(_0x151b6d){logger['info']('UpdateOpenchannelApplication',_0x45178e);logger['debug'](_0x4bfe('0x16'),_0x45178e,JSON[_0x4bfe('0x11')](_0x151b6d));_0x4864b3(_0x151b6d);})[_0x4bfe('0x15')](function(_0x39aa96){logger[_0x4bfe('0x12')]('UpdateOpenchannelApplication',_0x39aa96[_0x4bfe('0x14')],_0x45178e);_0x107c16(_0x394736[_0x4bfe('0x12')](0x1f4,_0x39aa96['message']));});});};