Built motion from commit (unavailable).|2.3.94
[motion2.git] / server / api / openchannelInteraction / openchannelInteraction.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 _0x56a4=['limit','debug','catch','AddTagsToOpenchannelInteraction','addTags','body','ids','omit','spread','AddTags','lodash','util','bluebird','randomstring','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','request','then','info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','error','code','message','result','UpdateOpenchannelInteraction','OpenchannelInteraction','options','raw','where'];(function(_0x2343c9,_0x3bd974){var _0x4fee71=function(_0x1cb968){while(--_0x1cb968){_0x2343c9['push'](_0x2343c9['shift']());}};_0x4fee71(++_0x3bd974);}(_0x56a4,0x11b));var _0x456a=function(_0x485038,_0x3e26e8){_0x485038=_0x485038-0x0;var _0xa87ace=_0x56a4[_0x485038];return _0xa87ace;};'use strict';var _=require(_0x456a('0x0'));var util=require(_0x456a('0x1'));var moment=require('moment');var BPromise=require(_0x456a('0x2'));var rs=require(_0x456a('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x456a('0x4'));var logger=require(_0x456a('0x5'))(_0x456a('0x6'));var config=require(_0x456a('0x7'));var jayson=require(_0x456a('0x8'));var client=jayson['client'][_0x456a('0x9')]({'port':0x232a});config['redis']=_['defaults'](config[_0x456a('0xa')],{'host':_0x456a('0xb'),'port':0x18eb});var socket=require(_0x456a('0xc'))(new Redis(config['redis']));require(_0x456a('0xd'))['register'](socket);function respondWithRpcPromise(_0xb56df,_0x29073f,_0x3bb712){return new BPromise(function(_0x3b57ac,_0x2706a7){return client[_0x456a('0xe')](_0xb56df,_0x3bb712)[_0x456a('0xf')](function(_0xe60506){logger[_0x456a('0x10')](_0x456a('0x11'),_0x29073f,_0x456a('0x12'));logger['debug'](_0x456a('0x13'),_0x29073f,'request\x20sent',JSON['stringify'](_0xe60506));if(_0xe60506[_0x456a('0x14')]){if(_0xe60506[_0x456a('0x14')][_0x456a('0x15')]===0x1f4){logger[_0x456a('0x14')]('OpenchannelInteraction,\x20%s,\x20%s',_0x29073f,_0xe60506[_0x456a('0x14')][_0x456a('0x16')]);return _0x2706a7(_0xe60506[_0x456a('0x14')][_0x456a('0x16')]);}logger[_0x456a('0x14')](_0x456a('0x11'),_0x29073f,_0xe60506['error'][_0x456a('0x16')]);return _0x3b57ac(_0xe60506[_0x456a('0x14')][_0x456a('0x16')]);}else{logger[_0x456a('0x10')]('OpenchannelInteraction,\x20%s,\x20%s',_0x29073f,_0x456a('0x12'));_0x3b57ac(_0xe60506[_0x456a('0x17')][_0x456a('0x16')]);}})['catch'](function(_0x3d06b4){logger['error']('OpenchannelInteraction,\x20%s,\x20%s',_0x29073f,_0x3d06b4);_0x2706a7(_0x3d06b4);});});}exports[_0x456a('0x18')]=function(_0x562cfa){var _0x44d79a=this;return new Promise(function(_0x4b48bf,_0x962b6d){return db[_0x456a('0x19')]['update'](_0x562cfa['body'],{'raw':_0x562cfa['options']?_0x562cfa[_0x456a('0x1a')][_0x456a('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x562cfa[_0x456a('0x1a')]?_0x562cfa['options'][_0x456a('0x1c')]||null:null,'attributes':_0x562cfa['options']?_0x562cfa['options']['attributes']||null:null,'limit':_0x562cfa[_0x456a('0x1a')]?_0x562cfa[_0x456a('0x1a')][_0x456a('0x1d')]||null:null})['then'](function(_0x45ea0c){logger[_0x456a('0x10')]('UpdateOpenchannelInteraction',_0x562cfa);logger[_0x456a('0x1e')]('UpdateOpenchannelInteraction',_0x562cfa,JSON['stringify'](_0x45ea0c));_0x4b48bf(_0x45ea0c);})[_0x456a('0x1f')](function(_0x5441d1){logger[_0x456a('0x14')]('UpdateOpenchannelInteraction',_0x5441d1[_0x456a('0x16')],_0x562cfa);_0x962b6d(_0x44d79a[_0x456a('0x14')](0x1f4,_0x5441d1[_0x456a('0x16')]));});});};exports[_0x456a('0x20')]=function(_0xe280fc){return new Promise(function(_0x3036e4,_0x46f3b3){return db[_0x456a('0x19')]['find']({'where':_0xe280fc['options']?_0xe280fc['options'][_0x456a('0x1c')]||null:null})[_0x456a('0xf')](function(_0x564301){if(_0x564301){return _0x564301[_0x456a('0x21')](_0xe280fc[_0x456a('0x22')][_0x456a('0x23')],_[_0x456a('0x24')](_0xe280fc[_0x456a('0x22')],['ids','id'])||{});}})[_0x456a('0x25')](function(_0x3e8ee3){logger[_0x456a('0x10')]('AddTags',_0xe280fc);logger[_0x456a('0x1e')](_0x456a('0x26'),_0xe280fc,JSON['stringify'](_0x3e8ee3));_0x3036e4(_0x3e8ee3);})[_0x456a('0x1f')](function(_0x24efbc){logger[_0x456a('0x14')](_0x456a('0x26'),_0x24efbc[_0x456a('0x16')],_0xe280fc);_0x46f3b3(_this['error'](0x1f4,_0x24efbc[_0x456a('0x16')]));});});};