Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / smsInteraction / smsInteraction.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 _0x2273=['redis','localhost','socket.io-emitter','./smsInteraction.socket','register','request','info','SmsInteraction,\x20%s,\x20%s','request\x20sent','debug','SmsInteraction,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','UpdateSmsInteraction','SmsInteraction','update','body','options','raw','attributes','limit','then','stringify','AddTagsToSmsInteraction','find','where','addTags','omit','ids','spread','AddTags','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','defaults'];(function(_0x36e973,_0x3cd3b4){var _0x3606bd=function(_0x826d3f){while(--_0x826d3f){_0x36e973['push'](_0x36e973['shift']());}};_0x3606bd(++_0x3cd3b4);}(_0x2273,0x1d2));var _0x3227=function(_0x27bd8c,_0x4799e2){_0x27bd8c=_0x27bd8c-0x0;var _0x255b26=_0x2273[_0x27bd8c];return _0x255b26;};'use strict';var _=require(_0x3227('0x0'));var util=require('util');var moment=require(_0x3227('0x1'));var BPromise=require(_0x3227('0x2'));var rs=require(_0x3227('0x3'));var fs=require('fs');var Redis=require(_0x3227('0x4'));var db=require(_0x3227('0x5'))['db'];var utils=require(_0x3227('0x6'));var logger=require(_0x3227('0x7'))(_0x3227('0x8'));var config=require(_0x3227('0x9'));var jayson=require(_0x3227('0xa'));var client=jayson[_0x3227('0xb')][_0x3227('0xc')]({'port':0x232a});config['redis']=_[_0x3227('0xd')](config[_0x3227('0xe')],{'host':_0x3227('0xf'),'port':0x18eb});var socket=require(_0x3227('0x10'))(new Redis(config[_0x3227('0xe')]));require(_0x3227('0x11'))[_0x3227('0x12')](socket);function respondWithRpcPromise(_0x55ca78,_0x208eb4,_0x4ae66d){return new BPromise(function(_0x365b77,_0x513f06){return client[_0x3227('0x13')](_0x55ca78,_0x4ae66d)['then'](function(_0x15c923){logger[_0x3227('0x14')](_0x3227('0x15'),_0x208eb4,_0x3227('0x16'));logger[_0x3227('0x17')](_0x3227('0x18'),_0x208eb4,_0x3227('0x16'),JSON['stringify'](_0x15c923));if(_0x15c923['error']){if(_0x15c923[_0x3227('0x19')][_0x3227('0x1a')]===0x1f4){logger['error'](_0x3227('0x15'),_0x208eb4,_0x15c923[_0x3227('0x19')][_0x3227('0x1b')]);return _0x513f06(_0x15c923[_0x3227('0x19')][_0x3227('0x1b')]);}logger[_0x3227('0x19')](_0x3227('0x15'),_0x208eb4,_0x15c923['error'][_0x3227('0x1b')]);return _0x365b77(_0x15c923[_0x3227('0x19')][_0x3227('0x1b')]);}else{logger[_0x3227('0x14')](_0x3227('0x15'),_0x208eb4,_0x3227('0x16'));_0x365b77(_0x15c923[_0x3227('0x1c')]['message']);}})[_0x3227('0x1d')](function(_0x5eb4c3){logger[_0x3227('0x19')](_0x3227('0x15'),_0x208eb4,_0x5eb4c3);_0x513f06(_0x5eb4c3);});});}exports[_0x3227('0x1e')]=function(_0x3e2f77){var _0x10fc1a=this;return new Promise(function(_0x3a3ee7,_0x34e632){return db[_0x3227('0x1f')][_0x3227('0x20')](_0x3e2f77[_0x3227('0x21')],{'raw':_0x3e2f77[_0x3227('0x22')]?_0x3e2f77[_0x3227('0x22')][_0x3227('0x23')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3e2f77[_0x3227('0x22')]?_0x3e2f77[_0x3227('0x22')]['where']||null:null,'attributes':_0x3e2f77['options']?_0x3e2f77[_0x3227('0x22')][_0x3227('0x24')]||null:null,'limit':_0x3e2f77[_0x3227('0x22')]?_0x3e2f77['options'][_0x3227('0x25')]||null:null})[_0x3227('0x26')](function(_0xdcfeda){logger['info'](_0x3227('0x1e'),_0x3e2f77);logger[_0x3227('0x17')]('UpdateSmsInteraction',_0x3e2f77,JSON[_0x3227('0x27')](_0xdcfeda));_0x3a3ee7(_0xdcfeda);})[_0x3227('0x1d')](function(_0x5d1c12){logger['error'](_0x3227('0x1e'),_0x5d1c12[_0x3227('0x1b')],_0x3e2f77);_0x34e632(_0x10fc1a['error'](0x1f4,_0x5d1c12[_0x3227('0x1b')]));});});};exports[_0x3227('0x28')]=function(_0x3e0bd5){return new Promise(function(_0x41b9a2,_0x2ba150){return db[_0x3227('0x1f')][_0x3227('0x29')]({'where':_0x3e0bd5['options']?_0x3e0bd5[_0x3227('0x22')][_0x3227('0x2a')]||null:null})[_0x3227('0x26')](function(_0x3f5d25){if(_0x3f5d25){return _0x3f5d25[_0x3227('0x2b')](_0x3e0bd5[_0x3227('0x21')]['ids'],_[_0x3227('0x2c')](_0x3e0bd5[_0x3227('0x21')],[_0x3227('0x2d'),'id'])||{});}})[_0x3227('0x2e')](function(_0x55a08b){logger[_0x3227('0x14')](_0x3227('0x2f'),_0x3e0bd5);logger['debug'](_0x3227('0x2f'),_0x3e0bd5,JSON[_0x3227('0x27')](_0x55a08b));_0x41b9a2(_0x55a08b);})['catch'](function(_0x422c3d){logger[_0x3227('0x19')](_0x3227('0x2f'),_0x422c3d[_0x3227('0x1b')],_0x3e0bd5);_0x2ba150(_this[_0x3227('0x19')](0x1f4,_0x422c3d['message']));});});};