Built motion from commit 3c2ce842.|2.6.31
[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 _0x95c8=['../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','defaults','localhost','socket.io-emitter','./smsInteraction.socket','register','request','then','info','SmsInteraction,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','UpdateSmsInteraction','SmsInteraction','update','body','options','where','attributes','limit','AddTagsToSmsInteraction','find','addTags','ids','omit','AddTags','lodash','util','moment','bluebird','randomstring'];(function(_0x1f36bb,_0x8af718){var _0xaf97fa=function(_0xeca489){while(--_0xeca489){_0x1f36bb['push'](_0x1f36bb['shift']());}};_0xaf97fa(++_0x8af718);}(_0x95c8,0xa3));var _0x895c=function(_0x5634e2,_0xcbc3d6){_0x5634e2=_0x5634e2-0x0;var _0x50b5f2=_0x95c8[_0x5634e2];return _0x50b5f2;};'use strict';var _=require(_0x895c('0x0'));var util=require(_0x895c('0x1'));var moment=require(_0x895c('0x2'));var BPromise=require(_0x895c('0x3'));var rs=require(_0x895c('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x895c('0x5'))['db'];var utils=require(_0x895c('0x6'));var logger=require(_0x895c('0x7'))(_0x895c('0x8'));var config=require(_0x895c('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x895c('0xa')][_0x895c('0xb')]({'port':0x232a});config['redis']=_[_0x895c('0xc')](config['redis'],{'host':_0x895c('0xd'),'port':0x18eb});var socket=require(_0x895c('0xe'))(new Redis(config['redis']));require(_0x895c('0xf'))[_0x895c('0x10')](socket);function respondWithRpcPromise(_0x1d61d7,_0xe7dd8b,_0x30d7d8){return new BPromise(function(_0x532535,_0x1900a2){return client[_0x895c('0x11')](_0x1d61d7,_0x30d7d8)[_0x895c('0x12')](function(_0x1cf6b3){logger[_0x895c('0x13')](_0x895c('0x14'),_0xe7dd8b,_0x895c('0x15'));logger[_0x895c('0x16')]('SmsInteraction,\x20%s,\x20%s,\x20%s',_0xe7dd8b,_0x895c('0x15'),JSON[_0x895c('0x17')](_0x1cf6b3));if(_0x1cf6b3['error']){if(_0x1cf6b3[_0x895c('0x18')]['code']===0x1f4){logger[_0x895c('0x18')]('SmsInteraction,\x20%s,\x20%s',_0xe7dd8b,_0x1cf6b3[_0x895c('0x18')]['message']);return _0x1900a2(_0x1cf6b3[_0x895c('0x18')][_0x895c('0x19')]);}logger[_0x895c('0x18')]('SmsInteraction,\x20%s,\x20%s',_0xe7dd8b,_0x1cf6b3['error'][_0x895c('0x19')]);return _0x532535(_0x1cf6b3[_0x895c('0x18')][_0x895c('0x19')]);}else{logger[_0x895c('0x13')]('SmsInteraction,\x20%s,\x20%s',_0xe7dd8b,_0x895c('0x15'));_0x532535(_0x1cf6b3[_0x895c('0x1a')]['message']);}})[_0x895c('0x1b')](function(_0x206a8a){logger[_0x895c('0x18')](_0x895c('0x14'),_0xe7dd8b,_0x206a8a);_0x1900a2(_0x206a8a);});});}exports[_0x895c('0x1c')]=function(_0x1ff4b2){var _0x14281e=this;return new Promise(function(_0x13892d,_0xc016ad){return db[_0x895c('0x1d')][_0x895c('0x1e')](_0x1ff4b2[_0x895c('0x1f')],{'raw':_0x1ff4b2[_0x895c('0x20')]?_0x1ff4b2[_0x895c('0x20')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1ff4b2[_0x895c('0x20')]?_0x1ff4b2[_0x895c('0x20')][_0x895c('0x21')]||null:null,'attributes':_0x1ff4b2[_0x895c('0x20')]?_0x1ff4b2[_0x895c('0x20')][_0x895c('0x22')]||null:null,'limit':_0x1ff4b2['options']?_0x1ff4b2['options'][_0x895c('0x23')]||null:null})[_0x895c('0x12')](function(_0x969ed6){logger[_0x895c('0x13')](_0x895c('0x1c'),_0x1ff4b2);logger[_0x895c('0x16')](_0x895c('0x1c'),_0x1ff4b2,JSON[_0x895c('0x17')](_0x969ed6));_0x13892d(_0x969ed6);})[_0x895c('0x1b')](function(_0x1d21f3){logger[_0x895c('0x18')](_0x895c('0x1c'),_0x1d21f3[_0x895c('0x19')],_0x1ff4b2);_0xc016ad(_0x14281e['error'](0x1f4,_0x1d21f3[_0x895c('0x19')]));});});};exports[_0x895c('0x24')]=function(_0x3ffb31){return new Promise(function(_0x3260c1,_0x2a7907){return db[_0x895c('0x1d')][_0x895c('0x25')]({'where':_0x3ffb31['options']?_0x3ffb31[_0x895c('0x20')][_0x895c('0x21')]||null:null})[_0x895c('0x12')](function(_0x446094){if(_0x446094){return _0x446094[_0x895c('0x26')](_0x3ffb31[_0x895c('0x1f')][_0x895c('0x27')],_[_0x895c('0x28')](_0x3ffb31[_0x895c('0x1f')],[_0x895c('0x27'),'id'])||{});}})['spread'](function(_0xc8de5b){logger[_0x895c('0x13')]('AddTags',_0x3ffb31);logger[_0x895c('0x16')](_0x895c('0x29'),_0x3ffb31,JSON[_0x895c('0x17')](_0xc8de5b));_0x3260c1(_0xc8de5b);})[_0x895c('0x1b')](function(_0x13aa15){logger['error'](_0x895c('0x29'),_0x13aa15[_0x895c('0x19')],_0x3ffb31);_0x2a7907(_this[_0x895c('0x18')](0x1f4,_0x13aa15[_0x895c('0x19')]));});});};