Built motion from commit b0a9a629.|2.6.33
[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 _0x1cf8=['../../config/utils','rpc','../../config/environment','jayson/promise','client','http','defaults','socket.io-emitter','./smsInteraction.socket','register','request','then','request\x20sent','debug','SmsInteraction,\x20%s,\x20%s,\x20%s','stringify','error','SmsInteraction,\x20%s,\x20%s','message','info','result','catch','UpdateSmsInteraction','SmsInteraction','update','body','options','raw','where','attributes','limit','AddTagsToSmsInteraction','find','addTags','ids','omit','AddTags','lodash','util','moment','bluebird','randomstring','../../mysqldb'];(function(_0x5c50ca,_0x1f1634){var _0x58652f=function(_0x47f8c3){while(--_0x47f8c3){_0x5c50ca['push'](_0x5c50ca['shift']());}};_0x58652f(++_0x1f1634);}(_0x1cf8,0xfc));var _0x81cf=function(_0x39c65b,_0x4b5a02){_0x39c65b=_0x39c65b-0x0;var _0x487fee=_0x1cf8[_0x39c65b];return _0x487fee;};'use strict';var _=require(_0x81cf('0x0'));var util=require(_0x81cf('0x1'));var moment=require(_0x81cf('0x2'));var BPromise=require(_0x81cf('0x3'));var rs=require(_0x81cf('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x81cf('0x5'))['db'];var utils=require(_0x81cf('0x6'));var logger=require('../../config/logger')(_0x81cf('0x7'));var config=require(_0x81cf('0x8'));var jayson=require(_0x81cf('0x9'));var client=jayson[_0x81cf('0xa')][_0x81cf('0xb')]({'port':0x232a});config['redis']=_[_0x81cf('0xc')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x81cf('0xd'))(new Redis(config['redis']));require(_0x81cf('0xe'))[_0x81cf('0xf')](socket);function respondWithRpcPromise(_0x5d69be,_0x5eff52,_0x4fd5d6){return new BPromise(function(_0x14847d,_0x210882){return client[_0x81cf('0x10')](_0x5d69be,_0x4fd5d6)[_0x81cf('0x11')](function(_0x12d0bf){logger['info']('SmsInteraction,\x20%s,\x20%s',_0x5eff52,_0x81cf('0x12'));logger[_0x81cf('0x13')](_0x81cf('0x14'),_0x5eff52,_0x81cf('0x12'),JSON[_0x81cf('0x15')](_0x12d0bf));if(_0x12d0bf[_0x81cf('0x16')]){if(_0x12d0bf['error']['code']===0x1f4){logger[_0x81cf('0x16')](_0x81cf('0x17'),_0x5eff52,_0x12d0bf[_0x81cf('0x16')]['message']);return _0x210882(_0x12d0bf[_0x81cf('0x16')][_0x81cf('0x18')]);}logger[_0x81cf('0x16')](_0x81cf('0x17'),_0x5eff52,_0x12d0bf['error']['message']);return _0x14847d(_0x12d0bf[_0x81cf('0x16')][_0x81cf('0x18')]);}else{logger[_0x81cf('0x19')](_0x81cf('0x17'),_0x5eff52,'request\x20sent');_0x14847d(_0x12d0bf[_0x81cf('0x1a')][_0x81cf('0x18')]);}})[_0x81cf('0x1b')](function(_0x40c5b0){logger[_0x81cf('0x16')](_0x81cf('0x17'),_0x5eff52,_0x40c5b0);_0x210882(_0x40c5b0);});});}exports[_0x81cf('0x1c')]=function(_0x3b74d7){var _0x27e991=this;return new Promise(function(_0x3070a1,_0x5b890f){return db[_0x81cf('0x1d')][_0x81cf('0x1e')](_0x3b74d7[_0x81cf('0x1f')],{'raw':_0x3b74d7[_0x81cf('0x20')]?_0x3b74d7[_0x81cf('0x20')][_0x81cf('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3b74d7[_0x81cf('0x20')]?_0x3b74d7[_0x81cf('0x20')][_0x81cf('0x22')]||null:null,'attributes':_0x3b74d7[_0x81cf('0x20')]?_0x3b74d7[_0x81cf('0x20')][_0x81cf('0x23')]||null:null,'limit':_0x3b74d7[_0x81cf('0x20')]?_0x3b74d7[_0x81cf('0x20')][_0x81cf('0x24')]||null:null})[_0x81cf('0x11')](function(_0x2e4003){logger[_0x81cf('0x19')](_0x81cf('0x1c'),_0x3b74d7);logger[_0x81cf('0x13')](_0x81cf('0x1c'),_0x3b74d7,JSON[_0x81cf('0x15')](_0x2e4003));_0x3070a1(_0x2e4003);})[_0x81cf('0x1b')](function(_0x4e0acd){logger['error'](_0x81cf('0x1c'),_0x4e0acd[_0x81cf('0x18')],_0x3b74d7);_0x5b890f(_0x27e991['error'](0x1f4,_0x4e0acd['message']));});});};exports[_0x81cf('0x25')]=function(_0x18ff90){return new Promise(function(_0x18a12f,_0x4cc5c6){return db[_0x81cf('0x1d')][_0x81cf('0x26')]({'where':_0x18ff90['options']?_0x18ff90[_0x81cf('0x20')][_0x81cf('0x22')]||null:null})[_0x81cf('0x11')](function(_0x37952b){if(_0x37952b){return _0x37952b[_0x81cf('0x27')](_0x18ff90[_0x81cf('0x1f')][_0x81cf('0x28')],_[_0x81cf('0x29')](_0x18ff90[_0x81cf('0x1f')],[_0x81cf('0x28'),'id'])||{});}})['spread'](function(_0x7e5b1){logger['info'](_0x81cf('0x2a'),_0x18ff90);logger[_0x81cf('0x13')](_0x81cf('0x2a'),_0x18ff90,JSON[_0x81cf('0x15')](_0x7e5b1));_0x18a12f(_0x7e5b1);})[_0x81cf('0x1b')](function(_0x1d6d24){logger[_0x81cf('0x16')]('AddTags',_0x1d6d24[_0x81cf('0x18')],_0x18ff90);_0x4cc5c6(_this['error'](0x1f4,_0x1d6d24[_0x81cf('0x18')]));});});};