Built motion from commit dc14b02d.|2.6.27
[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 _0x2c0f=['socket.io-emitter','register','request','info','SmsInteraction,\x20%s,\x20%s','request\x20sent','debug','SmsInteraction,\x20%s,\x20%s,\x20%s','stringify','code','message','error','result','catch','UpdateSmsInteraction','SmsInteraction','update','body','raw','options','attributes','limit','AddTagsToSmsInteraction','find','where','then','addTags','ids','spread','AddTags','util','moment','randomstring','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','redis','localhost'];(function(_0x82129b,_0x484ae9){var _0x2ae5dc=function(_0x299e34){while(--_0x299e34){_0x82129b['push'](_0x82129b['shift']());}};_0x2ae5dc(++_0x484ae9);}(_0x2c0f,0x11a));var _0xf2c0=function(_0x5e709a,_0x1d7975){_0x5e709a=_0x5e709a-0x0;var _0x57401a=_0x2c0f[_0x5e709a];return _0x57401a;};'use strict';var _=require('lodash');var util=require(_0xf2c0('0x0'));var moment=require(_0xf2c0('0x1'));var BPromise=require('bluebird');var rs=require(_0xf2c0('0x2'));var fs=require('fs');var Redis=require(_0xf2c0('0x3'));var db=require(_0xf2c0('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0xf2c0('0x5'))('rpc');var config=require(_0xf2c0('0x6'));var jayson=require(_0xf2c0('0x7'));var client=jayson[_0xf2c0('0x8')][_0xf2c0('0x9')]({'port':0x232a});config[_0xf2c0('0xa')]=_['defaults'](config[_0xf2c0('0xa')],{'host':_0xf2c0('0xb'),'port':0x18eb});var socket=require(_0xf2c0('0xc'))(new Redis(config[_0xf2c0('0xa')]));require('./smsInteraction.socket')[_0xf2c0('0xd')](socket);function respondWithRpcPromise(_0x56c02d,_0x971a4b,_0x5b0043){return new BPromise(function(_0x37e1ad,_0x36f402){return client[_0xf2c0('0xe')](_0x56c02d,_0x5b0043)['then'](function(_0x58258b){logger[_0xf2c0('0xf')](_0xf2c0('0x10'),_0x971a4b,_0xf2c0('0x11'));logger[_0xf2c0('0x12')](_0xf2c0('0x13'),_0x971a4b,'request\x20sent',JSON[_0xf2c0('0x14')](_0x58258b));if(_0x58258b['error']){if(_0x58258b['error'][_0xf2c0('0x15')]===0x1f4){logger['error'](_0xf2c0('0x10'),_0x971a4b,_0x58258b['error'][_0xf2c0('0x16')]);return _0x36f402(_0x58258b['error'][_0xf2c0('0x16')]);}logger['error'](_0xf2c0('0x10'),_0x971a4b,_0x58258b[_0xf2c0('0x17')]['message']);return _0x37e1ad(_0x58258b[_0xf2c0('0x17')]['message']);}else{logger[_0xf2c0('0xf')](_0xf2c0('0x10'),_0x971a4b,'request\x20sent');_0x37e1ad(_0x58258b[_0xf2c0('0x18')][_0xf2c0('0x16')]);}})[_0xf2c0('0x19')](function(_0x3d7e0d){logger[_0xf2c0('0x17')](_0xf2c0('0x10'),_0x971a4b,_0x3d7e0d);_0x36f402(_0x3d7e0d);});});}exports[_0xf2c0('0x1a')]=function(_0x1f32a4){var _0x3b00bf=this;return new Promise(function(_0x40f3cd,_0x392e09){return db[_0xf2c0('0x1b')][_0xf2c0('0x1c')](_0x1f32a4[_0xf2c0('0x1d')],{'raw':_0x1f32a4['options']?_0x1f32a4['options'][_0xf2c0('0x1e')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1f32a4[_0xf2c0('0x1f')]?_0x1f32a4[_0xf2c0('0x1f')]['where']||null:null,'attributes':_0x1f32a4[_0xf2c0('0x1f')]?_0x1f32a4[_0xf2c0('0x1f')][_0xf2c0('0x20')]||null:null,'limit':_0x1f32a4[_0xf2c0('0x1f')]?_0x1f32a4[_0xf2c0('0x1f')][_0xf2c0('0x21')]||null:null})['then'](function(_0x158609){logger['info'](_0xf2c0('0x1a'),_0x1f32a4);logger[_0xf2c0('0x12')](_0xf2c0('0x1a'),_0x1f32a4,JSON[_0xf2c0('0x14')](_0x158609));_0x40f3cd(_0x158609);})[_0xf2c0('0x19')](function(_0x4f3870){logger['error']('UpdateSmsInteraction',_0x4f3870[_0xf2c0('0x16')],_0x1f32a4);_0x392e09(_0x3b00bf['error'](0x1f4,_0x4f3870['message']));});});};exports[_0xf2c0('0x22')]=function(_0x215b3b){return new Promise(function(_0x1a734b,_0xcd05c0){return db[_0xf2c0('0x1b')][_0xf2c0('0x23')]({'where':_0x215b3b[_0xf2c0('0x1f')]?_0x215b3b['options'][_0xf2c0('0x24')]||null:null})[_0xf2c0('0x25')](function(_0xfd9904){if(_0xfd9904){return _0xfd9904[_0xf2c0('0x26')](_0x215b3b[_0xf2c0('0x1d')][_0xf2c0('0x27')],_['omit'](_0x215b3b[_0xf2c0('0x1d')],['ids','id'])||{});}})[_0xf2c0('0x28')](function(_0x20e595){logger[_0xf2c0('0xf')](_0xf2c0('0x29'),_0x215b3b);logger[_0xf2c0('0x12')](_0xf2c0('0x29'),_0x215b3b,JSON[_0xf2c0('0x14')](_0x20e595));_0x1a734b(_0x20e595);})[_0xf2c0('0x19')](function(_0x5f17ae){logger[_0xf2c0('0x17')](_0xf2c0('0x29'),_0x5f17ae[_0xf2c0('0x16')],_0x215b3b);_0xcd05c0(_this[_0xf2c0('0x17')](0x1f4,_0x5f17ae[_0xf2c0('0x16')]));});});};