Built motion from commit 511216ff.|2.6.34
[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 _0x705b=['SmsInteraction,\x20%s,\x20%s','debug','request\x20sent','stringify','error','code','message','result','catch','UpdateSmsInteraction','SmsInteraction','update','options','raw','where','limit','AddTagsToSmsInteraction','find','addTags','body','omit','ids','AddTags','lodash','util','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','./smsInteraction.socket','register','request','then','info'];(function(_0x13d2d5,_0x39e8be){var _0x53ffcc=function(_0x438e70){while(--_0x438e70){_0x13d2d5['push'](_0x13d2d5['shift']());}};_0x53ffcc(++_0x39e8be);}(_0x705b,0xe4));var _0xb705=function(_0x135a36,_0x2fcf5f){_0x135a36=_0x135a36-0x0;var _0x3571d3=_0x705b[_0x135a36];return _0x3571d3;};'use strict';var _=require(_0xb705('0x0'));var util=require(_0xb705('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xb705('0x2'));var db=require(_0xb705('0x3'))['db'];var utils=require(_0xb705('0x4'));var logger=require(_0xb705('0x5'))('rpc');var config=require(_0xb705('0x6'));var jayson=require(_0xb705('0x7'));var client=jayson[_0xb705('0x8')][_0xb705('0x9')]({'port':0x232a});config[_0xb705('0xa')]=_[_0xb705('0xb')](config[_0xb705('0xa')],{'host':_0xb705('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb705('0xa')]));require(_0xb705('0xd'))[_0xb705('0xe')](socket);function respondWithRpcPromise(_0x5a4515,_0x4162bf,_0xf6e9a8){return new BPromise(function(_0x35727f,_0x1651fe){return client[_0xb705('0xf')](_0x5a4515,_0xf6e9a8)[_0xb705('0x10')](function(_0x504121){logger[_0xb705('0x11')](_0xb705('0x12'),_0x4162bf,'request\x20sent');logger[_0xb705('0x13')]('SmsInteraction,\x20%s,\x20%s,\x20%s',_0x4162bf,_0xb705('0x14'),JSON[_0xb705('0x15')](_0x504121));if(_0x504121[_0xb705('0x16')]){if(_0x504121[_0xb705('0x16')][_0xb705('0x17')]===0x1f4){logger[_0xb705('0x16')](_0xb705('0x12'),_0x4162bf,_0x504121[_0xb705('0x16')][_0xb705('0x18')]);return _0x1651fe(_0x504121['error'][_0xb705('0x18')]);}logger['error'](_0xb705('0x12'),_0x4162bf,_0x504121[_0xb705('0x16')][_0xb705('0x18')]);return _0x35727f(_0x504121['error'][_0xb705('0x18')]);}else{logger[_0xb705('0x11')](_0xb705('0x12'),_0x4162bf,_0xb705('0x14'));_0x35727f(_0x504121[_0xb705('0x19')][_0xb705('0x18')]);}})[_0xb705('0x1a')](function(_0x152307){logger[_0xb705('0x16')](_0xb705('0x12'),_0x4162bf,_0x152307);_0x1651fe(_0x152307);});});}exports[_0xb705('0x1b')]=function(_0x4e3350){var _0x1da946=this;return new Promise(function(_0x17d37f,_0x121189){return db[_0xb705('0x1c')][_0xb705('0x1d')](_0x4e3350['body'],{'raw':_0x4e3350[_0xb705('0x1e')]?_0x4e3350[_0xb705('0x1e')][_0xb705('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x4e3350[_0xb705('0x1e')]?_0x4e3350[_0xb705('0x1e')][_0xb705('0x20')]||null:null,'attributes':_0x4e3350['options']?_0x4e3350[_0xb705('0x1e')]['attributes']||null:null,'limit':_0x4e3350['options']?_0x4e3350[_0xb705('0x1e')][_0xb705('0x21')]||null:null})[_0xb705('0x10')](function(_0x3f8f43){logger[_0xb705('0x11')](_0xb705('0x1b'),_0x4e3350);logger[_0xb705('0x13')](_0xb705('0x1b'),_0x4e3350,JSON[_0xb705('0x15')](_0x3f8f43));_0x17d37f(_0x3f8f43);})[_0xb705('0x1a')](function(_0x14353){logger['error'](_0xb705('0x1b'),_0x14353[_0xb705('0x18')],_0x4e3350);_0x121189(_0x1da946[_0xb705('0x16')](0x1f4,_0x14353[_0xb705('0x18')]));});});};exports[_0xb705('0x22')]=function(_0x37dc92){return new Promise(function(_0xc3279f,_0x250b03){return db[_0xb705('0x1c')][_0xb705('0x23')]({'where':_0x37dc92['options']?_0x37dc92[_0xb705('0x1e')][_0xb705('0x20')]||null:null})[_0xb705('0x10')](function(_0xf5f2be){if(_0xf5f2be){return _0xf5f2be[_0xb705('0x24')](_0x37dc92[_0xb705('0x25')]['ids'],_[_0xb705('0x26')](_0x37dc92[_0xb705('0x25')],[_0xb705('0x27'),'id'])||{});}})['spread'](function(_0x343cbc){logger[_0xb705('0x11')]('AddTags',_0x37dc92);logger['debug'](_0xb705('0x28'),_0x37dc92,JSON['stringify'](_0x343cbc));_0xc3279f(_0x343cbc);})['catch'](function(_0x1cb6be){logger[_0xb705('0x16')](_0xb705('0x28'),_0x1cb6be[_0xb705('0x18')],_0x37dc92);_0x250b03(_this['error'](0x1f4,_0x1cb6be['message']));});});};