Built motion from commit (unavailable).|2.4.3
[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 _0x0319=['UpdateSmsInteraction','SmsInteraction','body','options','raw','where','attributes','limit','then','debug','AddTagsToSmsInteraction','find','addTags','omit','AddTags','lodash','moment','randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./smsInteraction.socket','request','info','request\x20sent','SmsInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','SmsInteraction,\x20%s,\x20%s','message','result','catch'];(function(_0x5db034,_0x1d2f4d){var _0x5170cd=function(_0x411e43){while(--_0x411e43){_0x5db034['push'](_0x5db034['shift']());}};_0x5170cd(++_0x1d2f4d);}(_0x0319,0xa7));var _0x9031=function(_0xbca1b1,_0x33f0ce){_0xbca1b1=_0xbca1b1-0x0;var _0x4e1686=_0x0319[_0xbca1b1];return _0x4e1686;};'use strict';var _=require(_0x9031('0x0'));var util=require('util');var moment=require(_0x9031('0x1'));var BPromise=require('bluebird');var rs=require(_0x9031('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x9031('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x9031('0x4'));var config=require(_0x9031('0x5'));var jayson=require(_0x9031('0x6'));var client=jayson['client'][_0x9031('0x7')]({'port':0x232a});config[_0x9031('0x8')]=_['defaults'](config[_0x9031('0x8')],{'host':_0x9031('0x9'),'port':0x18eb});var socket=require(_0x9031('0xa'))(new Redis(config[_0x9031('0x8')]));require(_0x9031('0xb'))['register'](socket);function respondWithRpcPromise(_0x3b13cc,_0x27d915,_0x54df3d){return new BPromise(function(_0x429911,_0x4b7f6b){return client[_0x9031('0xc')](_0x3b13cc,_0x54df3d)['then'](function(_0x59085d){logger[_0x9031('0xd')]('SmsInteraction,\x20%s,\x20%s',_0x27d915,_0x9031('0xe'));logger['debug'](_0x9031('0xf'),_0x27d915,'request\x20sent',JSON[_0x9031('0x10')](_0x59085d));if(_0x59085d[_0x9031('0x11')]){if(_0x59085d[_0x9031('0x11')][_0x9031('0x12')]===0x1f4){logger['error'](_0x9031('0x13'),_0x27d915,_0x59085d[_0x9031('0x11')][_0x9031('0x14')]);return _0x4b7f6b(_0x59085d[_0x9031('0x11')][_0x9031('0x14')]);}logger[_0x9031('0x11')]('SmsInteraction,\x20%s,\x20%s',_0x27d915,_0x59085d[_0x9031('0x11')][_0x9031('0x14')]);return _0x429911(_0x59085d[_0x9031('0x11')]['message']);}else{logger[_0x9031('0xd')](_0x9031('0x13'),_0x27d915,'request\x20sent');_0x429911(_0x59085d[_0x9031('0x15')][_0x9031('0x14')]);}})[_0x9031('0x16')](function(_0xf9013c){logger[_0x9031('0x11')](_0x9031('0x13'),_0x27d915,_0xf9013c);_0x4b7f6b(_0xf9013c);});});}exports[_0x9031('0x17')]=function(_0x5c2454){var _0x1a7a40=this;return new Promise(function(_0x5252e7,_0x51b7d2){return db[_0x9031('0x18')]['update'](_0x5c2454[_0x9031('0x19')],{'raw':_0x5c2454[_0x9031('0x1a')]?_0x5c2454[_0x9031('0x1a')][_0x9031('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x5c2454[_0x9031('0x1a')]?_0x5c2454[_0x9031('0x1a')][_0x9031('0x1c')]||null:null,'attributes':_0x5c2454['options']?_0x5c2454[_0x9031('0x1a')][_0x9031('0x1d')]||null:null,'limit':_0x5c2454[_0x9031('0x1a')]?_0x5c2454['options'][_0x9031('0x1e')]||null:null})[_0x9031('0x1f')](function(_0x2a2d34){logger[_0x9031('0xd')](_0x9031('0x17'),_0x5c2454);logger[_0x9031('0x20')](_0x9031('0x17'),_0x5c2454,JSON[_0x9031('0x10')](_0x2a2d34));_0x5252e7(_0x2a2d34);})[_0x9031('0x16')](function(_0x2dcc40){logger[_0x9031('0x11')](_0x9031('0x17'),_0x2dcc40[_0x9031('0x14')],_0x5c2454);_0x51b7d2(_0x1a7a40[_0x9031('0x11')](0x1f4,_0x2dcc40[_0x9031('0x14')]));});});};exports[_0x9031('0x21')]=function(_0x5a0a0a){return new Promise(function(_0x510823,_0x4db77d){return db[_0x9031('0x18')][_0x9031('0x22')]({'where':_0x5a0a0a[_0x9031('0x1a')]?_0x5a0a0a[_0x9031('0x1a')]['where']||null:null})[_0x9031('0x1f')](function(_0x8a4ae5){if(_0x8a4ae5){return _0x8a4ae5[_0x9031('0x23')](_0x5a0a0a['body']['ids'],_[_0x9031('0x24')](_0x5a0a0a[_0x9031('0x19')],['ids','id'])||{});}})['spread'](function(_0x4fee23){logger[_0x9031('0xd')](_0x9031('0x25'),_0x5a0a0a);logger[_0x9031('0x20')](_0x9031('0x25'),_0x5a0a0a,JSON[_0x9031('0x10')](_0x4fee23));_0x510823(_0x4fee23);})[_0x9031('0x16')](function(_0x1c0246){logger[_0x9031('0x11')]('AddTags',_0x1c0246[_0x9031('0x14')],_0x5a0a0a);_0x4db77d(_this['error'](0x1f4,_0x1c0246['message']));});});};