Built motion from commit (unavailable).|2.4.4
[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 _0x2d72=['socket.io-emitter','./openchannelInteraction.socket','register','request','then','OpenchannelInteraction,\x20%s,\x20%s','debug','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','request\x20sent','result','catch','UpdateOpenchannelInteraction','body','options','raw','where','attributes','limit','AddTagsToOpenchannelInteraction','OpenchannelInteraction','find','ids','omit','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults','redis'];(function(_0x2ac149,_0x59f4c3){var _0x6e04ec=function(_0x19a039){while(--_0x19a039){_0x2ac149['push'](_0x2ac149['shift']());}};_0x6e04ec(++_0x59f4c3);}(_0x2d72,0xa8));var _0x22d7=function(_0x3611fe,_0x1dc928){_0x3611fe=_0x3611fe-0x0;var _0x1571f3=_0x2d72[_0x3611fe];return _0x1571f3;};'use strict';var _=require(_0x22d7('0x0'));var util=require(_0x22d7('0x1'));var moment=require(_0x22d7('0x2'));var BPromise=require(_0x22d7('0x3'));var rs=require(_0x22d7('0x4'));var fs=require('fs');var Redis=require(_0x22d7('0x5'));var db=require(_0x22d7('0x6'))['db'];var utils=require(_0x22d7('0x7'));var logger=require(_0x22d7('0x8'))(_0x22d7('0x9'));var config=require(_0x22d7('0xa'));var jayson=require(_0x22d7('0xb'));var client=jayson[_0x22d7('0xc')][_0x22d7('0xd')]({'port':0x232a});config['redis']=_[_0x22d7('0xe')](config[_0x22d7('0xf')],{'host':'localhost','port':0x18eb});var socket=require(_0x22d7('0x10'))(new Redis(config[_0x22d7('0xf')]));require(_0x22d7('0x11'))[_0x22d7('0x12')](socket);function respondWithRpcPromise(_0x49f7e1,_0x5f56eb,_0x1810b8){return new BPromise(function(_0x257c85,_0x233c0b){return client[_0x22d7('0x13')](_0x49f7e1,_0x1810b8)[_0x22d7('0x14')](function(_0x4db5dd){logger['info'](_0x22d7('0x15'),_0x5f56eb,'request\x20sent');logger[_0x22d7('0x16')](_0x22d7('0x17'),_0x5f56eb,'request\x20sent',JSON[_0x22d7('0x18')](_0x4db5dd));if(_0x4db5dd[_0x22d7('0x19')]){if(_0x4db5dd[_0x22d7('0x19')][_0x22d7('0x1a')]===0x1f4){logger[_0x22d7('0x19')](_0x22d7('0x15'),_0x5f56eb,_0x4db5dd[_0x22d7('0x19')][_0x22d7('0x1b')]);return _0x233c0b(_0x4db5dd['error'][_0x22d7('0x1b')]);}logger[_0x22d7('0x19')](_0x22d7('0x15'),_0x5f56eb,_0x4db5dd['error']['message']);return _0x257c85(_0x4db5dd['error'][_0x22d7('0x1b')]);}else{logger[_0x22d7('0x1c')](_0x22d7('0x15'),_0x5f56eb,_0x22d7('0x1d'));_0x257c85(_0x4db5dd[_0x22d7('0x1e')]['message']);}})[_0x22d7('0x1f')](function(_0x75affd){logger[_0x22d7('0x19')]('OpenchannelInteraction,\x20%s,\x20%s',_0x5f56eb,_0x75affd);_0x233c0b(_0x75affd);});});}exports[_0x22d7('0x20')]=function(_0x7f2905){var _0x3574e4=this;return new Promise(function(_0xcb35a8,_0x6be49e){return db['OpenchannelInteraction']['update'](_0x7f2905[_0x22d7('0x21')],{'raw':_0x7f2905[_0x22d7('0x22')]?_0x7f2905[_0x22d7('0x22')][_0x22d7('0x23')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x7f2905['options']?_0x7f2905[_0x22d7('0x22')][_0x22d7('0x24')]||null:null,'attributes':_0x7f2905[_0x22d7('0x22')]?_0x7f2905['options'][_0x22d7('0x25')]||null:null,'limit':_0x7f2905['options']?_0x7f2905[_0x22d7('0x22')][_0x22d7('0x26')]||null:null})[_0x22d7('0x14')](function(_0x5db3aa){logger[_0x22d7('0x1c')]('UpdateOpenchannelInteraction',_0x7f2905);logger['debug'](_0x22d7('0x20'),_0x7f2905,JSON[_0x22d7('0x18')](_0x5db3aa));_0xcb35a8(_0x5db3aa);})[_0x22d7('0x1f')](function(_0x27998a){logger[_0x22d7('0x19')]('UpdateOpenchannelInteraction',_0x27998a[_0x22d7('0x1b')],_0x7f2905);_0x6be49e(_0x3574e4[_0x22d7('0x19')](0x1f4,_0x27998a[_0x22d7('0x1b')]));});});};exports[_0x22d7('0x27')]=function(_0x45dc29){return new Promise(function(_0x49199a,_0x2606bd){return db[_0x22d7('0x28')][_0x22d7('0x29')]({'where':_0x45dc29[_0x22d7('0x22')]?_0x45dc29['options'][_0x22d7('0x24')]||null:null})[_0x22d7('0x14')](function(_0x47ef72){if(_0x47ef72){return _0x47ef72['addTags'](_0x45dc29['body'][_0x22d7('0x2a')],_[_0x22d7('0x2b')](_0x45dc29[_0x22d7('0x21')],['ids','id'])||{});}})[_0x22d7('0x2c')](function(_0x5ef395){logger[_0x22d7('0x1c')](_0x22d7('0x2d'),_0x45dc29);logger[_0x22d7('0x16')](_0x22d7('0x2d'),_0x45dc29,JSON[_0x22d7('0x18')](_0x5ef395));_0x49199a(_0x5ef395);})[_0x22d7('0x1f')](function(_0x4ac16c){logger['error'](_0x22d7('0x2d'),_0x4ac16c['message'],_0x45dc29);_0x2606bd(_this[_0x22d7('0x19')](0x1f4,_0x4ac16c[_0x22d7('0x1b')]));});});};