Built motion from commit f3da74b7.|2.5.36
[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 _0x9966=['request\x20sent','error','code','message','info','catch','UpdateOpenchannelApplication','OpenchannelApplication','update','body','options','raw','where','attributes','limit','stringify','util','bluebird','randomstring','ioredis','../../config/logger','../../config/environment','jayson/promise','client','http','request','then','OpenchannelApplication,\x20%s,\x20%s','debug','OpenchannelApplication,\x20%s,\x20%s,\x20%s'];(function(_0x22b39b,_0x2b7d63){var _0x280e1d=function(_0xc74635){while(--_0xc74635){_0x22b39b['push'](_0x22b39b['shift']());}};_0x280e1d(++_0x2b7d63);}(_0x9966,0x11e));var _0x6996=function(_0x27e649,_0x40868c){_0x27e649=_0x27e649-0x0;var _0x27f389=_0x9966[_0x27e649];return _0x27f389;};'use strict';var _=require('lodash');var util=require(_0x6996('0x0'));var moment=require('moment');var BPromise=require(_0x6996('0x1'));var rs=require(_0x6996('0x2'));var fs=require('fs');var Redis=require(_0x6996('0x3'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x6996('0x4'))('rpc');var config=require(_0x6996('0x5'));var jayson=require(_0x6996('0x6'));var client=jayson[_0x6996('0x7')][_0x6996('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1e1612,_0x26287b,_0xde4bef){return new BPromise(function(_0x104aec,_0x3913ae){return client[_0x6996('0x9')](_0x1e1612,_0xde4bef)[_0x6996('0xa')](function(_0x52edd9){logger['info'](_0x6996('0xb'),_0x26287b,'request\x20sent');logger[_0x6996('0xc')](_0x6996('0xd'),_0x26287b,_0x6996('0xe'),JSON['stringify'](_0x52edd9));if(_0x52edd9[_0x6996('0xf')]){if(_0x52edd9[_0x6996('0xf')][_0x6996('0x10')]===0x1f4){logger[_0x6996('0xf')](_0x6996('0xb'),_0x26287b,_0x52edd9[_0x6996('0xf')]['message']);return _0x3913ae(_0x52edd9[_0x6996('0xf')][_0x6996('0x11')]);}logger['error'](_0x6996('0xb'),_0x26287b,_0x52edd9[_0x6996('0xf')][_0x6996('0x11')]);return _0x104aec(_0x52edd9[_0x6996('0xf')]['message']);}else{logger[_0x6996('0x12')]('OpenchannelApplication,\x20%s,\x20%s',_0x26287b,'request\x20sent');_0x104aec(_0x52edd9['result'][_0x6996('0x11')]);}})[_0x6996('0x13')](function(_0x4bb54b){logger['error'](_0x6996('0xb'),_0x26287b,_0x4bb54b);_0x3913ae(_0x4bb54b);});});}exports[_0x6996('0x14')]=function(_0x36f370){var _0x5abb5d=this;return new Promise(function(_0x6a2a9c,_0x71740c){return db[_0x6996('0x15')][_0x6996('0x16')](_0x36f370[_0x6996('0x17')],{'raw':_0x36f370[_0x6996('0x18')]?_0x36f370[_0x6996('0x18')][_0x6996('0x19')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x36f370['options']?_0x36f370[_0x6996('0x18')][_0x6996('0x1a')]||null:null,'attributes':_0x36f370[_0x6996('0x18')]?_0x36f370['options'][_0x6996('0x1b')]||null:null,'limit':_0x36f370[_0x6996('0x18')]?_0x36f370[_0x6996('0x18')][_0x6996('0x1c')]||null:null})[_0x6996('0xa')](function(_0x3799a3){logger['info'](_0x6996('0x14'),_0x36f370);logger[_0x6996('0xc')](_0x6996('0x14'),_0x36f370,JSON[_0x6996('0x1d')](_0x3799a3));_0x6a2a9c(_0x3799a3);})[_0x6996('0x13')](function(_0x5ea3b0){logger['error']('UpdateOpenchannelApplication',_0x5ea3b0[_0x6996('0x11')],_0x36f370);_0x71740c(_0x5abb5d[_0x6996('0xf')](0x1f4,_0x5ea3b0[_0x6996('0x11')]));});});};