Built motion from commit 47436d59.|2.6.7
[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 _0x613b=['stringify','AddTagsToSmsInteraction','SmsInteraction','find','addTags','ids','AddTags','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./smsInteraction.socket','request','then','info','debug','SmsInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','SmsInteraction,\x20%s,\x20%s','message','result','catch','UpdateSmsInteraction','update','options','where','attributes'];(function(_0x212a37,_0xf35b2e){var _0x5d0bf9=function(_0x51850f){while(--_0x51850f){_0x212a37['push'](_0x212a37['shift']());}};_0x5d0bf9(++_0xf35b2e);}(_0x613b,0x16f));var _0xb613=function(_0x5d5da5,_0x530556){_0x5d5da5=_0x5d5da5-0x0;var _0x3e5ec5=_0x613b[_0x5d5da5];return _0x3e5ec5;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xb613('0x0'));var BPromise=require(_0xb613('0x1'));var rs=require(_0xb613('0x2'));var fs=require('fs');var Redis=require(_0xb613('0x3'));var db=require(_0xb613('0x4'))['db'];var utils=require(_0xb613('0x5'));var logger=require(_0xb613('0x6'))(_0xb613('0x7'));var config=require(_0xb613('0x8'));var jayson=require(_0xb613('0x9'));var client=jayson[_0xb613('0xa')]['http']({'port':0x232a});config[_0xb613('0xb')]=_[_0xb613('0xc')](config[_0xb613('0xb')],{'host':_0xb613('0xd'),'port':0x18eb});var socket=require(_0xb613('0xe'))(new Redis(config[_0xb613('0xb')]));require(_0xb613('0xf'))['register'](socket);function respondWithRpcPromise(_0x2022ed,_0x2b070f,_0x22bdbb){return new BPromise(function(_0x3fbd7b,_0x1c931d){return client[_0xb613('0x10')](_0x2022ed,_0x22bdbb)[_0xb613('0x11')](function(_0x1ae807){logger[_0xb613('0x12')]('SmsInteraction,\x20%s,\x20%s',_0x2b070f,'request\x20sent');logger[_0xb613('0x13')](_0xb613('0x14'),_0x2b070f,_0xb613('0x15'),JSON['stringify'](_0x1ae807));if(_0x1ae807[_0xb613('0x16')]){if(_0x1ae807[_0xb613('0x16')][_0xb613('0x17')]===0x1f4){logger[_0xb613('0x16')](_0xb613('0x18'),_0x2b070f,_0x1ae807[_0xb613('0x16')][_0xb613('0x19')]);return _0x1c931d(_0x1ae807[_0xb613('0x16')][_0xb613('0x19')]);}logger['error'](_0xb613('0x18'),_0x2b070f,_0x1ae807[_0xb613('0x16')][_0xb613('0x19')]);return _0x3fbd7b(_0x1ae807[_0xb613('0x16')][_0xb613('0x19')]);}else{logger[_0xb613('0x12')](_0xb613('0x18'),_0x2b070f,_0xb613('0x15'));_0x3fbd7b(_0x1ae807[_0xb613('0x1a')][_0xb613('0x19')]);}})[_0xb613('0x1b')](function(_0x19a5cf){logger['error'](_0xb613('0x18'),_0x2b070f,_0x19a5cf);_0x1c931d(_0x19a5cf);});});}exports[_0xb613('0x1c')]=function(_0x1ab99b){var _0x5ad90b=this;return new Promise(function(_0x40d694,_0x1d96e3){return db['SmsInteraction'][_0xb613('0x1d')](_0x1ab99b['body'],{'raw':_0x1ab99b['options']?_0x1ab99b[_0xb613('0x1e')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1ab99b[_0xb613('0x1e')]?_0x1ab99b[_0xb613('0x1e')][_0xb613('0x1f')]||null:null,'attributes':_0x1ab99b['options']?_0x1ab99b['options'][_0xb613('0x20')]||null:null,'limit':_0x1ab99b[_0xb613('0x1e')]?_0x1ab99b['options']['limit']||null:null})[_0xb613('0x11')](function(_0x56686b){logger[_0xb613('0x12')]('UpdateSmsInteraction',_0x1ab99b);logger['debug'](_0xb613('0x1c'),_0x1ab99b,JSON[_0xb613('0x21')](_0x56686b));_0x40d694(_0x56686b);})[_0xb613('0x1b')](function(_0x5d389d){logger[_0xb613('0x16')](_0xb613('0x1c'),_0x5d389d[_0xb613('0x19')],_0x1ab99b);_0x1d96e3(_0x5ad90b[_0xb613('0x16')](0x1f4,_0x5d389d[_0xb613('0x19')]));});});};exports[_0xb613('0x22')]=function(_0x5467fa){return new Promise(function(_0x3e917d,_0x2217d4){return db[_0xb613('0x23')][_0xb613('0x24')]({'where':_0x5467fa[_0xb613('0x1e')]?_0x5467fa[_0xb613('0x1e')]['where']||null:null})[_0xb613('0x11')](function(_0x2c50a8){if(_0x2c50a8){return _0x2c50a8[_0xb613('0x25')](_0x5467fa['body'][_0xb613('0x26')],_['omit'](_0x5467fa['body'],[_0xb613('0x26'),'id'])||{});}})['spread'](function(_0x3e1a72){logger[_0xb613('0x12')]('AddTags',_0x5467fa);logger['debug'](_0xb613('0x27'),_0x5467fa,JSON['stringify'](_0x3e1a72));_0x3e917d(_0x3e1a72);})['catch'](function(_0x1a77d6){logger[_0xb613('0x16')](_0xb613('0x27'),_0x1a77d6[_0xb613('0x19')],_0x5467fa);_0x2217d4(_this[_0xb613('0x16')](0x1f4,_0x1a77d6[_0xb613('0x19')]));});});};