Built motion from commit 44b1f254.|2.6.26
[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 _0xb20d=['debug','SmsInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','SmsInteraction,\x20%s,\x20%s','message','result','catch','UpdateSmsInteraction','update','body','options','raw','where','attributes','limit','AddTagsToSmsInteraction','SmsInteraction','addTags','ids','omit','AddTags','lodash','util','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','jayson/promise','client','http','redis','defaults','socket.io-emitter','./smsInteraction.socket','register','request','then','info'];(function(_0x4f81b8,_0x5ab18b){var _0x3408c1=function(_0x4f78d5){while(--_0x4f78d5){_0x4f81b8['push'](_0x4f81b8['shift']());}};_0x3408c1(++_0x5ab18b);}(_0xb20d,0x96));var _0xdb20=function(_0x5fbeb0,_0x3eb180){_0x5fbeb0=_0x5fbeb0-0x0;var _0x502a3a=_0xb20d[_0x5fbeb0];return _0x502a3a;};'use strict';var _=require(_0xdb20('0x0'));var util=require(_0xdb20('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0xdb20('0x2'));var fs=require('fs');var Redis=require(_0xdb20('0x3'));var db=require(_0xdb20('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xdb20('0x5'))(_0xdb20('0x6'));var config=require('../../config/environment');var jayson=require(_0xdb20('0x7'));var client=jayson[_0xdb20('0x8')][_0xdb20('0x9')]({'port':0x232a});config[_0xdb20('0xa')]=_[_0xdb20('0xb')](config[_0xdb20('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0xdb20('0xc'))(new Redis(config[_0xdb20('0xa')]));require(_0xdb20('0xd'))[_0xdb20('0xe')](socket);function respondWithRpcPromise(_0x2d3d20,_0x3aa540,_0x4dd8f1){return new BPromise(function(_0x5804fc,_0x2ea05c){return client[_0xdb20('0xf')](_0x2d3d20,_0x4dd8f1)[_0xdb20('0x10')](function(_0x2ea7ef){logger[_0xdb20('0x11')]('SmsInteraction,\x20%s,\x20%s',_0x3aa540,'request\x20sent');logger[_0xdb20('0x12')](_0xdb20('0x13'),_0x3aa540,_0xdb20('0x14'),JSON[_0xdb20('0x15')](_0x2ea7ef));if(_0x2ea7ef[_0xdb20('0x16')]){if(_0x2ea7ef[_0xdb20('0x16')][_0xdb20('0x17')]===0x1f4){logger['error'](_0xdb20('0x18'),_0x3aa540,_0x2ea7ef[_0xdb20('0x16')][_0xdb20('0x19')]);return _0x2ea05c(_0x2ea7ef[_0xdb20('0x16')][_0xdb20('0x19')]);}logger[_0xdb20('0x16')](_0xdb20('0x18'),_0x3aa540,_0x2ea7ef[_0xdb20('0x16')]['message']);return _0x5804fc(_0x2ea7ef[_0xdb20('0x16')][_0xdb20('0x19')]);}else{logger[_0xdb20('0x11')]('SmsInteraction,\x20%s,\x20%s',_0x3aa540,_0xdb20('0x14'));_0x5804fc(_0x2ea7ef[_0xdb20('0x1a')]['message']);}})[_0xdb20('0x1b')](function(_0x232851){logger[_0xdb20('0x16')]('SmsInteraction,\x20%s,\x20%s',_0x3aa540,_0x232851);_0x2ea05c(_0x232851);});});}exports[_0xdb20('0x1c')]=function(_0x87a744){var _0x2c3810=this;return new Promise(function(_0x3ccbbf,_0x473f1c){return db['SmsInteraction'][_0xdb20('0x1d')](_0x87a744[_0xdb20('0x1e')],{'raw':_0x87a744['options']?_0x87a744[_0xdb20('0x1f')][_0xdb20('0x20')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x87a744['options']?_0x87a744[_0xdb20('0x1f')][_0xdb20('0x21')]||null:null,'attributes':_0x87a744[_0xdb20('0x1f')]?_0x87a744[_0xdb20('0x1f')][_0xdb20('0x22')]||null:null,'limit':_0x87a744[_0xdb20('0x1f')]?_0x87a744['options'][_0xdb20('0x23')]||null:null})[_0xdb20('0x10')](function(_0x638edd){logger[_0xdb20('0x11')]('UpdateSmsInteraction',_0x87a744);logger[_0xdb20('0x12')](_0xdb20('0x1c'),_0x87a744,JSON[_0xdb20('0x15')](_0x638edd));_0x3ccbbf(_0x638edd);})['catch'](function(_0x49ae43){logger[_0xdb20('0x16')](_0xdb20('0x1c'),_0x49ae43[_0xdb20('0x19')],_0x87a744);_0x473f1c(_0x2c3810[_0xdb20('0x16')](0x1f4,_0x49ae43['message']));});});};exports[_0xdb20('0x24')]=function(_0x15a74b){return new Promise(function(_0x696fd,_0x3ca25f){return db[_0xdb20('0x25')]['find']({'where':_0x15a74b[_0xdb20('0x1f')]?_0x15a74b[_0xdb20('0x1f')][_0xdb20('0x21')]||null:null})[_0xdb20('0x10')](function(_0x50f716){if(_0x50f716){return _0x50f716[_0xdb20('0x26')](_0x15a74b[_0xdb20('0x1e')][_0xdb20('0x27')],_[_0xdb20('0x28')](_0x15a74b[_0xdb20('0x1e')],[_0xdb20('0x27'),'id'])||{});}})['spread'](function(_0xf8672){logger[_0xdb20('0x11')]('AddTags',_0x15a74b);logger[_0xdb20('0x12')](_0xdb20('0x29'),_0x15a74b,JSON[_0xdb20('0x15')](_0xf8672));_0x696fd(_0xf8672);})[_0xdb20('0x1b')](function(_0x4f0678){logger[_0xdb20('0x16')](_0xdb20('0x29'),_0x4f0678[_0xdb20('0x19')],_0x15a74b);_0x3ca25f(_this['error'](0x1f4,_0x4f0678[_0xdb20('0x19')]));});});};