Built motion from commit (unavailable).|2.5.6
[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 _0x0321=['request','then','request\x20sent','debug','stringify','error','code','OpenchannelInteraction,\x20%s,\x20%s','message','info','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','where','attributes','limit','AddTagsToOpenchannelInteraction','find','addTags','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','client','http','redis','localhost','./openchannelInteraction.socket','register'];(function(_0x2a56ad,_0x2b94bf){var _0x425175=function(_0x342f20){while(--_0x342f20){_0x2a56ad['push'](_0x2a56ad['shift']());}};_0x425175(++_0x2b94bf);}(_0x0321,0xc3));var _0x1032=function(_0x19453a,_0x5c22c2){_0x19453a=_0x19453a-0x0;var _0xc20964=_0x0321[_0x19453a];return _0xc20964;};'use strict';var _=require(_0x1032('0x0'));var util=require(_0x1032('0x1'));var moment=require(_0x1032('0x2'));var BPromise=require(_0x1032('0x3'));var rs=require(_0x1032('0x4'));var fs=require('fs');var Redis=require(_0x1032('0x5'));var db=require(_0x1032('0x6'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x1032('0x7'));var config=require(_0x1032('0x8'));var jayson=require('jayson/promise');var client=jayson[_0x1032('0x9')][_0x1032('0xa')]({'port':0x232a});config['redis']=_['defaults'](config[_0x1032('0xb')],{'host':_0x1032('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x1032('0xb')]));require(_0x1032('0xd'))[_0x1032('0xe')](socket);function respondWithRpcPromise(_0x4ee07a,_0x4b3888,_0x113254){return new BPromise(function(_0x2d9c21,_0x10bf25){return client[_0x1032('0xf')](_0x4ee07a,_0x113254)[_0x1032('0x10')](function(_0x457141){logger['info']('OpenchannelInteraction,\x20%s,\x20%s',_0x4b3888,_0x1032('0x11'));logger[_0x1032('0x12')]('OpenchannelInteraction,\x20%s,\x20%s,\x20%s',_0x4b3888,_0x1032('0x11'),JSON[_0x1032('0x13')](_0x457141));if(_0x457141['error']){if(_0x457141[_0x1032('0x14')][_0x1032('0x15')]===0x1f4){logger[_0x1032('0x14')](_0x1032('0x16'),_0x4b3888,_0x457141[_0x1032('0x14')]['message']);return _0x10bf25(_0x457141[_0x1032('0x14')][_0x1032('0x17')]);}logger[_0x1032('0x14')]('OpenchannelInteraction,\x20%s,\x20%s',_0x4b3888,_0x457141[_0x1032('0x14')][_0x1032('0x17')]);return _0x2d9c21(_0x457141[_0x1032('0x14')][_0x1032('0x17')]);}else{logger[_0x1032('0x18')]('OpenchannelInteraction,\x20%s,\x20%s',_0x4b3888,_0x1032('0x11'));_0x2d9c21(_0x457141['result']['message']);}})[_0x1032('0x19')](function(_0xc83d78){logger[_0x1032('0x14')](_0x1032('0x16'),_0x4b3888,_0xc83d78);_0x10bf25(_0xc83d78);});});}exports[_0x1032('0x1a')]=function(_0x5bb41b){var _0xda0a71=this;return new Promise(function(_0x4a2360,_0x30bdfa){return db[_0x1032('0x1b')][_0x1032('0x1c')](_0x5bb41b[_0x1032('0x1d')],{'raw':_0x5bb41b[_0x1032('0x1e')]?_0x5bb41b[_0x1032('0x1e')][_0x1032('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5bb41b[_0x1032('0x1e')]?_0x5bb41b[_0x1032('0x1e')][_0x1032('0x20')]||null:null,'attributes':_0x5bb41b['options']?_0x5bb41b[_0x1032('0x1e')][_0x1032('0x21')]||null:null,'limit':_0x5bb41b[_0x1032('0x1e')]?_0x5bb41b[_0x1032('0x1e')][_0x1032('0x22')]||null:null})[_0x1032('0x10')](function(_0x3727d7){logger[_0x1032('0x18')](_0x1032('0x1a'),_0x5bb41b);logger[_0x1032('0x12')](_0x1032('0x1a'),_0x5bb41b,JSON[_0x1032('0x13')](_0x3727d7));_0x4a2360(_0x3727d7);})[_0x1032('0x19')](function(_0x413b3c){logger[_0x1032('0x14')](_0x1032('0x1a'),_0x413b3c[_0x1032('0x17')],_0x5bb41b);_0x30bdfa(_0xda0a71['error'](0x1f4,_0x413b3c[_0x1032('0x17')]));});});};exports[_0x1032('0x23')]=function(_0x267e82){return new Promise(function(_0x393e66,_0xbd3bd1){return db[_0x1032('0x1b')][_0x1032('0x24')]({'where':_0x267e82[_0x1032('0x1e')]?_0x267e82[_0x1032('0x1e')]['where']||null:null})[_0x1032('0x10')](function(_0x3df35a){if(_0x3df35a){return _0x3df35a[_0x1032('0x25')](_0x267e82[_0x1032('0x1d')][_0x1032('0x26')],_[_0x1032('0x27')](_0x267e82['body'],[_0x1032('0x26'),'id'])||{});}})[_0x1032('0x28')](function(_0x539511){logger[_0x1032('0x18')]('AddTags',_0x267e82);logger[_0x1032('0x12')](_0x1032('0x29'),_0x267e82,JSON[_0x1032('0x13')](_0x539511));_0x393e66(_0x539511);})[_0x1032('0x19')](function(_0x105d55){logger[_0x1032('0x14')](_0x1032('0x29'),_0x105d55[_0x1032('0x17')],_0x267e82);_0xbd3bd1(_this[_0x1032('0x14')](0x1f4,_0x105d55[_0x1032('0x17')]));});});};