Built motion from commit 9e1ec266.|2.6.28
[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 _0xf9d5=['code','error','message','result','catch','OpenchannelApplication','update','body','options','raw','where','attributes','limit','UpdateOpenchannelApplication','stringify','util','moment','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','info','OpenchannelApplication,\x20%s,\x20%s','request\x20sent','debug'];(function(_0x3a2e49,_0x21ebea){var _0x257140=function(_0x5a2362){while(--_0x5a2362){_0x3a2e49['push'](_0x3a2e49['shift']());}};_0x257140(++_0x21ebea);}(_0xf9d5,0x1e0));var _0x5f9d=function(_0x4bc873,_0x2e2c33){_0x4bc873=_0x4bc873-0x0;var _0x1faa4e=_0xf9d5[_0x4bc873];return _0x1faa4e;};'use strict';var _=require('lodash');var util=require(_0x5f9d('0x0'));var moment=require(_0x5f9d('0x1'));var BPromise=require(_0x5f9d('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x5f9d('0x3'));var db=require(_0x5f9d('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x5f9d('0x5'))(_0x5f9d('0x6'));var config=require(_0x5f9d('0x7'));var jayson=require(_0x5f9d('0x8'));var client=jayson[_0x5f9d('0x9')][_0x5f9d('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x29f40d,_0xe5b654,_0x2ad682){return new BPromise(function(_0x2c3152,_0x10047d){return client[_0x5f9d('0xb')](_0x29f40d,_0x2ad682)['then'](function(_0x1a4f7c){logger[_0x5f9d('0xc')](_0x5f9d('0xd'),_0xe5b654,_0x5f9d('0xe'));logger[_0x5f9d('0xf')]('OpenchannelApplication,\x20%s,\x20%s,\x20%s',_0xe5b654,_0x5f9d('0xe'),JSON['stringify'](_0x1a4f7c));if(_0x1a4f7c['error']){if(_0x1a4f7c['error'][_0x5f9d('0x10')]===0x1f4){logger[_0x5f9d('0x11')](_0x5f9d('0xd'),_0xe5b654,_0x1a4f7c[_0x5f9d('0x11')][_0x5f9d('0x12')]);return _0x10047d(_0x1a4f7c[_0x5f9d('0x11')][_0x5f9d('0x12')]);}logger['error']('OpenchannelApplication,\x20%s,\x20%s',_0xe5b654,_0x1a4f7c['error'][_0x5f9d('0x12')]);return _0x2c3152(_0x1a4f7c[_0x5f9d('0x11')][_0x5f9d('0x12')]);}else{logger[_0x5f9d('0xc')](_0x5f9d('0xd'),_0xe5b654,_0x5f9d('0xe'));_0x2c3152(_0x1a4f7c[_0x5f9d('0x13')]['message']);}})[_0x5f9d('0x14')](function(_0x58852c){logger[_0x5f9d('0x11')](_0x5f9d('0xd'),_0xe5b654,_0x58852c);_0x10047d(_0x58852c);});});}exports['UpdateOpenchannelApplication']=function(_0x3f79a0){var _0xb40727=this;return new Promise(function(_0x4ee6b1,_0x102b26){return db[_0x5f9d('0x15')][_0x5f9d('0x16')](_0x3f79a0[_0x5f9d('0x17')],{'raw':_0x3f79a0[_0x5f9d('0x18')]?_0x3f79a0[_0x5f9d('0x18')][_0x5f9d('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3f79a0[_0x5f9d('0x18')]?_0x3f79a0[_0x5f9d('0x18')][_0x5f9d('0x1a')]||null:null,'attributes':_0x3f79a0[_0x5f9d('0x18')]?_0x3f79a0[_0x5f9d('0x18')][_0x5f9d('0x1b')]||null:null,'limit':_0x3f79a0['options']?_0x3f79a0[_0x5f9d('0x18')][_0x5f9d('0x1c')]||null:null})['then'](function(_0x234abe){logger[_0x5f9d('0xc')](_0x5f9d('0x1d'),_0x3f79a0);logger[_0x5f9d('0xf')](_0x5f9d('0x1d'),_0x3f79a0,JSON[_0x5f9d('0x1e')](_0x234abe));_0x4ee6b1(_0x234abe);})[_0x5f9d('0x14')](function(_0x145fa2){logger['error'](_0x5f9d('0x1d'),_0x145fa2[_0x5f9d('0x12')],_0x3f79a0);_0x102b26(_0xb40727[_0x5f9d('0x11')](0x1f4,_0x145fa2[_0x5f9d('0x12')]));});});};