bd9bd94b0006d64b45e53d93b12af6fa98ef06f8
[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 _0x6caf=['request\x20sent','debug','SmsInteraction,\x20%s,\x20%s,\x20%s','error','code','message','SmsInteraction,\x20%s,\x20%s','catch','UpdateSmsInteraction','update','body','options','raw','where','attributes','limit','then','stringify','AddTagsToSmsInteraction','SmsInteraction','find','addTags','ids','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','request','info'];(function(_0xb7e5f5,_0x26000a){var _0x980c00=function(_0x2c0521){while(--_0x2c0521){_0xb7e5f5['push'](_0xb7e5f5['shift']());}};_0x980c00(++_0x26000a);}(_0x6caf,0x121));var _0xf6ca=function(_0xb7a459,_0xc13228){_0xb7a459=_0xb7a459-0x0;var _0x104ab5=_0x6caf[_0xb7a459];return _0x104ab5;};'use strict';var _=require(_0xf6ca('0x0'));var util=require(_0xf6ca('0x1'));var moment=require(_0xf6ca('0x2'));var BPromise=require(_0xf6ca('0x3'));var rs=require(_0xf6ca('0x4'));var fs=require('fs');var Redis=require(_0xf6ca('0x5'));var db=require(_0xf6ca('0x6'))['db'];var utils=require(_0xf6ca('0x7'));var logger=require(_0xf6ca('0x8'))(_0xf6ca('0x9'));var config=require(_0xf6ca('0xa'));var jayson=require(_0xf6ca('0xb'));var client=jayson[_0xf6ca('0xc')]['http']({'port':0x232a});config[_0xf6ca('0xd')]=_[_0xf6ca('0xe')](config[_0xf6ca('0xd')],{'host':_0xf6ca('0xf'),'port':0x18eb});var socket=require(_0xf6ca('0x10'))(new Redis(config[_0xf6ca('0xd')]));require('./smsInteraction.socket')['register'](socket);function respondWithRpcPromise(_0x6742f,_0x22148e,_0x363bf6){return new BPromise(function(_0x11b12c,_0x257165){return client[_0xf6ca('0x11')](_0x6742f,_0x363bf6)['then'](function(_0x410fa9){logger[_0xf6ca('0x12')]('SmsInteraction,\x20%s,\x20%s',_0x22148e,_0xf6ca('0x13'));logger[_0xf6ca('0x14')](_0xf6ca('0x15'),_0x22148e,'request\x20sent',JSON['stringify'](_0x410fa9));if(_0x410fa9[_0xf6ca('0x16')]){if(_0x410fa9[_0xf6ca('0x16')][_0xf6ca('0x17')]===0x1f4){logger[_0xf6ca('0x16')]('SmsInteraction,\x20%s,\x20%s',_0x22148e,_0x410fa9[_0xf6ca('0x16')]['message']);return _0x257165(_0x410fa9['error'][_0xf6ca('0x18')]);}logger[_0xf6ca('0x16')](_0xf6ca('0x19'),_0x22148e,_0x410fa9[_0xf6ca('0x16')][_0xf6ca('0x18')]);return _0x11b12c(_0x410fa9['error']['message']);}else{logger['info'](_0xf6ca('0x19'),_0x22148e,_0xf6ca('0x13'));_0x11b12c(_0x410fa9['result']['message']);}})[_0xf6ca('0x1a')](function(_0x399bbf){logger[_0xf6ca('0x16')]('SmsInteraction,\x20%s,\x20%s',_0x22148e,_0x399bbf);_0x257165(_0x399bbf);});});}exports[_0xf6ca('0x1b')]=function(_0xdc162){var _0x490cfd=this;return new Promise(function(_0x3317df,_0x3d8579){return db['SmsInteraction'][_0xf6ca('0x1c')](_0xdc162[_0xf6ca('0x1d')],{'raw':_0xdc162[_0xf6ca('0x1e')]?_0xdc162[_0xf6ca('0x1e')][_0xf6ca('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0xdc162[_0xf6ca('0x1e')]?_0xdc162[_0xf6ca('0x1e')][_0xf6ca('0x20')]||null:null,'attributes':_0xdc162[_0xf6ca('0x1e')]?_0xdc162[_0xf6ca('0x1e')][_0xf6ca('0x21')]||null:null,'limit':_0xdc162['options']?_0xdc162[_0xf6ca('0x1e')][_0xf6ca('0x22')]||null:null})[_0xf6ca('0x23')](function(_0x15c0d2){logger[_0xf6ca('0x12')](_0xf6ca('0x1b'),_0xdc162);logger[_0xf6ca('0x14')](_0xf6ca('0x1b'),_0xdc162,JSON[_0xf6ca('0x24')](_0x15c0d2));_0x3317df(_0x15c0d2);})[_0xf6ca('0x1a')](function(_0x34aef0){logger[_0xf6ca('0x16')](_0xf6ca('0x1b'),_0x34aef0[_0xf6ca('0x18')],_0xdc162);_0x3d8579(_0x490cfd['error'](0x1f4,_0x34aef0['message']));});});};exports[_0xf6ca('0x25')]=function(_0x1a5c90){return new Promise(function(_0x421d29,_0x249545){return db[_0xf6ca('0x26')][_0xf6ca('0x27')]({'where':_0x1a5c90[_0xf6ca('0x1e')]?_0x1a5c90[_0xf6ca('0x1e')][_0xf6ca('0x20')]||null:null})[_0xf6ca('0x23')](function(_0x267cdd){if(_0x267cdd){return _0x267cdd[_0xf6ca('0x28')](_0x1a5c90[_0xf6ca('0x1d')]['ids'],_['omit'](_0x1a5c90[_0xf6ca('0x1d')],[_0xf6ca('0x29'),'id'])||{});}})[_0xf6ca('0x2a')](function(_0x269cad){logger['info'](_0xf6ca('0x2b'),_0x1a5c90);logger['debug'](_0xf6ca('0x2b'),_0x1a5c90,JSON['stringify'](_0x269cad));_0x421d29(_0x269cad);})[_0xf6ca('0x1a')](function(_0x35a40a){logger[_0xf6ca('0x16')]('AddTags',_0x35a40a[_0xf6ca('0x18')],_0x1a5c90);_0x249545(_this[_0xf6ca('0x16')](0x1f4,_0x35a40a['message']));});});};